Skip to content

Commit

Permalink
add mediaPlaybackRequiresUserGesture parameter (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincaicedo authored and charafau committed Dec 11, 2019
1 parent 5e406a9 commit 29c0480
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void openUrl(MethodCall call, MethodChannel.Result result) {
boolean withJavascript = call.argument("withJavascript");
boolean clearCache = call.argument("clearCache");
boolean clearCookies = call.argument("clearCookies");
boolean mediaPlaybackRequiresUserGesture = call.argument("mediaPlaybackRequiresUserGesture");
boolean withZoom = call.argument("withZoom");
boolean displayZoomControls = call.argument("displayZoomControls");
boolean withLocalStorage = call.argument("withLocalStorage");
Expand Down Expand Up @@ -145,6 +146,7 @@ void openUrl(MethodCall call, MethodChannel.Result result) {
clearCache,
hidden,
clearCookies,
mediaPlaybackRequiresUserGesture,
userAgent,
url,
headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ void openUrl(
boolean clearCache,
boolean hidden,
boolean clearCookies,
boolean mediaPlaybackRequiresUserGesture,
String userAgent,
String url,
Map<String, String> headers,
Expand Down Expand Up @@ -398,6 +399,10 @@ void openUrl(

webView.getSettings().setUseWideViewPort(useWideViewPort);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
webView.getSettings().setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
}

// Handle debugging
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.setWebContentsDebuggingEnabled(debuggingEnabled);
Expand Down
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class MyApp extends StatelessWidget {
return WebviewScaffold(
url: selectedUrl,
javascriptChannels: jsChannels,
mediaPlaybackRequiresUserGesture: false,
appBar: AppBar(
title: const Text('Widget WebView'),
),
Expand Down
2 changes: 2 additions & 0 deletions lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class FlutterWebviewPlugin {
bool withJavascript,
bool clearCache,
bool clearCookies,
bool mediaPlaybackRequiresUserGesture,
bool hidden,
bool enableAppScheme,
Rect rect,
Expand All @@ -174,6 +175,7 @@ class FlutterWebviewPlugin {
'clearCache': clearCache ?? false,
'hidden': hidden ?? false,
'clearCookies': clearCookies ?? false,
'mediaPlaybackRequiresUserGesture': mediaPlaybackRequiresUserGesture ?? true,
'enableAppScheme': enableAppScheme ?? true,
'userAgent': userAgent,
'withZoom': withZoom ?? false,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/webview_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class WebviewScaffold extends StatefulWidget {
this.withJavascript,
this.clearCache,
this.clearCookies,
this.mediaPlaybackRequiresUserGesture = true,
this.enableAppScheme,
this.userAgent,
this.primary = true,
Expand Down Expand Up @@ -49,6 +50,7 @@ class WebviewScaffold extends StatefulWidget {
final bool withJavascript;
final bool clearCache;
final bool clearCookies;
final bool mediaPlaybackRequiresUserGesture;
final bool enableAppScheme;
final String userAgent;
final bool primary;
Expand Down Expand Up @@ -158,6 +160,7 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
withJavascript: widget.withJavascript,
clearCache: widget.clearCache,
clearCookies: widget.clearCookies,
mediaPlaybackRequiresUserGesture: widget.mediaPlaybackRequiresUserGesture,
hidden: widget.hidden,
enableAppScheme: widget.enableAppScheme,
userAgent: widget.userAgent,
Expand Down

0 comments on commit 29c0480

Please sign in to comment.