-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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 beforesourcechange and sourcechange events #3329
Conversation
These are non-standard events, but I'd like to open discussion on adding them. They have a lot of practical application as we've seen at Brightcove and other companies where core contributors work. This may be ultimately more appropriate in a plugin, but modifying the `Player` prototype seems out of the scope of plugins to me.
You forgot to mention #2382 |
@@ -1903,6 +1903,13 @@ class Player extends Component { | |||
// the tech loop to check for a compatible technology | |||
this.sourceList_([source]); | |||
} else { | |||
let previous = this.currentSrc(); | |||
|
|||
this.trigger('beforesourcechange', { |
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 was going to ask if this should be triggered on line 1888 (and I do think that it probably should) but given how recursive src
is, we probably don't want to move this up.
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.
My thought was that we'd only call it when we are changing to a playable source because that's what people will care about in most cases, I think.
@nickygerritsen would love to get your input on this given you opened #2382. |
Also, I'd love to get some @videojs/core-committers thoughts on the notion of firing non-standard events like this. And whether we should namespace them to make it crystal clear they're not standard. |
Oh, cool, totally forgot that you can pass a dataobject as a second param to trigger. |
Would you mind elaborating on some use-cases? I think it would be easier to evaluate if we were talking about specific examples where the native events aren't sufficient. |
Don't forget about #1194! Some good discussion between @dmlap and I around this. I'd be interested to know specifically how If they turn out to be not different enough, we could also consider just adding a |
The problem with Our existing analytics code attempted to shoehorn it and ended up with bugs and unintelligible event spaghetti. Different browsers behave differently - for example, in IE on Windows 7, player.src(...);
player.play(); These issues mean we cannot reliably detect when a new video has started without doing something like polling I would be agreeable to the idea of making it |
Maybe for videojs-playlist, we should have Also, related to #1194, @incompl was thinking that maybe it's time for videojs to make it's own set of events (based on the native events but maybe with different names) that have some guarantees. Like, a version of |
I'm obviously a vote in favor of something like that since that's basically what I'm proposing here. 😄 And when considering it, also consider the idea of namespacing non-native/standard events. Could be something like |
@misteroneill are the browser behaviors you're seeing not compliant with the standard? If that's the case, I think it's reasonable to normalize their behavior in video.js (and maybe that gets rid of the need for new events). |
As we discussed in person, the standard doesn't seem to give us any recommendation about ordering of events like I've been spending the morning observing behaviors in Chrome with different combinations of HTML5, thankfully, is fairly consistent. It follows the Flash is less consistent. In fact, with
Also, I want to be clear that I don't want to merge this just to solve some problems we're having that, in some cases, are caused by external projects (SWF, playlists, etc). I'm open to all sorts of ideas - like moving it into a separate project that modifies video.js with experimental features or something similar. |
Thought I'd note the logic we're now using internally to detect source changes: on Maybe this will help someone else struggling with similar issues. |
Closing again for now. We have https://github.com/brightcove/videojs-per-source-behaviors and we will potentially do some more work around this soon. |
Description
This adds two new events which are triggered by the
Player#src()
method."beforesourcechange"
fires before a playable source is set on the player."sourcechange"
fires after the playable source has been set on the player (including after any tech-readiness and autoplay/preload behavior is triggered).These are non-standard events, but I'd like to open discussion on adding them. They have a lot of practical application as we've seen at Brightcove and other companies where core contributors work. This may be ultimately more appropriate in a separate project - in order to keep the core more pure, but modifying the
Player
prototype seems out of the scope of plugins to me. An alternative might be coming up with some kind of flag that notes an event as non-standard.Discuss!
Requirements Checklist