The react-player is playing video even when `playing={false}`.
See original GitHub issueBe sure to search for your issue before opening a new one.
Current Behavior
The react-player is playing video even when playing={false}
. I’m using antd
modal which is wrapped around my player.
when I close the modal the modal state changes to false. Which is passed in react-player but the player keeps on playing in the background.
Expected Behavior
It should close with modal.
Steps to Reproduce
1.Install antd modal and react-player 2.Make a class component with the below code. ` import React, { Component } from ‘react’ import { Modal } from “antd”; import ReactPlayer from “react-player”;
export class demo extends Component {
constructor(props) {
super(props);
this.state = {
isModalOpen: false,
};
}
ConfirmationModalhandleCancel = () => {
this.setState({ isModalOpen: false });
};
ConfirmationModalPlay = () => {
this.setState({ isModalOpen: true });
};
getVideo = () => {
console.log("Modal state",this.state.isModalOpen)
return (
<ReactPlayer
playing={this.state.isModalOpen}
className="introductionVideoLearningPlanPage"
controls={true}
url="https://www.youtube.com/watch?v=agi4geKb8v8"
/>
);
};
getIntroVideoModal = () => {
return (
<Modal
title={null}
footer={null}
visible={this.state.isModalOpen}
onCancel={this.ConfirmationModalhandleCancel}
width="fit-content"
bodyStyle={{ padding: '0' }}
>
{this.getVideo()}
</Modal>
)
}
render() {
return (
<div>
{this.getIntroVideoModal()}
</div>
)
}
}
export default demo
`
Environment
- Browser: Chrome : 92.0.4515.159 (Official Build) (64-bit)
- Operating system: windows 10
- react-player: 2.6.2, 2.9.0 (tried on both)
Other Information
I have observed that the console.log(“Modal state”,this.state.isModalOpen) is consoling false when the modal closes but the player keeps on playing.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
why is react-player playing video even when playing={false}?
The react -player is playing video even when playing={false}. I'm using antd modal which is wrapped around my player. when I close the...
Read more >isPlaying is false even playing props is true #1485 - GitHub
Current Behavior isPlaying prop of player is false even I have set playing prop is true Expected Behavior isPlaying's value must follow ...
Read more >Building a Video Player with React and Material UI
React player is a package used to create video players that supports various video sources and types. The first thing to do is...
Read more >react-player - npm Package Health Analysis - Snyk
A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion For more ......
Read more >react-native-video - npm
Indicates whether the player should only play the audio track and instead of displaying the video track, show the poster instead. false ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you very much for your answers.
Hi baiziyu-fe hope you’re doing well, The reason why your second demo there isn’t working is because you didn’t set the onPlay behaviour to change the state. Here’s what goes wrong if you don’t do that:
onPlay={()=>setPlaying1(true)}
) to change your state to true then your playing1 state is still false.Here’s the codesandbox Hope this helps!