Titanium Community Questions & Answer Archive

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

Video player disappear

Hi.
I have a video player at window 1 and the event listener for video player is to open a new window to play the video. But after finish playing at the new window, the video player at window 1 will give me nothing(cannot see the video player).
Here is my code for window 1:

var videoView = Titanium.UI.createView({  
    //backgroundColor:'white',
    top:280,
    width:300,
    left: 20,
    right: 20,
    height: 180,
    opacity : 1,
    borderWidth: 0
});

var player = Titanium.Media.createVideoPlayer({
    url:'../video/movie.mp4',
    //backgroundColor: 'white',
    movieControlMode:Titanium.Media.VIDEO_CONTROL_NONE,
    scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});

videoView.add(player);
player.stop();

player.addEventListener('click',function()
{
    if (player.playing) {
        player.stop();
        var w = Ti.UI.createWindow({
            url: '../MTE/video.js',
            backgroundColor: 'white',
            title: titleLabel.text
        });
        Titanium.UI.currentTab.open(w);
    }
    else if(player.stop)
    {
        w = Ti.UI.createWindow({
            url: '../MTE/video.js',
            backgroundColor: 'white',
            title: titleLabel.text
        });
        Titanium.UI.currentTab.open(w);
    }

code for new window:

var win = Ti.UI.currentWindow;

win.orientationModes = [
    Titanium.UI.LANDSCAPE_LEFT,
    Titanium.UI.LANDSCAPE_RIGHT
];

var player = Titanium.Media.createVideoPlayer({
    url:'../video/movie.mp4',
    backgroundColor: 'white',
    width:480,
    height:250,
    movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT,
    scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});

player.addEventListener('complete',function(e){
    win.close();
});

player.stop();

win.add(player);

Anyone can help me?
Thank you!

— asked August 19th 2010 by Haoming Cheng
  • disappear
  • videoplayer
  • window
0 Comments

1 Answer

  • I had this problem up until awhile ago. I believe it is your Event Listeners. The only (major) difference between yours and my code is that I have this:

    win.addEventListener('close', function() {
        activeMovie.stop();
    });
    

    Hope that helps? I know, I ain't that great at helping :P

    — answered August 19th 2010 by Colton Arabsky
    permalink
    2 Comments
    • Thanks for your answer, but where should I put it? New window or the original one?

      — commented August 19th 2010 by Haoming Cheng
    • Right below the:

      player.addEventListener('complete',function(e){
          win.close();
      });
      

      In the new window.

      — commented August 19th 2010 by Colton Arabsky
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.