Skip to content

Commit

Permalink
fix android autoplay issues (#2 #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
LonelyCpp committed Apr 7, 2020
1 parent d13844b commit f5227d9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/YoutubeIframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, {
useImperativeHandle,
forwardRef,
useState,
Platform,
} from 'react';
import {View, StyleSheet} from 'react-native';
import WebView from 'react-native-webview';
Expand All @@ -18,19 +19,20 @@ const YoutubeIframe = (
width,
videoId,
playList,
playListStartIndex = 0,
play = false,
onChangeState = _event => {},
onReady = _event => {},
onError = _err => {},
onPlaybackQualityChange = _quality => {},
mute = false,
volume = 100,
playbackRate = 1,
onPlaybackRateChange = _playbackRate => {},
initialPlayerParams = {},
webViewStyle,
webViewProps,
playbackRate = 1,
onError = _err => {},
onReady = _event => {},
playListStartIndex = 0,
initialPlayerParams = {},
forceAndroidAutoplay = false,
onChangeState = _event => {},
onPlaybackQualityChange = _quality => {},
onPlaybackRateChange = _playbackRate => {},
},
ref,
) => {
Expand Down Expand Up @@ -170,6 +172,10 @@ const YoutubeIframe = (
mediaPlaybackRequiresUserAction={false}
allowsInlineMediaPlayback
onMessage={onWebMessage}
userAgent={Platform.select({
android:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
})}
{...webViewProps}
/>
</View>
Expand Down

0 comments on commit f5227d9

Please sign in to comment.