سؤال

Is there a way to play video without it launching fullscreen? Trigger.IO API does not have an option to set it up apparently, and adding 'webkit-playsinline' inside HTML5 video tag is not enough on iPhone as well, as it needs property 'allowsInlineMediaPlayback' of 'UIWebView' to be set as 'YES'.

I would expect Trigger.IO to have some kind of option to trigger this property on or off...

P.S. It looks like Phone Gap supports it already...

هل كانت مفيدة؟

المحلول

You could easily write your own native module to change WebView properties in a Trigger.io app. The function would probably look a lot like this:

+ (void)enableInlineMediaPlayback:(ForgeTask*)task {
    if (NSClassFromString(@"WKWebView") && [[ForgeApp sharedApp] useWKWebView]) {
        // Handle new WebView 
        WKWebView *webView = (WKWebView*)[[ForgeApp sharedApp] webView];
        WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
        configuration.allowsInlineMediaPlayback = YES;
        webView.configuration = configuration;
    } else {
        // Handle old WebView
        UIWebView *webView = (UIWebView*)[[ForgeApp sharedApp] webView];
        webView.allowsInlineMediaPlayback = YES;
    }
    [task success:nil];
}

Additionally, you need to add the webkit-playsinline attribute to the video HTML tag.


EDIT: I've adjusted the code to include relevant code for iOS8 and WKWebView.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top