Youtube API 从 XML 获取视频时长 [英] Youtube API get video duration from the XML
问题描述
考虑 Youtube API XML 文件,例如 http://gdata.youtube.com/feeds/api/videos/$id一个特定的 XML 数据文件是 http://gdata.youtube.com/feeds/api/videos/GI6CfKcMhjY以下函数根据 XML url 获取视频的标题:
Consider Youtube API XML files like http://gdata.youtube.com/feeds/api/videos/$id One particular XML data file is http://gdata.youtube.com/feeds/api/videos/GI6CfKcMhjY The following function gets the title of the video according to the XML url:
function ytTitle($ytid,$ytURLConstant){
$url = $ytURLConstant.$ytid;
$doc = new DOMDocument;
$doc->load($url);
echo $title = $doc->getElementsByTagName("title")->item(0)->nodeValue;
}
如我所见,XML 文件中有视频时长:
As I see there is video duration in the XML file:
<media:title type='plain'>Jack Sparrow (feat. Michael Bolton)</media:title><yt:duration seconds='197'/>
由于我是 XML 新手,任何有关获取视频时长的帮助将不胜感激.
As I am an XML newbie any help concerning getting the video duration will be greatly appreciated.
推荐答案
我在使用 Youtube API 时遇到了类似的问题,我发现这个网站非常有用
I had a similar problem with Youtube API and I find this very helpful site
http://viewsboard.com/boards/view/discussion/2/263
这篇关于Youtube API 从 XML 获取视频时长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!