Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: deprecate mediaPlaybackAllowsAirPlay #785

Merged
merged 2 commits into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,17 @@ - (WKWebViewConfiguration*) createConfigurationFromSettings:(NSDictionary*)setti
configuration.mediaTypesRequiringUserActionForPlayback = mediaTypesRequiringUserActionForPlayback;

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

/*
* If the old preference key "MediaPlaybackAllowsAirPlay" exists, use it or default to "YES".
* Check if the new preference key "AllowsAirPlayForMediaPlayback" exists and overwrite the "MediaPlaybackAllowsAirPlay" value.
*/
BOOL allowsAirPlayForMediaPlayback = [settings cordovaBoolSettingForKey:@"MediaPlaybackAllowsAirPlay" defaultValue:YES];
if([settings cordovaSettingForKey:@"AllowsAirPlayForMediaPlayback"] != nil) {
allowsAirPlayForMediaPlayback = [settings cordovaBoolSettingForKey:@"AllowsAirPlayForMediaPlayback" defaultValue:YES];
}
configuration.allowsAirPlayForMediaPlayback = allowsAirPlayForMediaPlayback;

return configuration;
}

Expand Down
3 changes: 2 additions & 1 deletion bin/templates/scripts/cordova/lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ function updateFileResources (cordovaProject, locations) {

function alertDeprecatedPreference (configParser) {
const deprecatedToNewPreferences = {
MediaPlaybackRequiresUserAction: 'MediaTypesRequiringUserActionForPlayback'
MediaPlaybackRequiresUserAction: 'MediaTypesRequiringUserActionForPlayback',
MediaPlaybackAllowsAirPlay: 'AllowsAirPlayForMediaPlayback'
};

Object.keys(deprecatedToNewPreferences).forEach(oldKey => {
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