Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12156] iOS: In iOS6, Modal Window with video player in it leaves a black screen on close

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionHold
Resolution Date2017-03-21T21:15:15.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2013 Sprint 08 API, 2013 Sprint 08
ComponentsiOS
Labelsios6, videoplayer
ReporterAnirudh Nagesh
AssigneeVishal Duggal
Created2012-12-27T02:40:54.000+0000
Updated2017-03-21T21:15:20.000+0000

Description

Modal window with a video player inside it does not close properly and leaves a black screen on completion of video. It happens only on iOS6. On iOS5, works as expected. Window closes properly and returns to the root window. Run the below code to see the behavior.
var rootwin = Ti.UI.createWindow({
    backgroundColor : 'red',
    navBarHidden : true,
    top : 0,
    left : 0,
    right : 0,
    bottom : 0
});

var button = Ti.UI.createButton({
    title : 'Play Video',
    width : '250dp',
    height : '50dp'
});
button.addEventListener('click', function(e){
    var win = Ti.UI.createWindow({
        navBarHidden : true,
        backgroundColor : '#ffffff',
        exitOnClose : true,
        top : 0,
        left : 0,
        right : 0,
        bottom : 0,
        orientationModes:[Ti.UI.PORTRAIT,Ti.UI.LANDSCAPE_LEFT,Ti.UI.LANDSCAPE_RIGHT],
        modal : true // comment this line to see proper behavior
    });
    
    var videoPlayer = Titanium.Media.createVideoPlayer({
        repeatMode : Ti.Media.VIDEO_REPEAT_MODE_NONE,
        url : 'http://monactifry-tevolys.seb-cms-qual.bearstech.com/videos/9789.mp4',
        backgroundColor : 'black',
        mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
        scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT,
        fullscreen : true,
        autoplay : true
    });
    
    function onComplete() {
        videoPlayer.stop();
        win.close();
    }
    
    function onFullScreen(e) {
        if (e.entering == 0) {
            videoPlayer.stop();
            win.close();    
        }
    }
    
    videoPlayer.addEventListener('complete', onComplete);
 
    videoPlayer.addEventListener('fullscreen', onFullScreen);
    
    win.add(videoPlayer);

    
    win.open();
});
rootwin.add(button);

rootwin.open();

Note: Opening just a modal window( without video player ) from root window works fine and expected.

Comments

  1. Chris Carranza 2012-12-27

    I've been having this same problem but didn't know it had anything to do with a videoplayer being inside the window. My problem has the exact same behavior yet is a bit different. It only happens when i open a modal window from a tableview, then return to a previous view in the navigationgroup, when i return to the window with the tableview, its appears as if the click on the table is trying to open the Modal window twice. This may or may not be directly related to this error, but it only happens when changing to SDK 3.0.0.GA, if i take the exact same code and run it with 2.1.4.GA it works just fine.
       [INFO] :  open
       [INFO] :  open
       [DEBUG] :  New scheme: <NSMutableURLRequest http://www.websitehere.com>;
       [DEBUG] :  2012-12-27 13:48:18.025 App[58687:c07] *** Assertion failure in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:], /SourceCache/UIKit_Sim/UIKit-2372/UIWindowController.m:211
       [ERROR] :  Script Error = Attempting to begin a modal transition from <UINavigationController: 0xb369430> to <UINavigationController: 0xa641c20> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed at JobCallsView.js (line 268).
       [WARN] :  ing: Attempt to present <TiErrorController: 0xa63e430> on <TiRootViewController: 0xb3be310> while a presentation is in progress!
       
  2. Chris Carranza 2013-02-20

    Nothing on this yet?
  3. Eric Merriman 2013-03-13

    Verified occurs with: SDK: 3.0.2.GA SDK: 3.1.0.v20130312161655 Titanium Studio, build: 3.0.2.201302191606 The "onComplete" function is executed, but the win.close(); event doesn't have any effect. Additional note: If you tap the screen during play and hit the "done" button, you get this in the log: [WARN] :   ing: Attempt to dismiss from view controller while a presentation or dismiss is in progress! Also, the onFullscreen function was not called during my test, even when tapping the "fullscreen" button, even though the video already is in fullscreen.
  4. Vishal Duggal 2013-04-15

    The blank screen on complete on iOS6 has been reported in TIMOB-11212 and a workaround has been provided. However using that workaround will still not work in this case since you are trying to close the window while it is dismissing its presented fullscreen video player Using this code will solve the issue and work consistently across various iOS versions.
       var rootwin = Ti.UI.createWindow({
           backgroundColor : 'red',
           navBarHidden : true,
           top : 0,
           left : 0,
           right : 0,
           bottom : 0
       });
        
       var button = Ti.UI.createButton({
           title : 'Play Video',
           width : '250dp',
           height : '50dp'
       });
       button.addEventListener('click', function(e){
           var win = Ti.UI.createWindow({
               navBarHidden : true,
               backgroundColor : '#ffffff',
               exitOnClose : true,
               top : 0,
               left : 0,
               right : 0,
               bottom : 0,
               orientationModes:[Ti.UI.PORTRAIT,Ti.UI.LANDSCAPE_LEFT,Ti.UI.LANDSCAPE_RIGHT],
               modal : true // comment this line to see proper behavior
           });
            
           var videoPlayer = Titanium.Media.createVideoPlayer({
               repeatMode : Ti.Media.VIDEO_REPEAT_MODE_NONE,
               url : 'http://monactifry-tevolys.seb-cms-qual.bearstech.com/videos/9789.mp4',
               backgroundColor : 'black',
               mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
               scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT,
               fullscreen : false,
               autoplay : true
           });
            
           function onComplete() {
               Ti.API.info('COMPLETE')
               videoPlayer.fullscreen = false;
           }
            
           function onFullScreen(e) {
               if (e.entering == 0) {
                   videoPlayer.stop();
                   delay = e.duration*1000;
                   Ti.API.info('FULLSCREEN '+delay)
                   //Since this is a modal window have to wait for fullscreen controller to dismiss before closing the window
                   setTimeout(function(){win.close()},delay);
               }
           }
            
           videoPlayer.addEventListener('complete', onComplete);
         
           videoPlayer.addEventListener('fullscreen', onFullScreen);
       
           var fsset = false;
           videoPlayer.addEventListener('loadstate',function(e){
               if(e.loadState = Ti.Media.VIDEO_LOAD_STATE_PLAYTHROUGH_OK && fsset == false) {
                   Ti.API.info('FS TRUE');
                   fsset = true;
                   setTimeout(function(){videoPlayer.fullscreen = true;},300);
               }
           })
            
           win.add(videoPlayer);
        
            
           win.open();
       });
       rootwin.add(button);
        
       rootwin.open();
       
  5. Vishal Duggal 2013-04-15

    Going to resolve this as HOLD. This should be revisited on iOS 4.X deprecation. JS workaround in ticket
  6. Lee Morris 2017-03-21

    Closing ticket due to the time that has passed since it was filed and iOS 4 has been deprecated.

JSON Source