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);
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.
Thank you for your help
Perfect ticket, Jamil - thank you! :)
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.
This issue latest notification was not sent due to JIRA mail setting. Fixed now. Please check the issue for latests changes.
Closing due to inactivity. If this issue still exists, please raise a new ticket.