-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
A means to save state during detach/attach cycle for ads #2039
Comments
I see that if I call detach at a certain point in time, I can then call attach again when I want to, but the loaded media is unloaded when I call detach, so I need to call load again, and possibly add the time I detached the video element so Shaka will resume from last position. |
Honestly, I think letting a third party ad SDK wipe the source buffer is not a good idea to begin with (as it does not call Would you mind sharing what ad SDK you're implementing? I've worked with both FreeWheel and Google IMA, both can be configured not to use a video element playing content. |
The intent is that you can call attach after detach, yes. Detach removes all association to the video element, including MediaSource/SourceBuffer and your current playback position. So after attaching, you need to call load() again if you want to resume where you left off. The meaning of detach is not "temporarily let somebody else have the video element". Nothing like that exists today. Current options are either to call attach() and load() again, or to have the ads SDK use a separate video element that hides the main video. |
Thanks for the prompt replies @matvp91 and @joeyparrish . |
Before attach/detach, Player instances required a video element passed into the constructor. There was a feature request (IIRC) to make this optional and allow the Player to exist without a video element. So attach/detach were added as way to enable that. Now the Player can be constructed without a video element, and the video element can be attached later, before load() is called. Detach was added to mirror that. The FR & discussion was in #1087. Attach/detach also fits nicely into our future plans for preload(), in which you'll be able to start preloading content from several sources before attaching to a video element and completing the pipeline. This will allow applications to achieve both lower-latency startup and speculative preloading of media. I can see the advantage of saving state for reattaching after an ad, though. In particular when you mentioned selected tracks. It's easy enough to re-attach() and re-load() at the same point in time, but more burdensome to select the same languages/tracks if the user has changed them. I can't promise a particular timeline at the moment, but if this would be a useful feature (a way to save state somehow during detach/attach cycle), we can make this issue into a feature request. |
It would be very useful so yes, please consider this as a feature request. A question about how performant this approach is - if calling detach unloads the media then (with and without the discussed optimizations) calling attach again re-inits the media, it still means it will be loaded from network again, right? And if it’s right then I assume we still have fallback behavior that network calls will be loaded from browser cache(unless they have explicit expiration duration which is very short), right? |
Yes, that's right.
Correct. |
Thanks @joeyparrish! |
We had the same issue for both Tizen and LG in order to implement Freewheel ads. For Tizen, we used their AvPlayer element to play ads and at the same time, we detach the video element from DOM by using the removeChild method of DOM element. Then, reattach the video element again to DOM when ad playback is finished. As for LG, it is similar. To play ads, we were using their video element with some options that are specific to video element in LG. Plus, hiding the element during the switch was enough instead of detaching the video element. |
@OrenMe |
Sure @ismena |
Yay! So... If you have sample content you're able to share (privately) that would be awesome, but the discussion is valuable to us either way. Thanks! |
We don’t have clients doing client side dynamic ad insertion so we don’t have a use case for manifest signaling, but we definitely get this asked from time to time. Unfortunately I don’t have any examples to share at the moment, but there’s a nice selection of test tags in google IMA vast inspector website. I’ll add four more points to consider:
Hope this helps. |
Very helpful, @OrenMe thanks for the info! |
@OrenMe another question (I feel a bit stupid asking this, but I want to make sure): Thanks again for your help, I'm almost dome with the initial integration design :) |
Hi @ismena, sorry, I missed your last question. |
I'm going to fold this into #2792. |
Duplicate of #2792 |
Can I attach a video element, load a media, pause playback, detach video element(to be used by other libraries), call attach again and resume playback?
And all of the above is required with keeping the state and buffer of Shaka while it is detached from the video element.
Popular use case is platforms that supports only single video tag and it needs to be shared with playback of main content(by Shaka for example) and by third party ads SDK that wants to play midrolls.
Sometimes these 3rd party ad sdks are VERY opinionated and don't allow controlling the selection of video element, so you can't even tell them to use another video tag.
When such am SDK wants to play the ad it will snatch the video tag and kill the media source binding to the video element.
The text was updated successfully, but these errors were encountered: