I know there are several questions for this topic. I even got a great answer here.
The problem is the following. I have a piece of code I can't change that shows the youtube video. I have to adapt to it.
The problem is that the function onPlayerStateChange() never start. Any idea why this happens?
<script src="http://www.youtube.com/player_api"></script>
<script type="text/javascript">
var ytPlayer;
var idplayer;
function onYouTubePlayerReady(playerId) {
ytPlayer = document.getElementById("ytPlayer");
}
function pauseVideo() {
if (ytPlayer) {
ytPlayer.stopVideo();
}
}
// when video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
idplayer=document.getElementById("a_TMBLRWDLH").href;
window.location.assign(idplayer);
}
}
j$(document).ready(function(){
j$('#' + Bnr_vars[0].banner).click(function(){
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)))
{
var info='<iframe width=\"600\" height=\"338\" src=\"http://www.youtube.com/embed/0Bmhjf0rKe8?rel=0&wmode=transparent&modestbranding=1&autoplay=1&enablejsapi=1\" frameborder=\"0\" allowfullscreen></iframe>';
j$('#player').html(info);
}
});
</script>