Full-screen video player in 1.4 / iOS4
I've been looking through a number of threads on the topic, and am still coming out confused.
I have a table view with a bunch of videos listed. When the user clicks a row, I want them to be taken to a full-screen video player in widescreen (landscape) orientation to see the video. When it's complete or they click Done, they're returned to the table view.
This used to be accomplished with something like this:
var activeMovie = Ti.Media.createVideoPlayer({...});
activeMovie.play();
In 1.4 the videoPlayer behaviour is much different. I was eventually able to cobble together something like the old behaviour (adding a new window, adding videoPlayer to it, setting videoPlayer to fullscreen, changing orientationModes, listening for leaving fullscreen so I can stop & release videoPlayer and close window…), but performance on the device was terrible - took a long time to get into and out of the player, and video wouldn't play smoothly.
If someone could provide a working example for emulating the old behaviour of videoPlayer, I would greatly appreciate it.
Thanks!
4 Answers
-
OK I have something working similarly now. Not the most elegant because you still see the rotation, but it pretty much works:
var win = Ti.UI.currentWindow; ... var activeMovie = Ti.Media.createVideoPlayer({ url:videoURL, movieControlMode:Ti.Media.VIDEO_CONTROL_DEFAULT, scalingMode:Ti.Media.VIDEO_SCALING_ASPECT_FILL // better than MODE_FILL, preserves aspect ratio }); win.add(activeMovie); win.orientationModes = [Ti.UI.LANDSCAPE_RIGHT]; activeMovie.fullscreen = true; activeMovie.play(); activeMovie.addEventListener('fullscreen', function(e){ // when fullscreen status is changed if (!e.entering){ // user pressed "Done" or video finished win.remove(activeMovie); win.orientationModes = [Ti.UI.PORTRAIT]; } });
Not sure if this is the optimal approach, but it seems to be working. win.remove(activeMovie) is enough to release it from memory, correct?
-
To be fair, I read Apple IOS 4 guideline, and that's how current SDk behave, not completely TI issue.
However, there are many more problems you may encounter with this version of videoplayer.
-On first video clip, a small spinner would stay there forever unless video is played back on fullscreen. The next movie will get rid of the problem though. So you must force video to load on fullscreen, otherwise, first clip will always has a spinner on top of the movie. I wish there's no default spinner, adding one myself then listening to loadstate would solve the issue.
-Done button's not longer trigger anything, otherwise you could use that to close video. You still need a complete event handler for 3.2 and below devices.
-Embeded movie (HTML 5) can't close on iPad (as universal app)
-
This should help, just posted it.
http://developer.appcelerator.com/question/135367/fullscreen-video-player-example-works -
25