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

API to get live stream position as Date, not relative to video timeline #356

Closed
aletorrado opened this issue Apr 25, 2016 · 8 comments
Closed
Assignees
Labels
status: archived Archived and locked; will not be updated type: enhancement New feature or request
Milestone

Comments

@aletorrado
Copy link

Is it possible using Shaka to get the current live playback time, from a live streaming MPD, such as .timeAsUTC() of Dash.js?

Thanks!

@tdrews tdrews added the type: question A question from the community label Apr 25, 2016
@tdrews
Copy link
Contributor

tdrews commented Apr 25, 2016

You can use player.seekRange().end. This will give you the effective live-edge in seconds. However, this value will be a number of seconds less than just now - MPD@availabilityStartTime. Does that work?

@aletorrado
Copy link
Author

aletorrado commented Apr 26, 2016

.seekRange doesn't work for me. I need the time of the current playback position. Btw, seekRange does not seem to be documented.

I could use the current seek value (for example, getting the HTML Video DOM element, and getting .currentTime), but I don't know how to access MPD@availabilityStartTime using Shaka either.

@tdrews
Copy link
Contributor

tdrews commented Apr 26, 2016

If you just need the playhead position then you should use video.currentTime; it will correspond to the position in the live stream.

@aletorrado
Copy link
Author

Nope, I need the real time (UTC) of the playhead, like MPD.availabilityStartTime+video.currentTime. But I have no access to the MPD.

@tdrews
Copy link
Contributor

tdrews commented Apr 26, 2016

Ah, got it. We could add an API for that. You could also try

var timeBehindLiveEdge = player.seekRange().end - video.currentTime;
var streamPosition = (Date.now() / 1000) - timeBehindLiveEdge;

although, since player.seekRange().end is offset a little from the true live-edge, it may not work exactly how you want (seekRange() available from the master branch).

@tdrews tdrews added type: enhancement New feature or request and removed type: question A question from the community labels Apr 26, 2016
@tdrews tdrews changed the title Getting current playback time Add API to get live stream position. Apr 26, 2016
@aletorrado
Copy link
Author

It may work but it won't be precise. I'm thinking about accesing .manifest_ to get the availabilityStartTime, but it would be really nice to have .timeAsUTC() as dash.js have. Why don't you export the manifest?

@aletorrado
Copy link
Author

This works great:

var playHeadDate = new Date(player.manifest_.presentationTimeline.presentationStartTime_*1000 + videoElm.currentTime*1000)

@tdrews
Copy link
Contributor

tdrews commented Apr 26, 2016

Why don't you export the manifest?

Modifications to the manifest by the application could have many unintended consequences.

var playHeadDate = new Date(player.manifest_.presentationTimeline.presentationStartTime_*1000 + videoElm.currentTime*1000)

We could provide an equivalent API for this.

@joeyparrish joeyparrish added this to the v2+ milestone May 2, 2016
@joeyparrish joeyparrish changed the title Add API to get live stream position. API to get live stream position as Date, not relative to video timeline Oct 4, 2016
@joeyparrish joeyparrish modified the milestones: vLater, v2.1.0 Oct 4, 2016
@ismena ismena self-assigned this Oct 5, 2016
@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants