
June 7th, 2011, 02:24 AM
|
|
Contributing User
|
|
Join Date: Aug 2008
Posts: 51
Time spent in forums: 10 h 3 m 6 sec
Reputation Power: 5
|
|
|
Problem playing youtube video using javascript(jquery)
hi I am trying to play a video from youtube. What I have done so far is getting videos from my database and displaying all those videos thumbnails. So now what i want is to when i click any thumbnail it should play that video in my website. How can I do this?
Here is my code
Code:
function showResult(result) {
$('#videosLoader').css('display','none');
var videoId = result.split(" ");
for(i = 0; i < videoId.length - 1; i++) {
var vidId = $.trim(videoId[i]);
vidLink = getScreen(vidId,"small");
$('#videosList').append("<div class='playVid'>" +
"<img width=80 height=80 src=" + vidLink + " alt='' /> " +
"<input type='hidden' name='vidId' value='" + vidId + "' />" +
"</div>").addClass("playVid");
}
$('.playVid').click(function() {
var val = $("input[name='vidId']").val();
alert("val");
$("#haveYourDefinition").append("<embed src='http://www.youtube.com/v/" + val + "&rel=1' pluginspage='http://adobe.com/go/getflashplayer' type='application/x-shockwave-flash' quality='high' width='450' height='376' bgcolor='#ffffff' loop='false'></embed>");
});
When I click any thumbnail it does nothing. Why and please tell me how to do this? Help
|