Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Stop video when navigating away

Hi all

Hope you can help me with this.

In a window I have a local movie playing (from the kitchen sink examples) how do I make this video stop when navigating away from the window by clicking the tab bar?

Cheers Dennis

— asked November 23rd 2010 by Dennis Nielsen
0 Comments

4 Answers

  • Accepted Answer

    let's say you have win1 that inside has the movieplayer1

    win1 belongs to tab1

    you should be able to do this:

    win1.addEventListener('blur', function(){
       movieplayer1.stop();
    })
    

    So when you click on tab2, the win1 get's "blurred" and triggers the stop method for movieplayer1.
    Hope it makes sense :)

    — answered November 23rd 2010 by Dan Tamas
    permalink
    0 Comments
  • Catch the blur event of the window and stop the video there.

    — answered November 23rd 2010 by Dan Tamas
    permalink
    0 Comments
  • Could you explain that in step by step?

    Best

    — answered November 23rd 2010 by Dennis Nielsen
    permalink
    0 Comments
  • that works great! but now the video is gone when i navigate back to the video tab?

    
    //
    // create controls tab and root window
    //
    var win3 = Titanium.UI.createWindow({  
        title:'Video',
        backgroundImage:"iPad_banner.png",
        navBarHidden:true,
    
    
    
    });
    
    
    
    var android = (Titanium.Platform.name == 'android');
    
    var activeMovie = Titanium.Media.createVideoPlayer({
        contentURL:'images/joystick.mp4',
    
    
    
    
    
        backgroundColor:'#111',
        movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT,
        scalingMode:Titanium.Media.VIDEO_SCALING_MODE_FILL
    
    });
    
    if (parseFloat(Titanium.Platform.version) >= 3.2)
    {
        activeMovie.movieControlStyle = Titanium.Media.VIDEO_CONTROL_EMBEDDED;
    //    activeMovie.movieControlStyle = Titanium.Media.VIDEO_CONTROL_FULLSCREEN;
    //    activeMovie.movieControlStyle = Titanium.Media.VIDEO_CONTROL_NONE;
        if (Titanium.Platform.osname == "ipad") {
            activeMovie.width = 500;
            activeMovie.height = 300;
        }
        win3.add(activeMovie);
    }
    
    
    
    win3.addEventListener('blur', function(){
       activeMovie.stop();
    })
    
    
    
    
    var tab3 = Titanium.UI.createTab({  
        icon:'KS_nav_ui.png',
        title:'Video',
        window:win3
    });
    
    
    
    
    
    var label3 = Titanium.UI.createLabel({
        color:'#999',
        text:'I am Window 3',
        font:{fontSize:20,fontFamily:'Helvetica Neue'},
        textAlign:'center',
        width:'auto'
    });
    
    
    win3.add(label3);
    
    — answered November 23rd 2010 by Dennis Nielsen
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.