Quantcast
Viewing latest article 1
Browse Latest Browse All 8

Getting info from the standard iPhone video player opened from a webview

Hi All, QUESTION: How do I tell when the user has clicked the "Done" button in the standard iPhone video player? Or in more general terms, how do I find out anything about the state of the standard iPhone video player whilst it is open?

I am playing video from a webview with some embedded HTML5 video code from Viddler. The HTML is (in file "show_video.html"):-

<html>
<head>
<script type="text/javascript">
function tiPlay()
{
    Titanium.App.fireEvent('htmlVideoStarted');
}
function tiPause()
{
    Titanium.App.fireEvent('htmlVideoPaused');
}
</script>
</head>
<body style="margin:0; padding: 0">
    <video id="viddlerVideo-87cd75f3" src="http://www.viddler.com/file/87cd75f3/html5mobile/" type="video/mp4" width="320" height="180" poster="http://www.viddler.com/thumbnail/87cd75f3/" controls="controls" onPlay="tiPlay();" onPause="tiPause();"> </video>
</body>
</html>
This is opened in a standard Titanium webview:-
var _thisWindow = Ti.UI.currentWindow;
var _topView = Titanium.UI.createWebView(
{
    url: './show_video.html',
    width: 320,
    height: 180,
});
_thisWindow.add(_topView);
Titanium.App.addEventListener('htmlVideoStarted', function(evt)
{
    alert('started');
});
Titanium.App.addEventListener('htmlVideoPaused', function(evt)
{
    alert('video paused');
});
This all works fine, the video thumbnail has an overlayed "play" icon and when clicked it opens the standard iPhone video player. I can get callbacks to my Titanium code on playing and pausing the video using Titanium.App.fireEvent. All good. But I want the video to auto-orient in the standard iPhone video player, but not in my launching window. So I want to change the window orientations when the video player has been opened ie
if (in_standard_iphone_video_player)
    _thisWindow.orientationModes = [Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT, Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT];
else
    _thisWindow.orientationModes = [Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT];
To do this I know when the user opens the standard iPhone video player by clicking on my embedded video link. The problem is I don't know how to find out when the user clicks the "Done" button to close the standard video player. I can check for whether the video is paused, but that may be whilst still in the standard video player. I have tried all manner of tricks to try and find out view or window information that changes when this standard video player is opened/closed but can't get anywhere.

QUESTION: How do I tell when the user has clicked the "Done" button in the standard iPhone video player? Or, in more general terms, how do I find out anything about the state of the standard iPhone video player whilst it is open?

Cheers Simon Buckingham, Creative Director, Icecandy Entertainment simon@icecandy.com www.icecandy.com


Viewing latest article 1
Browse Latest Browse All 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>