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
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 :) -
Catch the blur event of the window and stop the video there.
-
Could you explain that in step by step?
Best
-
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);