Watch duration of a Youtube video?

Asked

Viewed 65 times

1

How is it possible to view the time of a video through the id of the video?

With some research I found how to see the title but I could not find the duration.

    $content = file_get_contents("http://youtube.com/get_video_info?video_id=".$id_vid);
    parse_str($content, $ytarr);
    $titulo_v = $ytarr['title'];

With the above code shown, I can see the title of the video but how do I do with the duration? It is possible in the same way?

  • have to see what are the return data, give a print_r in the variable $ytarr

1 answer

2


Within the variable $ytarr has the index length_seconds that brings the duration of the video in seconds:

$seconds = $ytarr['length_seconds'];
  • 1

    I did the print_r and discovered that too, I will accept this answer as soon as I can, it worked perfectly

Browser other questions tagged

You are not signed in. Login or sign up in order to post.