apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.16k stars 989 forks source link

Config.xml prefs do not apply to Secondary webview (Airplay)? #1055

Closed josiaho closed 1 year ago

josiaho commented 3 years ago

Bug Report

Problem

I want to play/autoplay an inline video on a secondary screen (Airplay). Test Project: Looper.zip

What is expected to happen?

Once the extended screen (airplay) launches, the inline video should load and autoplay.

What does actually happen?

Once the extended screen (airplay) launches, the inline video appears to load, but does not autoplay.

Information

My config.xml contains the following preferences: <preference name="AllowInlineMediaPlayback" value="true" /> <preference name="MediaTypesRequiringUserActionForPlayback" value="none" /> And my external page contains this tag: <video src="img/fireandiceocean.mp4" preload autoplay playsinline loop />

The preferences do not appear to apply to the secondary webview.

I've modified the cordova-plugin-wkwebview-external-screen plugin in WKWebViewExternalScreen.m with the following with no avail:

- (WKWebView*)getWebView {
    if (!self.externalWebView) {
        UIScreen* externalScreen = [[UIScreen screens] objectAtIndex: 1];
        CGRect screenBounds = externalScreen.bounds;

        self.externalWebView = [[WKWebView alloc] initWithFrame: screenBounds configuration: [[WKWebViewConfiguration alloc] init]];

        // I ADDED THESE TWO LINES
        self.externalWebView.configuration.allowsInlineMediaPlayback = YES;// Updated 'true' to 'YES'
        self.externalWebView.configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;

        self.externalWindow = [[UIWindow alloc] initWithFrame: screenBounds];

        self.externalWindow.screen = externalScreen;
        self.externalWindow.clipsToBounds = YES;
        [self.externalWindow addSubview:self.externalWebView];
        [self.externalWindow makeKeyAndVisible];
        self.externalWindow.hidden = NO;
    }
    return self.externalWebView;
}

Any thoughts?

Environment, Platform, Device

iPhone 7, iPad Mini 2, iPad Air 2, iPod touch gen 7, Xcode Simulators - all on iOS 14.2

Version information

Cordova: CLI 10.0.0, iOS 6.1.1 macOS 11.1 on an intel Retina iMac and M1 MacBook Air Xcode 12.3

Checklist

dpogue commented 1 year ago

I've marked this issue as stale because it's been over a year with no further comments. If this is still an issue in the latest cordova-ios version and an up-to-date iOS version, please let us know. Otherwise, this issue will be closed.

dpogue commented 1 year ago

Closing as stale.