web: common: MediaViewer. stop playing invisible video/audio
This commit is contained in:
parent
62fee1ecfe
commit
f8218bf17f
@ -212,7 +212,7 @@ class MediaViewer extends React.Component {
|
||||
]}
|
||||
/>
|
||||
:
|
||||
<StyledVideoViewer url={url} isVideo={isVideo} />
|
||||
<StyledVideoViewer url={url} playing ={this.state.visible} isVideo={isVideo} />
|
||||
)
|
||||
}
|
||||
<div className="mediaViewerToolbox"></div>
|
||||
|
@ -181,7 +181,7 @@ class VideoViewer extends Component {
|
||||
state = {
|
||||
url: this.props.url,
|
||||
pip: false,
|
||||
playing: true,
|
||||
playing: this.props.playing,
|
||||
controls: false,
|
||||
light: false,
|
||||
volume: 0.3,
|
||||
@ -201,14 +201,25 @@ class VideoViewer extends Component {
|
||||
pip: false
|
||||
})
|
||||
}
|
||||
componentDidUpdate(prevProps) {
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
let newUrl = prevState.url;
|
||||
let newPlaying = prevState.playing;
|
||||
if (this.props.url !== prevProps.url || this.props.playing !== prevProps.playing) {
|
||||
if (this.props.url !== prevProps.url) {
|
||||
newUrl = this.props.url
|
||||
}
|
||||
if (this.props.playing !== prevProps.playing) {
|
||||
newPlaying = this.props.playing
|
||||
}
|
||||
this.setState(
|
||||
{
|
||||
url: this.props.url
|
||||
url: newUrl,
|
||||
playing: newPlaying
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
handlePlayPause = () => {
|
||||
this.setState({ playing: !this.state.playing })
|
||||
@ -443,7 +454,8 @@ class VideoViewer extends Component {
|
||||
|
||||
VideoViewer.propTypes = {
|
||||
isVideo: PropTypes.bool,
|
||||
url: PropTypes.string
|
||||
url: PropTypes.string,
|
||||
playing: PropTypes.bool
|
||||
}
|
||||
|
||||
export default VideoViewer;
|
Loading…
Reference in New Issue
Block a user