Skip to content

Commit 597b96c

Browse files
authored
Merge pull request #83 from VocaDB/develop
Develop
2 parents 230ee29 + ba06bf5 commit 597b96c

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

android/app/src/main/AndroidManifest.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
1212
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
1313
<uses-permission android:name="android.permission.VIBRATE" />
14-
14+
1515
<uses-sdk
1616
android:minSdkVersion="16"
17-
android:targetSdkVersion="26" />
17+
android:targetSdkVersion="26"
18+
tools:overrideLibrary="com.reactNativeQuickActions" />
1819

1920
<application
2021
android:name=".MainApplication"

src/components/YouTubePlayer/YoutubePlayer.js

+29-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
11
import React from 'react';
2-
import { View, Text, WebView } from 'react-native';
2+
import { View, Text, WebView, AppState } from 'react-native';
33
import PropTypes from 'prop-types';
44

55
const Player = require('./player.html');
66

77
class YoutubePlayer extends React.Component {
8+
9+
state = {
10+
appState: AppState.currentState
11+
}
12+
13+
componentDidMount() {
14+
AppState.addEventListener('change', this._handleAppStateChange);
15+
}
16+
17+
componentWillUnmount() {
18+
AppState.removeEventListener('change', this._handleAppStateChange);
19+
}
20+
21+
_handleAppStateChange = (nextAppState) => {
22+
this.setState({appState: nextAppState});
23+
}
24+
825
render () {
926

1027
return (
1128
<View style={{ height: 260 }}>
12-
<WebView
13-
style={{flex:1}}
14-
javaScriptEnabled={true}
15-
mediaPlaybackRequiresUserAction={false}
16-
allowsInlineMediaPlayback={true}
17-
source={{uri: `https://www.youtube.com/embed/${this.props.pvId}?playsinline=1`}}
18-
/>
29+
30+
{this.state.appState == 'active' &&
31+
<WebView
32+
style={{flex:1}}
33+
javaScriptEnabled={true}
34+
mediaPlaybackRequiresUserAction={true}
35+
allowsInlineMediaPlayback={true}
36+
source={{uri: `https://www.youtube.com/embed/${this.props.pvId}?playsinline=1`}}
37+
/>
38+
}
39+
1940
</View>
2041
)
2142
}

0 commit comments

Comments
 (0)