I’m trying to have a page reload to another place after the end of an embedded YouTube video. It works in every browser I’ve tested so far … except Blackberry. The video plays, but rather than redirect, instead it replays the video.
Here’s the nifty code.
You can see the page in action at: http://bit.ly/I0csry
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: '3MGQor2YaHA',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// autoplay video
function onPlayerReady(event) {
event.target.playVideo();
}
// when video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
window.location = "http://www.stage.celebritycruises.com/m/explore/destinations/home.do?dest=ALCAN";
}
}