Skip to content
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

Seek after load does not work #1298

Closed
DanDeMicco opened this issue Feb 12, 2018 · 7 comments

Comments

Projects
None yet
4 participants
@DanDeMicco
Copy link

commented Feb 12, 2018

Have you read the FAQ and checked for duplicate open issues?:
Yes
What version of Shaka Player are you using?:
2.1.8

I am currently using shaka player for streaming DASH, and would like to make it so the playback starts at a certain time. From the docs I see player.load supports opt_startTime, however with the version of shaka player I have, if the opt_startTime is a time that is longer than the video, the player throws an error and fails to load. I noticed around 2.2.8, the stream starts at END_TIME - 1 instead of throwing an error.

I was wondering what the best way would be to to detect that the start time is out of bounds, and start at t=0 rather than t=END_TIME - 1? This is an example of what I am currently thinking (involves upgrading of shaka player to 2.2.5 for streaming event support):

const startTime = 60; // some start time in seconds
player.load(manifestUri, startTime);
player.addEventListener('streaming', function() {
    const end = this.seekRange().end;
    if (startTime > end) {
        this.getMediaElement().currentTime = 0.1; // 0 seems to start at end
    }
});

The above seems to work, but I am not sure if there is a better solution. Also, if there is some solution that would involve me not upgrading shaka player that would be great.

@DanDeMicco DanDeMicco changed the title Starting at t=0 if opt_startTime is out of bounds Starting at t=0 if opt_startTime is out of bounds? Feb 12, 2018

@joeyparrish

This comment has been minimized.

Copy link
Member

commented Feb 12, 2018

You could try something like this, which doesn't rely on the streaming event:

const startTime = 60; // some start time in seconds
player.load(manifestUri).then(function() {
    const end = player.seekRange().end;
    if (startTime < end) {
        player.getMediaElement().currentTime = startTime;
    }
});

Does this help?

@joeyparrish joeyparrish self-assigned this Feb 12, 2018

@DanDeMicco

This comment has been minimized.

Copy link
Author

commented Feb 13, 2018

Hey @joeyparrish thanks for the super fast response! That was a good idea but unfortunately it doesn't work in 2.1.8, the start doesn't get set correctly. Assuming I upgrade to the latest version, do you see any problems with my original code or is there a better way?

Edit: apparently the original way I posted is not working, and setting currentTime doesnt seem to be a good approach. Here I am setting the opt_startTime to 500 (invalid), then setting back to 0 in streaming event: https://codepen.io/anon/pen/MQoERE it still goes to END_TIME - 1

@joeyparrish

This comment has been minimized.

Copy link
Member

commented Feb 13, 2018

If you can, upgrading is rarely a bad idea. At the very least, try the most recent bugfix release from the v2.2 branch, v2.2.10. Otherwise, you should try the very latest, which is currently v2.3.2.

It could be that some of these approaches fail because of bugs we've already fixed in newer releases, so I suggest you try an upgrade before we go further. Upgrade guides can be found here: https://shaka-player-demo.appspot.com/docs/api/tutorial-upgrade.html

If upgrading your entire project is going to be too time-consuming for you right now, you could always just try building a very simple demo on top of the latest release using the sample code you posted above. That should be cheap and easy, and will tell you whether your approach makes sense and whether an upgrade will help with this particular issue.

@DanDeMicco

This comment has been minimized.

Copy link
Author

commented Feb 13, 2018

Hey @joeyparrish, definitely will look into upgrading, but even that doesn't work entirely. I linked a codepen above in my edit which has the latest v2.3.2 and a demo example of what I am trying to do.

In my codepen, tried changing player.getMediaElement().currentTime in both the streaming event and player callback, and the playback still starts at t=END_TIME - 1 if opt_startTime is invalid.

I have also tried not setting opt_startTime and just setting player.getMediaElement().currentTime. This starts it at t=0. Here is a codepen for this: https://codepen.io/anon/pen/oEeeVW

@joeyparrish

This comment has been minimized.

Copy link
Member

commented Feb 13, 2018

Seeking during the 'streaming' event doesn't work because we haven't put opt_startTime into effect yet. I would expect that seeking after load() resolves would still work, but it doesn't. Delaying the seek another 100ms after load() resolves works on my workstation, but that is not a good fix.

It is surprising that we override a seek that occurs after load() is resolved, so I'll go ahead and mark this as a bug. I'm not sure exactly what is causing it, though.

@joeyparrish joeyparrish added bug and removed question labels Feb 13, 2018

@joeyparrish joeyparrish removed their assignment Feb 13, 2018

@joeyparrish joeyparrish added this to the v2.4.0 milestone Feb 13, 2018

@joeyparrish joeyparrish changed the title Starting at t=0 if opt_startTime is out of bounds? Seek after load does not work Feb 26, 2018

@shaka-bot shaka-bot closed this in 10e1227 Mar 23, 2018

@michellezhuogg

This comment has been minimized.

Copy link
Contributor

commented Mar 23, 2018

This should work after the fix is commited:

const startTime = 500;
player.load(asset.manifestUri, startTime).then(function() {
    const end = player.seekRange().end;
    if (startTime > end) {
      player.getMediaElement().currentTime = 0.1;
    }
});

joeyparrish added a commit that referenced this issue Mar 29, 2018

Fixing Seek after load
Fixing the seek after load not working issue where our customer wants to
start the video from a certain time when playback.
Deleted earlySeekTimer.

Backported to v2.3.x

Closes #1298.

Change-Id: Ifa293c20c1baf76193948e3b5a7778a2f262222e
@joeyparrish

This comment has been minimized.

Copy link
Member

commented Mar 29, 2018

Fix cherry-picked to v2.3.5.

@shaka-bot shaka-bot added the archived label May 22, 2018

@google google locked and limited conversation to collaborators May 22, 2018

rounce pushed a commit to rounce/shaka-player that referenced this issue Jul 8, 2019

Fixing Seek after load
Fixing the seek after load not working issue where our customer wants to
start the video from a certain time when playback.
Deleted earlySeekTimer.

Closes google#1298.

Change-Id: Ifa293c20c1baf76193948e3b5a7778a2f262222e
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.