When playing a media file in a UIWebview (youtube for instance)
there is a button to "fullscreen" the html5 media player - How can I
To force videos to always play in fullscreen, when configuring your UIWebView
, use this line of code:
webView.allowsInlineMediaPlayback = NO;
It looks like there are a few ways to detect entering and leaving fullscreen, though it seems like these are not recommended approaches. See the linked StackOverflow question.
Depending on what you're trying to do, it almost seems like you're better off detecting player state change using the onStateChange
callback. In a project I'm working on, the code looks like this:
function onStateChange(event) {
window.location.href = 'ytplayer://onStateChange?data=' + event.data;
}
Then I sniff for this URL in the controller or view wrapper class:
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
if([request.URL.scheme isEqualToString:@"ytplayer"]) {
NSString *action = request.URL.host;
And here is how to force webview
to exit video playback fullscreen:
[_webView reload];
It's not clean and it will also stop video playback. But I think this is the only way to exit video fullscreen playback.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With