[FIX] Stop video when modal is closed (#1787)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
39d9a00933
commit
fac0958b8b
|
@ -65,8 +65,22 @@ class AttachmentView extends React.Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
navigation.setParams({ handleSave: this.handleSave });
|
navigation.setParams({ handleSave: this.handleSave });
|
||||||
|
|
||||||
|
this.willBlurListener = navigation.addListener('willBlur', () => {
|
||||||
|
if (this.videoRef && this.videoRef.stopAsync) {
|
||||||
|
this.videoRef.stopAsync();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (this.willBlurListener && this.willBlurListener.remove) {
|
||||||
|
this.willBlurListener.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getVideoRef = ref => this.videoRef = ref;
|
||||||
|
|
||||||
handleSave = async() => {
|
handleSave = async() => {
|
||||||
const { attachment } = this.state;
|
const { attachment } = this.state;
|
||||||
const { user, baseUrl } = this.props;
|
const { user, baseUrl } = this.props;
|
||||||
|
@ -117,6 +131,7 @@ class AttachmentView extends React.Component {
|
||||||
useNativeControls
|
useNativeControls
|
||||||
onLoad={() => this.setState({ loading: false })}
|
onLoad={() => this.setState({ loading: false })}
|
||||||
onError={console.log}
|
onError={console.log}
|
||||||
|
ref={this.getVideoRef}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue