Skip to content

Commit 7b57a0f

Browse files
committed
add fullscreen webview prop handling (#6, #8)
1 parent f5227d9 commit 7b57a0f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/YoutubeIframe.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const YoutubeIframe = (
2929
onReady = _event => {},
3030
playListStartIndex = 0,
3131
initialPlayerParams = {},
32-
forceAndroidAutoplay = false,
32+
forceAndroidAutoplay = true,
3333
onChangeState = _event => {},
3434
onPlaybackQualityChange = _quality => {},
3535
onPlaybackRateChange = _playbackRate => {},
@@ -165,17 +165,21 @@ const YoutubeIframe = (
165165
return (
166166
<View style={{height, width}}>
167167
<WebView
168-
style={[styles.webView, webViewStyle]}
169168
ref={webViewRef}
170169
originWhitelist={['*']}
171-
source={{html: MAIN_SCRIPT(videoId, playList, initialPlayerParams)}}
172-
mediaPlaybackRequiresUserAction={false}
173-
allowsInlineMediaPlayback
174170
onMessage={onWebMessage}
175-
userAgent={Platform.select({
176-
android:
177-
'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',
178-
})}
171+
allowsInlineMediaPlayback
172+
style={[styles.webView, webViewStyle]}
173+
mediaPlaybackRequiresUserAction={false}
174+
allowsFullscreenVideo={!initialPlayerParams?.preventFullScreen}
175+
source={{html: MAIN_SCRIPT(videoId, playList, initialPlayerParams)}}
176+
userAgent={
177+
forceAndroidAutoplay &&
178+
Platform.select({
179+
android:
180+
'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',
181+
})
182+
}
179183
{...webViewProps}
180184
/>
181185
</View>

0 commit comments

Comments
 (0)