Skip to content

Commit

Permalink
feat: 实现在安卓上自动全屏播放
Browse files Browse the repository at this point in the history
  • Loading branch information
flyyuan committed Nov 25, 2023
1 parent 3ce7dcd commit 4d6e0fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ export default function App() {

handleLoad = () => {
const INJECTED_JAVASCRIPT = `(function() {
const videoPlayerDiv = document.querySelector('.video-player');
if (videoPlayerDiv) {
videoPlayerDiv.style.width = '100%';
videoPlayerDiv.style.height = '100vh';
videoPlayerDiv.style.position = 'absolute';
videoPlayerDiv.style.top = '0';
videoPlayerDiv.style.left = '0';
videoPlayerDiv.style.zIndex = '9999';
}
var video = document.querySelector('video');
video && video.addEventListener('play', function() {
if (video.requestFullscreen) {
Expand All @@ -34,7 +43,7 @@ export default function App() {
<StatusBar style="auto" />
<WebView
style={styles.fullScreen}
source={{ uri: "https://www.gdtv.cn/tvChannelDetail/44" }}
source={{ uri: "https://m.gdtv.cn/tvChannelDetail/44" }}
mediaPlaybackRequiresUserAction={false}
ref={(ref) => (this.webview = ref)}
onLoad={this.handleLoad}
Expand Down
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "珠江台",
"slug": "autotv",
"version": "1.0.0",
"orientation": "portrait",
"orientation": "landscape",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
Expand Down Expand Up @@ -40,4 +40,4 @@
"url": "https://u.expo.dev/d69fef41-0e8e-477c-ae88-faa0d8ac7b9c"
}
}
}
}

0 comments on commit 4d6e0fd

Please sign in to comment.