Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Youtube: View Count/Time Duration stamp on the thumbnail mechanism
    primarykey
    data
    text
    <p>I am having difficulties trying displaying a thumbnail with time DURATION. The code renders a thumbnail but without any times. Also, the views are coming out with a result of O views. Everything else is being fetch properly. </p> <pre><code> &lt;?php error_reporting(E_ALL); $feedURL = 'http://gdata.youtube.com/feeds/api/users/YOURUSERNAME/uploads?max-results=2'; $sxml = simplexml_load_file($feedURL); $i=0; foreach ($sxml-&gt;entry as $entry) { $media = $entry-&gt;children('media', true); $watch = (string)$media-&gt;group-&gt;player-&gt;attributes()-&gt;url; $thumbnail = (string)$media-&gt;group-&gt;thumbnail[0]-&gt;attributes()-&gt;url; // get &lt;yt:duration&gt; node for video length $yt = $entry-&gt;children('http://gdata.youtube.com/feeds/api/users/YOURUSERNAME/uploads?max-results=2'); $attrs = $yt-&gt;duration-&gt;attributes(); // get &lt;yt:stats&gt; node for viewer statistics $yt = $entry-&gt;children('http://gdata.youtube.com/feeds/api/users/YOURUSERNAME/uploads?max-results=2'); $attrs = $yt-&gt;statistics-&gt;attributes(); $viewCount = $attrs['viewCount']; ?&gt; &lt;div class="videoitem" style="height:"&gt; &lt;div class="videotitle" style="float:right; width:220px; "&gt; &lt;h3 &gt;&lt;a href="&lt;?php echo $watch; ?&gt;" class="watchvideo"&gt;&lt;?php echo $media-&gt;group-&gt;title; ?&gt;&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;&lt;?php echo sprintf("%0.2f", $length/60) . " min. | {$viewCount} views&lt;br/&gt;\n"; ?&gt; &lt;/p&gt; &lt;/div&gt; &lt;div class="videothumb" style="height:100px;"&gt;&lt;a href="&lt;?php echo $watch; ?&gt;" class="watchvideo"&gt;&lt;img src="&lt;?php echo $thumbnail;?&gt;" alt="&lt;?php echo $media-&gt;group-&gt;title; ?&gt;" width="150px" height="85px" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;?php $i++; if($i==3) { echo '&lt;div class="clear small_v_margin"&gt;&lt;/div&gt;'; $i=0; } } ?&gt; </code></pre>
    singulars
    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