-
Notifications
You must be signed in to change notification settings - Fork 6k
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
SeekTo throws IndexOutOfRange after adding item to DynamicConcatenatingMediaSource. #3407
Comments
When the player immediately changes to STATE_ENDED, it usually means that your media files can't be loaded or played. Have you checked whether you can play your files with ExoPlayer directly (without using DynamicConcatenatingPlaylist)? Also, please check if you receive an error on Player.EventListener.onPlayerError(). In addition, please note that you only need to call player.prepare(mediaSource) once. It seems like you re-prepare the player in addItemToPlaylist. This is not necessary, just add the new playlist item to the dynamic concatenating media source. |
I tried using *ConcatenatingMediaSource. *That is working fine but I cannot
use that because my playlist is dynamic(I should be able to add & remove
items to the playlist).
Also, I even if I call the *player.prepare *only once, still its not
playing.
Finally, *onPlayerError *is not called.
…On Tue, Oct 31, 2017 at 1:37 PM, tonihei ***@***.***> wrote:
When the player immediately changes to STATE_ENDED, it usually means that
your media files can't be loaded or played. Have you checked whether you
can play your files with ExoPlayer directly (without using
DynamicConcatenatingPlaylist)? Also, please check if you receive an error
on Player.EventListener.onPlayerError().
In addition, please note that you only need to call
player.prepare(mediaSource) once. It seems like you re-prepare the player
in addItemToPlaylist. This is not necessary, just add the new playlist item
to the dynamic concatenating media source.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3407 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABmzaRrBduo_O6LrmVGGnXzmyS6W8tPBks5sxuo8gaJpZM4QLwH6>
.
|
Could you try to remove the seekTo operations? A transition to STATE_ENDED might also be caused by a seek to an invalid position. |
But, if I remove the *seekTo* operation, then how can I play a particular
song in the playlist ?
…On Tue, Oct 31, 2017 at 1:49 PM, tonihei ***@***.***> wrote:
Could you try to remove the seekTo operations? A transition to STATE_ENDED
might also be caused by a seek to an invalid position.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3407 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABmzaW34_kDdC_RW-2A38m6mHblkyA3Pks5sxu0lgaJpZM4QLwH6>
.
|
I'm just trying to find the reason for the problem you have. You're right that you should be able to call seekTo to play a particular song in the playlist. So, does it help to remove the seekTo operations? That is, your content plays without going to STATE_ENDED? |
Seeks needs to happens after STATE_READY and not just after the prepare got caught by this one once :) And you should not call prepare after adding songs to the playlist if the playlist was already prepared. Init should call exoPlayer.prepare(dynamicMediaSource , true,true); to start clean then nothing more is needed. |
Not sure if I understand you correctly - does that mean you solved your problem now? Particularly by not calling prepare again? |
I'm not the OP, I just give possible solutions to the issue from code posted and personal experience since I'm playing with DynamicConcatenatingMediaSource right now. |
Oh, sorry :) Didn't even notice. Thanks for the advice then. One small correction: seeks can happen at any time after calling prepare, there should be no need to wait for STATE_READY. The rest is correct and as already described - prepare should only be called once preferably with the (source, true, true) parameters. Not resetting the state in prepare is usually only used when re-preparing after an error. |
@tonihei don't want to hijack the thread, but in 2.5.4 even with a simple MediaSource, calling prepare then seek then playwhenready does not seek at all. Only working solution, is prepare without playwhenready, wait for STATE_READY then seek then playwhenready(true) |
Actually you both gave valid points.
But, I have to use a delay of 500 millis to play an item that was added to the playlist or else its getting crashed. |
Lets say I am playing a media source at index 1 & then while its being played if I add another item to the But, after adding it to the I hope you got it |
@Tolriq player.seekTo is not supposed to throw. We noticed that there's a bug which may throw under certain circumstances after seeking (#3362). We're currently fixing this. @ourdex86 Judging from your code, it seems that it was the seekTo that was throwing, right? As I said above, seeking to the item you just added should be supported and there should be no need for you to to delay this operation. The question is whether you are having a problem because of the issue we're currently fixing anyway (#3362) or whether your problem is something else and related to the DynamicConcatenatingMediaSource. Could you please post a complete stack trace of your error or attach a bug report for us to investigate this further? Thanks! |
I was able to reproduce your issue myself. It's kind of related to the ongoing refactoring of the seek handling, so it's hopefully going to be fixed soon. |
We will push a fix to the dev branch soon which will allow you to pass in a custom Runnable to any of the DynamicConcatenatingMediaSource methods. These Runnables will be executed immediately after the player was made aware of the change. This removes the need for your workaround and also the timing of 500ms. The resulting code for your example would look like this:
|
@tonihei Just to confirm as 2.6.0 is already branched this means that this will go in for the release after? |
It will be cherry-picked into 2.6.0, I think. |
…ions. These callbacks are executed on the app thread after the corresponding timeline update was triggered. This ensures that seek operations see the updated timelines and are therefore valid, even if the seek is performed into a window which didn't exist before. GitHub:#3407 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=175136187
…ions. These callbacks are executed on the app thread after the corresponding timeline update was triggered. This ensures that seek operations see the updated timelines and are therefore valid, even if the seek is performed into a window which didn't exist before. GitHub:#3407 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=175136187
I am trying to use DynamicConcatenatingMediaSource to create dynamic playlists.
Here is the implementation.
But, the audio is not played. Its immediately invoking
onPlayerStateChanged
with player stateSTATE_ENDED
Exoplayer Version : r2.5.4
Android OS Version : 7.1.2
Device : Pixel XL
The text was updated successfully, but these errors were encountered: