-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Handle the loadstart event at the player level #1194
Comments
The video metadata example that triggered this discussion. |
There is at least one philosophical question which needs to be resolved: is video.js intended as a drop-in replacement for a video element or is it a video element++? If it's a drop-in replacement, I would expect to "see" all the |
That's a good question. In my opinion, working with video.js should "look" just like working with the video element. However whether or not video.js is allowed to abstract away something like mid roll ads, so that the API might be unaware of their loading, I'm not exactly sure. I think that would be a tech-level decision, not player-level. e.g. if we wanted to hide ads playback, we might have an HTML5+ads tech. But otherwise techs should expose everything that's going on.
I think part of the issue here is that ad plugins really shouldn't be talking directly to techs, and creating low-level events that don't originate from the player API. I don't have all the background on why that's needed though. To a good degree we can maintain state at the player and keep it reliably up to date with the underlying tech, but if plugins start bypassing the player to talk to the techs directly, I think that could mess things up. |
There are a number of mobile devices which can't really handle two video elements at once. To work around that, an ad library may re-use the video element that's used for regular playback. Google's client-side ad implementation, IMA, uses this approach. It's a frustrating complexity but I'm not aware of a better solution on those platforms. |
What's the limitation of the player API that makes talking directly to the video element needed? |
IMA is written to talk directly to a video element so the attributes-to-methods (e.g. |
One potential disadvantage of the ads-as-a-tech proposal is composability. With ads handled in a plugin, it's pretty easy to imagine how Flash ads work over HTML video, or how HTML ads could be overlayed on top of the YouTube tech. Techs are mutually exclusive today so I'm not sure how we would achieve those sorts of combinations. We could do some sort of tech-state-preservation mechanism but that sounds pretty involved. |
Ah right, that kind of kills the whole benefit of video.js. Shame on me. So, IMA is an external javascript library that we have no control over, and it expects being handed a video element specifically. For the sake of exhausting every angle...
But otherwise, just handing the live video element to IMA means the player is no longer in control of it. Which isn't too horrible since the player already doesn't really assume it's in control anyway, but the more we track state at the player level the more potential disconnects it could cause. The disconnects would come from:
I haven't seen any specific issues with the latter yet, but I also haven't tried implementing networkState or readyState to any significant degree. |
See #863 for a related issue. |
@dmlap I think you have a better understanding of this loadstart issue then I do. How does the new playlists/ads work affect this one? If we do end up making the player handle loadstart, it'd be good to get it in for 5.0. |
Since we filed this one, we decided that contrib-ads should do its best to abstract away the ad-related parts of playback for everyone that isn't interested in hearing about them. Rather than swallow the events entirely, we're prefixing them with "ad" (e.g. I think this puts us in a good position to trigger events like |
According to the latest version of the standard,
|
👍 |
I think this one needs to wait for Techs 2.0 to complete before it can be started. |
Wrap #1672 into this one. |
So, I think we can close this one for now since we've been living with it as is for now. Also, we recently released the |
jQuery(window).ready(function() {
const playPromise = media.play();
window.onload=function(){ |
The loadstart event is the closest thing to something like a 'srcchange' event defined in the HTML5 spec. It's fired whenever the src is set or the source selection process begins, and is fired even if preload=none.
Currently the player relies on the tech to fire the loadstart event and bubble it up to the player, but this isn't exactly right because, in the scope of the player, that would only happen AFTER the source selection process, when the selected source is handed to the tech. That means if a source isn't selected, the loadstart event won't get fired and we won't know that src change was even attempted.
One place this could have an impact is the error state (the player has an existing error). We should be able to use the loadstart event to clear the error state, and possible other player states (networkState, readyState) if we decide to handle them at the player level.
Another option would be to create a
srcchange
orcontentupdate
event that the player fires whenever src() is used. The downside of this is we would be inventing a new event and detracting from how the html5 video element works, which we try to avoid, and could have unforeseen implications down the road.The most difficult use case to work through so far is the ads use case, and understanding how we need the events to work in the process of switching between content and ad sources behind the scenes.
Also, wrap #1672 into this.
And #2382
IRC CHAT LOG: @dmlap, @heff
The text was updated successfully, but these errors were encountered: