-
Notifications
You must be signed in to change notification settings - Fork 133
[Proposal] Allow seeking through seekTo
before the HTMLMediaElement is ready
#1607
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
base: dev
Are you sure you want to change the base?
Conversation
1a7a15d
to
f477269
Compare
8bb2583
to
6862827
Compare
6862827
to
0988a00
Compare
We have "performance" tests which allow to ensure that we're not having what we could call "performance regressions", such as a higher delay to have a content loaded from a `loadVideo` call. I wanted to run them yesterday for #1607, but they hanged indefinitely. Turns out that our static server script, that we use here just to host and serve our testing scripts returned a promise that was never resolved. _(Note: we don't rely on external test runners nor on test frameworks for our performance tests, we manually detect and launch local chrome + firefox binaries on a local server serving our bundled scripts (themselves importing the RxPlayer), and at runtime those scripts send results to another "result" server when they're done)_ It was never resolved because we never properly handled the case in that script were we wanted to launch an HTTP server but not an HTTPS one for the same resource(s). This is now fixed. Hopeful that performance tests now work correctly, it's been a long time since I last ran them.
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
5e0767c
to
6c6d7c0
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
6c6d7c0
to
9350f96
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
9350f96
to
170500b
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
170500b
to
50a5f66
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
50a5f66
to
4120844
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
7d6d727
to
fa77883
Compare
We have "performance" tests which allow to ensure that we're not having what we could call "performance regressions", such as a higher delay to have a content loaded from a `loadVideo` call. I wanted to run them yesterday for #1607, but they hanged indefinitely. Turns out that our static server script, that we use here just to host and serve our testing scripts returned a promise that was never resolved. _(Note: we don't rely on external test runners nor on test frameworks for our performance tests, we manually detect and launch local chrome + firefox binaries on a local server serving our bundled scripts (themselves importing the RxPlayer), and at runtime those scripts send results to another "result" server when they're done)_ It was never resolved because we never properly handled the case in that script were we wanted to launch an HTTP server but not an HTTPS one for the same resource(s). This is now fixed. Hopeful that performance tests now work correctly, it's been a long time since I last ran them.
We have "performance" tests which allow to ensure that we're not having what we could call "performance regressions", such as a higher delay to have a content loaded from a `loadVideo` call. I wanted to run them yesterday for #1607, but they hanged indefinitely. Turns out that our static server script, that we use here just to host and serve our testing scripts returned a promise that was never resolved. _(Note: we don't rely on external test runners nor on test frameworks for our performance tests, we manually detect and launch local chrome + firefox binaries on a local server serving our bundled scripts (themselves importing the RxPlayer), and at runtime those scripts send results to another "result" server when they're done)_ It was never resolved because we never properly handled the case in that script were we wanted to launch an HTTP server but not an HTTPS one for the same resource(s). This is now fixed. Hopeful that performance tests now work correctly, it's been a long time since I last ran them.
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
fa77883
to
bcdc354
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
00fc806
to
b7216b4
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
b087c76
to
8711b01
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
this._priv_contentInfos.playbackObserver.setCurrentTime(positionWanted, false); | ||
return positionWanted; |
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.
The public documentation does not mention the return value seekTo()
.
Wouldn't it be worth noticing that it returns the "calculated" time to seek to ?
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 know if that's something that would be truly needed by an application, so I'm comfortable letting this that way.
The idea of keeping it that way now is to not potentially-break some legacy code but without having to make it the actual documented API which would force us to maintain that aspect of the code in our v4
.
What do you think?
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.
That makes sense in terms of not locking it into the public API for now.
But I feel like once we get the opportunity to make breaking changes (in v5), we should either make it explicit and document it properly as part of the API, or remove the return entirely if it’s not meant to be used.
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.
For seekTo
in a v5, I don't think returning currentTime
is that useful, so I would probably remove it.
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
8711b01
to
a106239
Compare
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
a106239
to
84742e6
Compare
As #1600 signalled, there's currently no practical way to update the initial position (configured through the `startAt` `loadVideo` option) until `startAt` has actually been applied. More generally, it's not possible to perform a `seekTo` call until the initial seek has been performed on the content (the `seekTo` call will just be ignored). This commit proposes the following code updates to improve on that situation: 1. Tangentially related, we now schedule a JavaScript micro-task right at `ContentTimeBoundariesObserver`'s instantiation so the caller can catch `events` that were previously synchronously sent (I'm thinking here of the warnings for the `MEDIA_TIME_BEFORE_MANIFEST` and the `MEDIA_TIME_AFTER_MANIFEST` codes). Without this, we would wait for the next playback observation, which could happen a whole second later. 2. I noticed that the position indicated through the `startAt` `loadVideo` option was bounded so it's inside the `[minimumPosition, maximumPosition]` range (as obtained from the Manifest). As [stated here](#1600 (comment)) I personally think this is suboptimal. In my opinion, we should let the initial position go outside the range of the Manifest and let the application do its thing based on `MEDIA_TIME_BEFORE_MANIFEST` / `MEDIA_TIME_AFTER_MANIFEST` events. As to not totally change the behavior, I've only done so for dynamic contents (contents for which segments are added or removed, like live and contents that are being downloaded locally). VoD contents continue to have the previous behavior for now. 3. I added a "seek-blocking" mechanism to the `MediaElementPlaybackObserver` and made all seek operations, including the one from `seekTo` go through it. The idea is that when it is blocked (as it is initially), we'll delay any seek operation (by marking it as a "pending seek") and only seek to the last one of those once the `unblockSeeking` method is called (when the RxPlayer considers that the initial seek should be done). I also had to add `getPendingSeekInformation` method, sadly. I feel that we could do without it if we're smarter about things, but I wanted to avoid changing too much code here. I also thought about reworking the initial seek so it is completely handled by the `MediaElementPlaybackObserver` - as it could make everything simpler - but I chose for now to implement that less disruptive "seek-blocking" mechanism for now. Note that technically, we could still have an application directly updating the `HTMLMediaElement.property.currentTime` property, or even a web feature such as picture-in-picture doing that. I ensured that this eventuality did not break anything. Still, there will be a preference for pending seeks performed through the `MediaElementPlaybackObserver` over such "HTML5 seeks" performed during that time (if there is a "pending seek", we will apply it regardless of if an "HTML5 seek" happened since then). I'm now unsure if the `getPosition` or `getCurrentBufferGap` API should now return that planned position. I did nothing for those yet.
This commit builds on #1607 to allow users of the demo to seek in the content even as it is still loading. In real use cases, a final user might rely on e.g. seeking thumbnails to already know where to seek to without having to wait for initial segments to be loaded. This is a functionality we do see with other media players, YouTube also does this for example. To make the seeking bar more visible, I lightly changed its CSS rules. Also, I conditioned the appearance of the "ProgressBar" based on if the minimum and maximum seekable positions are known, as else, seeking in that bar is not going to lead to a precize seek. This makes the content not seekable until the Manifest has been loaded.
84742e6
to
d8c24aa
Compare
? Automated performance checks have passed on commit DetailsPerformance tests 1st run outputNo significative change in performance for tests:
|
As #1600 signalled, there's currently no practical way to update the initial position (configured through the
startAt
loadVideo
option) untilstartAt
has actually been applied.More generally, it's not possible to perform a
seekTo
call until the initial seek has been performed on the content (theseekTo
call will just be ignored).This PR proposes the following code updates to improve on that situation:
Tangentially related, we now schedule a JavaScript micro-task right at
ContentTimeBoundariesObserver
's instantiation so the caller can catch events that were previously synchronously sent (I'm thinking here of the warnings for theMEDIA_TIME_BEFORE_MANIFEST
and theMEDIA_TIME_AFTER_MANIFEST
codes).Without this, we would wait for the next playback observation, which could happen a whole second later.
I noticed that the position indicated through the
startAt
loadVideo
option was bounded so it's inside the[minimumPosition, maximumPosition]
range (as obtained from the Manifest). As stated here I personally think this is suboptimal.In my opinion, we should let the initial position go outside the range of the Manifest and let the application do its thing based on
MEDIA_TIME_BEFORE_MANIFEST
/MEDIA_TIME_AFTER_MANIFEST
events.As to not totally change the behavior, I've only done so for dynamic contents (contents for which segments are added or removed, like live and contents that are being downloaded locally).
VoD contents continue to have the previous behavior for now.
I added a "seek-blocking" mechanism to the
MediaElementPlaybackObserver
and made all seek operations, including the one fromseekTo
go through it.The idea is that when it is blocked (as it is initially), we'll delay any seek operation (by marking it as a "pending seek") and only seek to the last one of those once the
unblockSeeking
method is called (when the RxPlayer considers that the initial seek should be done).I also had to add
getPendingSeekInformation
method, sadly. I feel that we could do without it if we're smarter about things, but I wanted to avoid changing too much code here.I also thought about reworking the initial seek so it is completely handled by the
MediaElementPlaybackObserver
- as it could make everything simpler - but I chose for now to implement that less disruptive "seek-blocking" mechanism.Note that technically, we could still have an application directly updating the
HTMLMediaElement.prototype.currentTime
property, or even a web feature such as picture-in-picture doing that. I ensured that this eventuality did not break anything. Still, there will be a preference for pending seeks performed through theMediaElementPlaybackObserver
over such "HTML5 seeks" performed during that time (if there is a "pending seek", we will apply it regardless of if an "HTML5 seek" happened since then).I'm now unsure if the
getPosition
orgetCurrentBufferGap
API should now return that planned position. I did nothing for those yet.