Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6938] iOS: Media - VideoPlayer fullscreen landscape video will not close window on complete event

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-07-27T17:36:47.000+0000
Affected Version/sRelease 1.7.5
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterJamil Hassan Spain
AssigneeIngo Muschenetz
Created2011-11-06T14:43:13.000+0000
Updated2017-07-27T17:36:47.000+0000

Description

Expected Behavior

The application is restricted to starting in Portrait mode. When the user clicks a button, the video player will play an external video ( amazon s3 bucket file ) in landscape window mode. The video file is a .m4v and is formatted for landscape dimension already. The "complete" eventListener is attached to the video Player in the new window. When adding and "complete" event listener on the VideoPlayer, I should be able to run a window.close() and the root window will now be visible.

Actual Behavior

The window will not close when the Done button is hit by user or the video play back ends. Both conditions that are captured by the complete eventListener on the video player. When playing the video in portrait mode, the window will close. So I have narrowed it down to being in landscape mode only.

Test Case

Titanium.UI.setBackgroundColor('#000');
// create Window
var win = Ti.UI.createWindow({});
	
	var button = Ti.UI.createButton({
		title: 'View Landscape Fullscreen Video',
		width: 250,
		height: 60
	});
	button.addEventListener('click', function(e){
		
		var _win = Ti.UI.createWindow({
			url: 'video-player.js'
		});
		
		_win.open({animated:true});
		
	});
	
win.add(button);
win.open();
var _win = Titanium.UI.currentWindow;

Titanium.UI.orientation = Ti.UI.LANDSCAPE_RIGHT;
 _win.orientationModes = [Ti.UI.LANSCAPE_RIGHT];
 
var activeMovie = Titanium.Media.createVideoPlayer({
	contentURL: 'https://iwwmg.s3.amazonaws.com/trailer-drake.m4v', //ks-movie.mp4
	backgroundColor:'#000',
	fullscreen: true,
	autoplay: true,
	height:320,
	width: 420,
	movieControlMode:Titanium.Media.VIDEO_CONTROL_FULLSCREEN,
	scalingMode:Titanium.Media.VIDEO_SCALING_MODE_FILL
});		

activeMovie.addEventListener('complete',function(e){
	if ( Titanium.Media.VIDEO_FINISH_REASON_USER_EXITED ) {
		_win.close();
		Ti.UI.orientation = Ti.UI.PORTRAIT;
		Ti.API.error('VIDEO_FINISH_REASON_USER_EXITED: Action was clicked');
	} else if ( Titanium.Media.VIDEO_FINISH_REASON_PLAYBACK_ENDED ) {
		_win.close();	
		Ti.UI.orientation = Ti.UI.PORTRAIT;
		Ti.API.error('VIDEO_FINISH_REASON_PLAYBACK_ENDED: Action was clicked');
	}					
});
				
_win.add(activeMovie);	

Comments

  1. Paul Dowsett 2011-11-06

    Jamil Thank you for raising this. If true, it looks to be a serious problem. In order for me to escalate it to our developers, though, the ticket needs to include all the information described in the [JIRA Ticket Checklist](http://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist), not least a test case (see [Creating a Test Case](http://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-CreatingaTestCase)). As each ticket should only contain one bug, would you create a different ticket for the following? This will also need to include a test case.
       There is also an issue with the following Video constants not being registering in iOS5.  Here are the two that I have found issues with from testing:
       
       VIDEO_FINISH_REASON_PLAYBACK_ENDED
       VIDEO_FINISH_REASON_USER_EXITED
       
       Here is a link to the pdf of the iOS documentation with references to the aforementioned related constants around Page 22-23: [MPMoviePlayerController_Class.pdf](http://developer.apple.com/library/ios/DOCUMENTATION/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController_Class.pdf)
       
       They are also additional options to Airplay media as well ( properties page 10-11 ) that may have future implications. 
       
    Thank you for your help
  2. Paul Dowsett 2011-12-29

    Perfect ticket, Jamil - thank you! :)
  3. Darren Harper 2012-02-05

    Hi all, I know this is an ongoing bug but I found a workaround for this issue. My app is always defaulted to Portrait view except when viewing a video, in which case it is set to Landscape Left. I discovered this bug when I tried to apply the win.close(); function to the event listener which listens for the video completing. The workaround for this is to set the orientation of the window back to Portrait in the event listener function (see code below). I haven't tested this on anything other than Titanium SDK 1.8.0.1 using the iPhone emulator on iOS SDK 5.0 so I can't say it works for other SDK versions. Here is the code for the event listener, where win2 is the currentWindow and activeMovie is the variable that runs Titanium.Media.createVideoPlayer activeMovie.addEventListener('complete', function (e) { win2.close(); Ti.UI.currentWindow.orientationModes = [Titanium.UI.PORTRAIT]; }); I hope this helps someone out as it took me a while to figure out the problem.
  4. Nikolai Derzhak 2012-02-06

    This issue latest notification was not sent due to JIRA mail setting. Fixed now. Please check the issue for latests changes.
  5. Lee Morris 2017-07-27

    Closing due to inactivity. If this issue still exists, please raise a new ticket.

JSON Source