setAudioMuted method

  1. @SupportedPlatforms(platforms: [AndroidPlatform(apiName: 'WebViewCompat.setAudioMuted', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#setAudioMuted(android.webkit.WebView,boolean)', note: 'Available only if [WebViewFeature.MUTE_AUDIO] is supported.'), IOSPlatform(apiName: 'WKWebView.setAllMediaPlaybackSuspended', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended', available: '15.0'), MacOSPlatform(apiName: 'WKWebView.setAllMediaPlaybackSuspended', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended', available: '12.0')])
Future<void> setAudioMuted({
  1. required bool muted,
})

Mutes or unmutes audio playback in this WebView.

On Android this maps to WebViewCompat.setAudioMuted when WebViewFeature.MUTE_AUDIO is supported. On iOS and macOS it maps to setAllMediaPlaybackSuspended.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • muted: all platforms

Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(
      apiName: 'WebViewCompat.setAudioMuted',
      apiUrl:
          'https://developer.android.com/reference/androidx/webkit/WebViewCompat#setAudioMuted(android.webkit.WebView,boolean)',
      note:
          'Available only if [WebViewFeature.MUTE_AUDIO] is supported.',
    ),
    IOSPlatform(
      apiName: 'WKWebView.setAllMediaPlaybackSuspended',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended',
      available: '15.0',
    ),
    MacOSPlatform(
      apiName: 'WKWebView.setAllMediaPlaybackSuspended',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended',
      available: '12.0',
    ),
  ],
)
Future<void> setAudioMuted({required bool muted}) {
  throw UnimplementedError(
    '${PlatformInAppWebViewControllerMethod.setAudioMuted.name} is not implemented on the current platform',
  );
}