ExoPlayer
ExoPlayer copied to clipboard
Support pausing at a frame-accurate position
Hello, I have a question to consult My English is not very good, please forgive me
I will be more MediaSource add ConcatenatingMediaSource , I want to listen CurrentWindowIndex to finish playing
@Override
public void onLoadingChanged(boolean isLoading) {
int curTime = (int) (player.getCurrentPosition() );
int time = (int) (player.getBufferedPosition() );
System.out.println("播放: onLoadingChanged " + curTime + "--->" + time);
if (time != 0 && curTime == time) {
player.setPlayWhenReady(false);
}
}
}
I can't do it that way
You can listen to onPositionDiscontinuity and check if player.getCurrentWindowIndex changed in there.
@tonihei Thank you for your reply I want to listen for each end, not the second beginning
player.getCurrentWindowIndex
When changing the source has become the next
There is only one single moment in which playback changes from window index to the next. If you'd like to know the previous index, you could just save the current index to a variable and check if it changed in the onPositionDiscontinuity callback.
If you want to do something at a specific playback position, you can also try to send a message at a certain time like so: player.createMessage((type, payload) -> doSomething()).setPosition(12345).setHandler(new Handler()).send();
@tonihei Send is an imprecise I want it to be when the current index play is done
player.setPlayWhenReady(false);
It's going to stop after the last frame of index not the first frame of next index
The message is imprecise because it's send on another thread.
I'll mark this as an enhancement to support sending precise messages which may block the playback thread while the message is handled. We do something like that in our testutils here if you want to give it a go.
An alternative is to NOT add MediaSources behind the current one to the ConcatenatingMediaSource and wait until the state changes to STATE_ENDED. After this happens you can add new sources and seek to the next item.
Thank you very much
for trying to prepare one MediaSource per time in PlaybackState.STATE_ENDED:
Reprepare MediaSource but there is currently a problem that there will be a lag between two prepare periods and I wonder if I can add a transition effect to add a better experience
Sending precise messages is most likely not feasible, because the main reason to do that is to pause at a specific frame-accurate timestamp. As we don't control the last few milliseconds before releasing the frame to the surface, this behavior needs to be implemented by actually holding back samples in the renderer.
This can still be implemented, e.g. by using renderer messages sent at an earlier time, but not as a PlayerMessage triggered at the intended position, because by the time the message is triggered, it's already too late.
I'll mark the issue as "low priority" because it's more complicated than anticipated. And also rename to only solve the pausing feature.
@tonihei
Thank you very much
I'm currently using what you called PlaybackState.STATE_ENDED To solve this problem
However, when the two MediaSource switch, can't make a better transition? Can we add a transition animation to make a better connection
Pausing at a frame-accurate position is a subset of setting the playback speed from a frame-accurate position (pausing := speed=0.0). Or at least both share a similar set-up.
@Samrobbo, assigning to you as you may look into the playback speed setting issue anyway.
There is now a public design doc for this feature at https://exoplayer.dev/design-documents.html (direct doc link)
We now support pausing at the end of media items (that is, at the last frame) using exoplayer.setPauseAtEndOfMediaItem.
I'll leave this issue open for the more general feature to pause at arbitrary exact frame positions. As most requests have been for last frame pausing, I'll mark this enhancement as low priority for now.
Hi, This is still not published to release-v2 version but has been dev for 6 months. Any particular reason?
It will be released very soon, in 2.12.
The work to enable pausing at the end of media items was released in 2.12. This issue remains open to track the more general feature to pause at arbitrary exact frame positions, as per https://github.com/google/ExoPlayer/issues/5660#issuecomment-619067418.
Is there any update? @ojw28 @tonihei
Hi,
Is this planned to be implemented?
There is a design doc from 2020-01-15 by @tonihei , and I found a few other issues that were closed because of similarity\duplicate with this.
Just saying, there is a demand for this feature