Support » Plugin: ACF YouTube Picker » Time

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter pro100light

    (@pro100light)

    I add this

    in youtubepicker.php

    public static function duration ( $vid, $apikey ) {
    				if( $vid = self::is_vid( $vid ) ) {
    					$dur = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=$vid&key=$apikey");
    					$VidDuration =json_decode($dur, true);
    					foreach ($VidDuration['items'] as $vidTime)
    					{
    					$VidDuration= $vidTime['contentDetails']['duration'];
    					}
    					// convert duration from ISO to M:S
    					$date = new DateTime('2000-01-01');
    					$date->add(new DateInterval($VidDuration));
    
    					return ( $date->format('i:s') );
    				}
    			}

    in acf-youtubepicker-v5.php
    LINE: 537

    'duration' => html_entity_decode( youtubepicker::duration( $v['vid'], $field['api_key'] ) )

    use like this: $video[‘duration’]

    Plugin Author airesvsg

    (@airesvsg)

    Hi pro100light!

    Follow the link below with the changes.

    https://github.com/airesvsg/acf-youtubepicker/commit/6f495d1a215e0585edbfe2a1457886e4ebb3e470

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Time’ is closed to new replies.