-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix): clear video src to prevent old video from continue loading #1360
Conversation
Thanks for fixing it. we had the same issue that the player keeps loading old url. |
@novyQ cheers, now just waiting for someone to merge it, hopefully |
noticed the CI error. is that why the PR is not being merged? |
src/players/FilePlayer.js
Outdated
@@ -38,11 +38,13 @@ export default class FilePlayer extends Component { | |||
this.props.url !== prevProps.url && | |||
!isMediaStream(this.props.url) | |||
) { | |||
this.player.src = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think this is needed? This runs when the url
has changed and the new one is not a MediaStream, we don’t necessarily want to clear the src
here, especially if the new url
is also a file path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cookpete I have tested it without this line and it doesn't really fix the problem (old video still load when I change the URL)
I don't see any downside of clearing src
here, as it'll be set again in the next render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any downside of clearing src here, as it'll be set again in the next render.
Will it? This is in componentDidUpdate
which fires after everything has finished rendering. When does the "next render" happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cookpete Oh you're right. Sorry, I was blind and somehow thought it is componentWillUpdate
... Now, I don't even know why it's still working when I have this.
I undo this change, and looks like reseting the src inside componentWillUnmount
is enough in my case (as I actually unmount the videoPlayer)
Thanks for looking into this!
Published in |
Fix #1359
Inspired by prior-art from videogular:
https://github.com/videogular/videogular/blob/master/app/scripts/com/2fdevs/videogular/controllers/vg-controller.js#L698