Open jeffzing opened 7 years ago
let jscodeTest = 'document.addEventListener("DOMContentLoaded", init, false);' + 'function init() {'+ 'document._video = document.getElementsByTagName("video")[0];' + 'document._video.play();}'
<WebView source={{uri:'https://v.qq.com/iframe/player.html?vid=v0561w7vjli&tiny=0&auto=0',method: 'GET'}} javaScriptEnabled={true} ref="myWebView" injectedJavaScript={jscodeTest} domStorageEnabled={true} allowsInlineMediaPlayback={true} mediaPlaybackRequiresUserAction={false} scalesPageToFit={false} style={styles.backgroundVideo}/>
document.addEventListener("DOMContentLoaded" not working at here.
remove document.addEventListener("DOMContentLoaded"
, then it will be ok. you can try it.
great ,thanks
发自我的iPhone
在 2022年1月13日,下午2:13,zhangwenshun @.***> 写道:
document.addEventListener("DOMContentLoaded" not working at here. remove document.addEventListener("DOMContentLoaded", then it will be ok. you can try it.
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.
I want to autoplay webview "video",but the video still can not autoplay, anything wrong with my code?
let jscodeTest = 'document.addEventListener("DOMContentLoaded", init, false);' + 'function init() {'+ 'document._video = document.getElementsByTagName("video")[0];' + 'document._video.play();}';
<WebView source={{uri:'https://v.qq.com/iframe/player.html?vid=v0561w7vjli&tiny=0&auto=0',method: 'GET'}} javaScriptEnabled={true} ref="myWebView" injectedJavaScript={jscodeTest} domStorageEnabled={true} allowsInlineMediaPlayback={true} mediaPlaybackRequiresUserAction={false} scalesPageToFit={false} style={styles.backgroundVideo}/>