Fetch the first youtube video via json jquery and display it as a teaser -
i have need pull out first video teaser display code below:
$.getjson('http://gdata.youtube.com/feeds/api/videos?q=love&alt=json-in-script&callback=?&max-results=3&start-index=1', function(data) { $.each(data.feed.entry, function(i, item) { var title = item['title']['$t']; var video = item['id']['$t']; // need variable store first video id array here manipulated via php later //var videoid1 = ?; video = video.replace('http://gdata.youtube.com/feeds/api/videos/','http://www.youtube.com/watch?v='); //replacement of link videoid = video.replace('http://www.youtube.com/watch?v=',''); // removing link , getting video id $('#videonavs .navs').append('<li><a href="'+video+'"> '+title+' -'+videoid+ '</a></li>'); // }); });
and html:
<div id="videos"> <object width="286" height="210"> <param value="http://www.youtube.com/v/[this should first video id/ videoid1 manipulated via php]&feature=youtube_gdata&hl=en_us&fs=1&rel=0" name="movie"> <param value="true" name="allowfullscreen"> <param value="always" name="allowscriptaccess"> </object> </div> <div id="videonavs"><ul class="navs"></ul></div>
this json if place callback "showmyvideos".
any hints appreciated. thanks
Comments
Post a Comment