Skip to content

Commit

Permalink
修复Android端退出之后,再次进来画面不动的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lzj committed Apr 15, 2020
1 parent f072220 commit 2c66c18
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
15 changes: 6 additions & 9 deletions android/src/main/java/com/jimi/rn/rtmp/JMRTMPPlayerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,17 @@ public JMRTMPPlayerManager(ReactApplicationContext reactContext) {
private final LifecycleEventListener mLifecycleEventListener = new LifecycleEventListener() {
@Override
public void onHostResume() {
JMRTMPMonitorManager.isResume = true;
if (glMonitor != null) {
glMonitor.onResume();
}
JMRTMPMonitorManager.setIsResume(true);
}

@Override
public void onHostPause() {
JMRTMPMonitorManager.isResume = false;
if (glMonitor != null) {
glMonitor.onPause();
}
JMRTMPMonitorManager.setIsResume(false);
}

@Override
public void onHostDestroy() {
JMRTMPMonitorManager.isResume = false;
JMRTMPMonitorManager.setIsResume(false);
if (mContext != null && mBroadcastReceiver != null) {
mContext.unregisterReceiver(mBroadcastReceiver);
mBroadcastReceiver = null;
Expand Down Expand Up @@ -138,13 +132,15 @@ public void deInitialize() {
public void startPlayLive() {
if (gJMVideoStreamPlayer != null) {
gJMVideoStreamPlayer.startPlayLive();
JMRTMPMonitorManager.setIsResume(true);
}
}

@ReactMethod
public void startPlay(String url) {
if (gJMVideoStreamPlayer != null) {
gJMVideoStreamPlayer.startPlay(url);
JMRTMPMonitorManager.setIsResume(true);
}
}

Expand All @@ -159,6 +155,7 @@ public void startPlayback(ReadableArray fileNameArray) {
}

gJMVideoStreamPlayer.startPlayback(list);
JMRTMPMonitorManager.setIsResume(true);
}
}

Expand Down
10 changes: 10 additions & 0 deletions example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ export default class App extends Component<Props> {
<TouchableOpacity style={styles.btn} onPress={() => { this.clickedSwitchCamera() }}>
<Text style={styles.baseStyle}>切换摄像头</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.btn} onPress={() => { this.clickedStopAll() }}>
<Text style={styles.baseStyle}>Stop</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.btn} onPress={() => { this.clickedReStart() }}>
<Text style={styles.baseStyle}>ReStart</Text>
</TouchableOpacity>
</View>
</View>
);
Expand Down Expand Up @@ -183,6 +189,10 @@ export default class App extends Component<Props> {
JMRTMPPlayerManager.setMute(this.state.mute);
});
}

clickedReStart() {
JMRTMPPlayerManager.reStart();
}
}

const styles = StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react": "16.6.3",
"react-native": "0.58.6",
"react-native-fs": "2.13.3",
"react-native-rtmp-player-jm": "^1.1.6"
"react-native-rtmp-player-jm": "^1.1.8"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
Expand Down

0 comments on commit 2c66c18

Please sign in to comment.