Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to obtain video duration from youtube api using simpeXML?
    primarykey
    data
    text
    <p>I've got this xml response from youtube</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:yt="http://gdata.youtube.com/schemas/2007"&gt; &lt;id&gt;http://gdata.youtube.com/feeds/api/videos/9mZb6PZM4FU&lt;/id&gt; &lt;published&gt;2010-01-09T19:38:15.000Z&lt;/published&gt; &lt;updated&gt;2013-07-17T06:51:32.000Z&lt;/updated&gt; &lt;category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video" /&gt; &lt;category scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="Entertainment" label="Розваги" /&gt; &lt;title type="text"&gt;Каратэ&lt;/title&gt; &lt;content type="text"&gt;Сцена из фильма "Не бойся, я с тобой"&lt;/content&gt; &lt;link rel="alternate" type="text/html" href="http://www.youtube.com/watch?v=9mZb6PZM4FU&amp;amp;feature=youtube_gdata" /&gt; &lt;link rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/9mZb6PZM4FU/responses" /&gt; &lt;link rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/9mZb6PZM4FU/related" /&gt; &lt;link rel="http://gdata.youtube.com/schemas/2007#mobile" type="text/html" href="http://m.youtube.com/details?v=9mZb6PZM4FU" /&gt; &lt;link rel="self" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/9mZb6PZM4FU" /&gt; &lt;author&gt; &lt;name&gt;Lefan123&lt;/name&gt; &lt;uri&gt;http://gdata.youtube.com/feeds/api/users/Lefan123&lt;/uri&gt; &lt;/author&gt; &lt;gd:comments&gt; &lt;gd:feedLink rel="http://gdata.youtube.com/schemas/2007#comments" href="http://gdata.youtube.com/feeds/api/videos/9mZb6PZM4FU/comments" countHint="80" /&gt; &lt;/gd:comments&gt; &lt;media:group&gt; &lt;media:category label="Розваги" scheme="http://gdata.youtube.com/schemas/2007/categories.cat"&gt;Entertainment&lt;/media:category&gt; &lt;media:content url="http://www.youtube.com/v/9mZb6PZM4FU?version=3&amp;amp;f=videos&amp;amp;app=youtube_gdata" type="application/x-shockwave-flash" medium="video" isDefault="true" expression="full" duration="174" yt:format="5" /&gt; &lt;media:content url="rtsp://r4---sn-4g57kuek.c.youtube.com/CiILENy73wIaGQlV4Ez26Ftm9hMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="174" yt:format="1" /&gt; &lt;media:content url="rtsp://r4---sn-4g57kuek.c.youtube.com/CiILENy73wIaGQlV4Ez26Ftm9hMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="174" yt:format="6" /&gt; &lt;media:description type="plain"&gt;Сцена из фильма "Не бойся, я с тобой"&lt;/media:description&gt; &lt;media:keywords /&gt; &lt;media:player url="http://www.youtube.com/watch?v=9mZb6PZM4FU&amp;amp;feature=youtube_gdata_player" /&gt; &lt;media:thumbnail url="http://i1.ytimg.com/vi/9mZb6PZM4FU/0.jpg" height="360" width="480" time="00:01:27" /&gt; &lt;media:thumbnail url="http://i1.ytimg.com/vi/9mZb6PZM4FU/1.jpg" height="90" width="120" time="00:00:43.500" /&gt; &lt;media:thumbnail url="http://i1.ytimg.com/vi/9mZb6PZM4FU/2.jpg" height="90" width="120" time="00:01:27" /&gt; &lt;media:thumbnail url="http://i1.ytimg.com/vi/9mZb6PZM4FU/3.jpg" height="90" width="120" time="00:02:10.500" /&gt; &lt;media:title type="plain"&gt;Каратэ&lt;/media:title&gt; &lt;yt:duration seconds="174" /&gt; &lt;/media:group&gt; &lt;gd:rating average="4.934732" max="5" min="1" numRaters="429" rel="http://schemas.google.com/g/2005#overall" /&gt; &lt;yt:statistics favoriteCount="0" viewCount="215169" /&gt; &lt;/entry&gt; </code></pre> <p>I trying get duration by using this code</p> <pre><code>public function getVideoLength($id) { $this-&gt;getVideoFeed($id); if ($this-&gt;xmlEntry == null) return 0; $duration = $this-&gt;xmlEntry-&gt;media['group']-&gt;yt['duration']; return $duration; } </code></pre> <p>but $duration is null. How to get it ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload