-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add mediaCannotPlay and onTrackPlaybackFailure #356
Conversation
Don't know if we should pass the activeTrackIndex or something to onTrackPlaybackFailure. |
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.
Awesome thank you! Looks great!
I've got a handful of comments - left me know if you have any questions.
@@ -166,6 +153,10 @@ export class PlayerContextProvider extends Component { | |||
this.videoHostOccupiedCallbacks = new Map(); | |||
this.videoHostVacatedCallbacks = new Map(); | |||
|
|||
// bind internal methods | |||
this.setMediaElementSources = this.setMediaElementSources.bind(this); |
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 think setMediaElementSources
doesn't need to be bound, unless I missed something.
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.
setMediaElementSources
method uses this
, wouldn't that require it to be bound?
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.
It's not passed anywhere as a callback so it's bound at call time when we call this.setMediaElementSources(...)
.
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.
Ahh, yes! Just removed it.
if (source.type) { | ||
sourceElement.type = source.type; | ||
} | ||
sourceElement.addEventListener('error', this.onTrackPlaybackFailure); |
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 think we should remove the event listeners on the source elements on component unmount, in case someone is holding onto a reference to the media element.
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.
Wouldn't it be garbage collected as you said in the issue?
Except in old browsers.
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.
However, doesn't hurt to remove them, check out the last commit.
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.
Normally yes, but if someone retained an outside ref to the media element then I want to make sure we don't have callbacks belonging to an unmounted component getting called.
mediaCannotPlay: true | ||
}); | ||
if (this.props.onTrackPlaybackFailure) { | ||
this.props.onTrackPlaybackFailure(event); |
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 think this should be:
this.props.onTrackPlaybackFailure(
this.props.playlist[this.state.activeTrackIndex],
this.state.activeTrackIndex,
event
);
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.
Good, done.
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.
Perfect thanks!
Released in v2.0.0-alpha.23. |
Solves #352.
I documented
mediaCannotPlay
, but not onTrackPlaybackFailure, since the markdown file for playerContextProvider is empty and the Readme options look outdated.