Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Member
Posts: 1
Registered: ‎04-19-2012
My Device: developer
My Carrier: t-mobile

Redirecting Blackberry After Embedded YouTube Finishes

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

 

code:

    // create youtube player
    var player;
    
    function onYouTubePlayerAPIReady() {
        player = new YT.Player('player', {
          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";
        }
    }