Skip to content

Commit

Permalink
refactor: deprecate mediaPlaybackAllowsAirPlay
Browse files Browse the repository at this point in the history
Apple has deprecated "mediaPlaybackAllowsAirPlay" in iOS 8.0-9.0.
This flag should be replaced with "allowsAirPlayForMediaPlayback".
Preference name has also been changed to "AllowsAirPlayForMediaPlayback"
  • Loading branch information
erisu committed Feb 12, 2020
1 parent 077c835 commit e26f876
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@ - (WKWebViewConfiguration*) createConfigurationFromSettings:(NSDictionary*)setti
configuration.mediaTypesRequiringUserActionForPlayback = mediaTypesRequiringUserActionForPlayback;

configuration.suppressesIncrementalRendering = [settings cordovaBoolSettingForKey:@"SuppressesIncrementalRendering" defaultValue:NO];
configuration.mediaPlaybackAllowsAirPlay = [settings cordovaBoolSettingForKey:@"MediaPlaybackAllowsAirPlay" defaultValue:YES];

// Check for usage of the older preference key, alert, and use.
BOOL allowsAirPlayForMediaPlayback = [settings cordovaBoolSettingForKey:@"AllowsAirPlayForMediaPlayback" defaultValue:YES];
NSString *mediaPlaybackAllowsAirPlayKey = [settings cordovaSettingForKey:@"MediaPlaybackAllowsAirPlay"];
if(mediaPlaybackAllowsAirPlayKey != nil) {
allowsAirPlayForMediaPlayback = [settings cordovaBoolSettingForKey:@"MediaPlaybackAllowsAirPlay" defaultValue:YES];
}
configuration.allowsAirPlayForMediaPlayback = allowsAirPlayForMediaPlayback;

return configuration;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/CordovaLibTests/CDVWebViewEngineTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ - (void) testUpdateInfo {
[@"AllowInlineMediaPlayback" lowercaseString] : @YES, // default is NO
[@"MediaTypesRequiringUserActionForPlayback" lowercaseString] : @YES, // default is NO
[@"SuppressesIncrementalRendering" lowercaseString] : @YES, // default is NO
[@"MediaPlaybackAllowsAirPlay" lowercaseString] : @NO, // default is YES
[@"AllowsAirPlayForMediaPlayback" lowercaseString] : @NO, // default is YES
[@"DisallowOverscroll" lowercaseString] : @YES, // so bounces is to be NO. defaults to NO
[@"WKWebViewDecelerationSpeed" lowercaseString] : @"fast" // default is 'normal'
};
Expand All @@ -108,7 +108,7 @@ - (void) testUpdateInfo {
XCTAssertTrue(wkWebView.configuration.mediaTypesRequiringUserActionForPlayback);
XCTAssertFalse(wkWebView.configuration.allowsInlineMediaPlayback);
XCTAssertFalse(wkWebView.configuration.suppressesIncrementalRendering);
XCTAssertTrue(wkWebView.configuration.mediaPlaybackAllowsAirPlay);
XCTAssertTrue(wkWebView.configuration.allowsAirPlayForMediaPlayback);

// in the test above, DisallowOverscroll is YES, so no bounce
if ([wkWebView respondsToSelector:@selector(scrollView)]) {
Expand All @@ -135,7 +135,7 @@ - (void) testConfigurationFromSettings {
[@"AllowInlineMediaPlayback" lowercaseString] : @YES, // default is NO
[@"MediaTypesRequiringUserActionForPlayback" lowercaseString] : @YES, // default is NO
[@"SuppressesIncrementalRendering" lowercaseString] : @YES, // default is NO
[@"MediaPlaybackAllowsAirPlay" lowercaseString] : @NO, // default is YES
[@"AllowsAirPlayForMediaPlayback" lowercaseString] : @NO, // default is YES
[@"DisallowOverscroll" lowercaseString] : @YES, // so bounces is to be NO. defaults to NO
[@"WKWebViewDecelerationSpeed" lowercaseString] : @"fast" // default is 'normal'
};
Expand All @@ -157,7 +157,7 @@ - (void) testConfigurationFromSettings {
XCTAssertTrue(wkWebView.configuration.allowsInlineMediaPlayback);
XCTAssertTrue(wkWebView.configuration.suppressesIncrementalRendering);
// The test case below is in a separate test "testConfigurationWithMediaPlaybackAllowsAirPlay" (Apple bug)
// XCTAssertFalse(wkWebView.configuration.mediaPlaybackAllowsAirPlay);
// XCTAssertFalse(wkWebView.configuration.allowsAirPlayForMediaPlayback);

// in the test above, DisallowOverscroll is YES, so no bounce
if ([wkWebView respondsToSelector:@selector(scrollView)]) {
Expand Down

0 comments on commit e26f876

Please sign in to comment.