You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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();
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.
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 reasonTIMELINE_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 reasonTIMELINE_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 thetimeOfTheDayToSeekTo
is set.My question is:
On versions 2.12.+ is there any equivalent callback to
onTimelineChanged
, with reasonTIMELINE_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
The text was updated successfully, but these errors were encountered: