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

Equivalent callback for onTimelineChanged with reason TIMELINE_CHANGE_REASON_PREPARED, on versiosn 2.12+ #8833

Closed
jrocharodrigues opened this issue Apr 20, 2021 · 2 comments
Assignees
Labels

Comments

@jrocharodrigues
Copy link

Hi,

On my project, when playing a live stream, i need to make a seek to a specific time of the day, when starting playing a new stream.
To do that, on ExoPlayer 2.11.x i relied the callback for onTimelineChanged with reason TIMELINE_CHANGE_REASON_PREPARED.
When that callback was called, i could get the media duration, and with the offset from the currentTime, calculate the position to pass to the seekTo method (player.duration - System.currentTime - timeOfTheDayToSeekTo).

After version 2.12.0, TIMELINE_CHANGE_REASON_PREPARED was removed, and when the callback is called with reason TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, the player duration still undefined.

I could rely on the callback being called with TIMELINE_CHANGE_REASON_SOURCE_UPDATE, but since that is called multiple times, i need to make extra checks to be sure i only make the seek on the first call after the media is changed, and the timeOfTheDayToSeekTo is set.

My question is:
On versions 2.12.+ is there any equivalent callback to onTimelineChanged, with reason TIMELINE_CHANGE_REASON_PREPARED on 2.11.x (Only called once, before the first the first frame is rendered, and after the media duration is known) ?

Is there any way make a relative seek, like seek to 30000ms before the live edge/default position (something like seekTo(-30000) so i can set the seek position right after calling prepare without knowing the media duration?

Thanks in advance

@marcbaechinger
Copy link
Contributor

marcbaechinger commented Apr 21, 2021

For 2.12. the equivalent is the first call with TIMELINE_CHANGE_REASON_SOURCE_UPDATE like you mention. For non-live sources this commonly is called only once. To answer your question, there is no alternative that is called only once for live streams I'm afraid.

For the second question you may want to use the extended live support we added with 2.13 where you can set the target offset from the live edge. So you could calculate the offset for the time to which you want to seek

MediaItem mediaItem = new MediaItem.Builder()
        .setUri(uri)
        .setLiveTargetOffsetMs(10 * 60_000)
        .build();

You probably want to look into issue #8218 that is about a similar topic for HLS, there is a proposal for adding a new property (not HLS specific) to the live configuration that lets you set the requested live unix start time. I think that would be most precisely what you want. Please drop a comment of interest in that issue if that would be something you'd like to have in a future release.

MediaItem mediaItem = new MediaItem.Builder()
        .setUri(uri)
        .setRequestedLiveUnixStartTimeMs(unixStartTimeMs)
        .build();

@jrocharodrigues
Copy link
Author

jrocharodrigues commented Apr 21, 2021

Hi, thanks for your answer.

For now i'll use you suggestion:
MediaItem mediaItem = new MediaItem.Builder() .setUri(uri) .setLiveTargetOffsetMs(10 * 60_000) .build();

As for the new property setRequestedLiveUnixStartTimeMs tracked on #8218 , i think it's a good idea, i'll drop a comment suggesting it to be implmented also for Dash.

best regards

@google google locked and limited conversation to collaborators Jun 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants