File tree Expand file tree Collapse file tree 2 files changed +19
-17
lines changed
Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import React, {
88} from 'react' ;
99import { View , StyleSheet , Platform } from 'react-native' ;
1010import WebView from 'react-native-webview' ;
11- import { PLAYER_STATES , PLAYER_ERROR } from './constants' ;
11+ import { PLAYER_STATES , PLAYER_ERROR , CUSTOM_USER_AGENT } from './constants' ;
1212import { EventEmitter } from 'events' ;
1313import { MAIN_SCRIPT , PLAYER_FUNCTIONS } from './PlayerScripts' ;
1414
@@ -173,12 +173,11 @@ const YoutubeIframe = (
173173 allowsFullscreenVideo = { ! initialPlayerParams ?. preventFullScreen }
174174 source = { { html : MAIN_SCRIPT ( videoId , playList , initialPlayerParams ) } }
175175 userAgent = {
176- forceAndroidAutoplay &&
177- Platform . select ( {
178- android :
179- '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' ,
180- } )
176+ forceAndroidAutoplay && Platform . select ( { android : CUSTOM_USER_AGENT } )
181177 }
178+ onShouldStartLoadWithRequest = { request => {
179+ return request . mainDocumentURL === 'about:blank' ;
180+ } }
182181 { ...webViewProps }
183182 />
184183 </ View >
Original file line number Diff line number Diff line change 11export const PLAYER_STATES = {
2- "-1" : " unstarted" ,
3- "0" : " ended" ,
4- "1" : " playing" ,
5- "2" : " paused" ,
6- "3" : " buffering" ,
7- "5" : " video cued"
2+ '-1' : ' unstarted' ,
3+ '0' : ' ended' ,
4+ '1' : ' playing' ,
5+ '2' : ' paused' ,
6+ '3' : ' buffering' ,
7+ '5' : ' video cued' ,
88} ;
99
1010export const PLAYER_ERROR = {
11- "2" : " invalid_parameter" ,
12- "5" : " HTML5_error" ,
13- " 100" : " video_not_found" ,
14- " 101" : " embed_not_allowed" ,
15- " 150" : " embed_not_allowed"
11+ '2' : ' invalid_parameter' ,
12+ '5' : ' HTML5_error' ,
13+ ' 100' : ' video_not_found' ,
14+ ' 101' : ' embed_not_allowed' ,
15+ ' 150' : ' embed_not_allowed' ,
1616} ;
17+
18+ export const CUSTOM_USER_AGENT =
19+ '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' ;
You can’t perform that action at this time.
0 commit comments