Get duration from a youtube url

前端 未结 6 1152
感情败类
感情败类 2021-02-08 10:51

Im looking for a function that will pull the youtube duration of a video from the url. I read some tutorials but don\'t get it. I embed videos on my site using a url and I have

6条回答
  •  不要未来只要你来
    2021-02-08 11:05

    You could use something like this:

    data->duration;
        }
    
        echo getDuration('http://www.youtube.com/watch?v=rFQc7VRJowk');
    
    ?>
    

    that returns the duration in seconds of the video.

    Reference: http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html

    You can use a function like this one to change the seconds to hours, minutes, and seconds.

提交回复
热议问题