cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [2/2] ios commit: CB-7184 - Implement support for mediaPlaybackAllowsAirPlay in UIWebView and WKWebView
Date Mon, 21 Jul 2014 21:48:58 GMT
CB-7184 - Implement support for mediaPlaybackAllowsAirPlay in UIWebView and WKWebView

plus config cleanup.


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/3d39ef4e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/3d39ef4e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/3d39ef4e

Branch: refs/heads/wkwebview
Commit: 3d39ef4e34e2ff994ee725fe5e2b956334eee854
Parents: 7ce625b
Author: Shazron Abdullah <shazron@apache.org>
Authored: Mon Jul 21 14:48:51 2014 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Mon Jul 21 14:48:51 2014 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVWebViewPreferences.m | 42 +++++++++++++++++--------
 1 file changed, 29 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3d39ef4e/CordovaLib/Classes/CDVWebViewPreferences.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVWebViewPreferences.m b/CordovaLib/Classes/CDVWebViewPreferences.m
index f1cb48f..eb55c9d 100644
--- a/CordovaLib/Classes/CDVWebViewPreferences.m
+++ b/CordovaLib/Classes/CDVWebViewPreferences.m
@@ -72,25 +72,34 @@
 
 - (void)updateUIWebView:(UIWebView*)theWebView settings:(NSDictionary*)settings
 {
-    NSString* enableViewportScale = [self cordovaSettings:settings forKey:@"EnableViewportScale"];
-    NSNumber* allowInlineMediaPlayback = [self cordovaSettings:settings forKey:@"AllowInlineMediaPlayback"];
-    BOOL mediaPlaybackRequiresUserAction = YES;  // default value
+    BOOL scalesPageToFit = NO; // default
+    id prefObj = [self cordovaSettings:settings forKey:@"EnableViewportScale"];
 
-    if ([self cordovaSettings:settings forKey:@"MediaPlaybackRequiresUserAction"]) {
-        mediaPlaybackRequiresUserAction = [(NSNumber*)[self cordovaSettings:settings forKey:@"MediaPlaybackRequiresUserAction"]
boolValue];
+    if (prefObj != nil) {
+        scalesPageToFit = [(NSNumber*)prefObj boolValue];
     }
+    theWebView.scalesPageToFit = scalesPageToFit;
 
-    theWebView.scalesPageToFit = [enableViewportScale boolValue];
+    BOOL allowInlineMediaPlayback = NO; // default
+    prefObj = [self cordovaSettings:settings forKey:@"AllowInlineMediaPlayback"];
+    if (prefObj != nil) {
+        allowInlineMediaPlayback = [(NSNumber*)prefObj boolValue];
+    }
+    theWebView.allowsInlineMediaPlayback = allowInlineMediaPlayback;
 
-    /*
-     * This is for iOS 4.x, where you can allow inline <video> and <audio>, and
also autoplay them
-     */
-    if ([allowInlineMediaPlayback boolValue] && [theWebView respondsToSelector:@selector(allowsInlineMediaPlayback)])
{
-        theWebView.allowsInlineMediaPlayback = YES;
+    BOOL mediaPlaybackRequiresUserAction = YES;  // default
+    prefObj = [self cordovaSettings:settings forKey:@"MediaPlaybackRequiresUserAction"];
+    if (prefObj != nil) {
+        mediaPlaybackRequiresUserAction = [(NSNumber*)prefObj boolValue];
     }
-    if ((mediaPlaybackRequiresUserAction == NO) && [theWebView respondsToSelector:@selector(mediaPlaybackRequiresUserAction)])
{
-        theWebView.mediaPlaybackRequiresUserAction = NO;
+    theWebView.mediaPlaybackRequiresUserAction = mediaPlaybackRequiresUserAction;
+
+    BOOL mediaPlaybackAllowsAirPlay = YES;  // default
+    prefObj = [self cordovaSettings:settings forKey:@"MediaPlaybackAllowsAirPlay"];
+    if (prefObj != nil) {
+        mediaPlaybackAllowsAirPlay = [(NSNumber*)prefObj boolValue];
     }
+    theWebView.mediaPlaybackAllowsAirPlay = mediaPlaybackAllowsAirPlay;
 
     // By default, overscroll bouncing is allowed.
     // UIWebViewBounce has been renamed to DisallowOverscroll, but both are checked.
@@ -263,6 +272,13 @@
         }
         theWebView.configuration.suppressesIncrementalRendering = suppressesIncrementalRendering;
 
+        BOOL mediaPlaybackAllowsAirPlay = YES;  // default
+        prefObj = [self cordovaSettings:settings forKey:@"MediaPlaybackAllowsAirPlay"];
+        if (prefObj != nil) {
+            mediaPlaybackAllowsAirPlay = [(NSNumber*)prefObj boolValue];
+        }
+        theWebView.configuration.mediaPlaybackAllowsAirPlay = mediaPlaybackAllowsAirPlay;
+
         /*
         BOOL javaScriptEnabled = YES;  // default value
         if ([self cordovaSettings:settings forKey:@"JavaScriptEnabled"]) {


Mime
View raw message