Problem description
When a video player is in each scrollableView view, orientation changes from portrait to landscape might cause the video to stop playing and disappear.
Steps to reproduce
var win1 = Titanium.UI.createWindow({
backgroundColor:'white'
});
var videoParams = {
mediaControlStyle: Titanium.Media.VIDEO_CONTROL_EMBEDDED,
scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FIT,
height: '72%'
};
var videoViews = [];
for(var i=0; i<7; i++){
videoViews.push(Ti.Media.createVideoPlayer(videoParams));
}
var scrollableView = Ti.UI.createScrollableView({
views: videoViews,
showPagingControl: true
});
scrollableView.addEventListener('scroll', function(e){
videoViews[e.currentPage].url = 'movie.mp4';
});
win1.add(scrollableView);
win1.open();
- Create a scrollableView with a video in each view (used the movie.mp4 video taken also from KitchenSink).
- Open the app and scroll to the last view.
Result: video is displayed
- Rotate the screen
Result: video stops and is not displayed anymore
- Change the number of views from 7 to 5 or set a cacheSize bigger than the stack
Result: video works as expected also when rotated
Additional notes
Customer ticket link:
http://support-admin.appcelerator.com/display/APP-992365
Probably due to the fact the views are removed and re-added during orientation change
Pull pending https://github.com/appcelerator/titanium_mobile/pull/2156
It's a number of things, although I found that videos do glitch out if you have more than one onscreen. (Note that in Apple's own native implementation, you can have more than one videoplayer active at a time.) I'm going to check to see if this is a fully native issue, or if there is something that can be done in Titanium.
Above test code will not work as only one movie player can be active at a time. Use this code to test instead.
Pull request merged. The developer may have to modify his JS file to resemble the final test in order to compensate for iOS not allowing more than one video player at a time.
Tested with: Titanium Studio, build: 2.1.0.201206251749 Titanium SDK: 2.1.0.v20120626104306 Device: iPad 3rd gen (5.1.1) First view is blank, and 7th view is covered with black blank window after device rotation. I used Vishal's code for testing, but changed number of views from 20 to 7.
Use this updated test code. The whole view management can be done much better through the newly introduced 'scrollEnd' event
Closing as fixed. Tested and verified with: Titanium Studio, build: 2.1.0.201206251749 Titanium SDK: 2.1.0.v20120627121617 Device: iPad 3rd gen (5.1.1)