-
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
How to correctly remove PlayerMessage? #7278
Comments
I investigated a problem a little bit more and I can say that I have a different problem. I'm getting a crash every time I'm doing following flow:
Here is the crash report I'm getting (I had 4
It's even more interesting, because |
Yes, definitely! That's what it was designed for.
Not sure if it is intentional, but this setup delivers the messages on the playback thread. If you rather like them to be delivered on another thread (e.g. the main thread), please use
Can you provide code snippets for each step and additional notes if other thread etc are involved? Some steps are a bit ambiguous based on this description. Thanks! |
@tonihei thank you for your answer. I decided to create a simple project that demonstrates a problem:
report. To make it more clear - items on the list with "Ad included" are a media items that have I did more investigation and when I have several items with "ads" (PlayerMessages in fact) on the playlist, the whole problem occurs only for the last item with "ads". So let's say I have 5 items on the playlist with Let me know if this description and project is clear. Thank you in advance! |
Thanks a lot for the reproduction steps and the project. I can reproduce the problem and will provide a fix. |
Thank you. |
We keep an index hint for the next pending player message. This hint wasn't updated correctly when messages are removed due to a timeline update. This change makes sure to only use the hint locally in one method so that it doesn't need to be updated anywhere else and also adds the "hint" suffix to the variable name to make it clearer that it's just a hint and there are no guarantees this index actually exists anymore. issue:#7278 PiperOrigin-RevId: 309217614
We keep an index hint for the next pending player message. This hint wasn't updated correctly when messages are removed due to a timeline update. This change makes sure to only use the hint locally in one method so that it doesn't need to be updated anywhere else and also adds the "hint" suffix to the variable name to make it clearer that it's just a hint and there are no guarantees this index actually exists anymore. issue:#7278 PiperOrigin-RevId: 309217614
We keep an index hint for the next pending player message. This hint wasn't updated correctly when messages are removed due to a timeline update. This change makes sure to only use the hint locally in one method so that it doesn't need to be updated anywhere else and also adds the "hint" suffix to the variable name to make it clearer that it's just a hint and there are no guarantees this index actually exists anymore. issue:#7278 PiperOrigin-RevId: 309217614
Searched documentation and description of the problem
I'm developing an app where I let user listen to some audio content. My content is built with
ConcatenatingMediaSource
and provided to the user as a playlist. There are advertisements baked into my content, HLS files. In the response from the API I have information when exactly the ad begins, when user reached middle of the ad and the end of the ad. I would like to be able to send send a data to the API in those points in timeline. I have checked all of the possible options in library likeAdsMediaSource
,ClippingMediaSource
and nothing matches my requirement as well asPlayerMessage
. It lets me set a "points" in my media files and be notified when user reached one.I'm using following methods to set a time when message should be sent:
From what I observed,
PlayerMessage
is assigned towindowIndex
(media on my playlist) and it's great, because when I for example add message to 4thwindowIndex
then remove 3rd item and I'm starting playing next one (the on that have message assigned), the message is delivered.User can remove items in playlist and add them again. So ideally it would be to react on
Timeline
change and remove all of the messages and add it again, to make 100% sure that those are added in correct points of timeline.My problem is that when I'm trying
cancel
a current messages:and then I'm adding them again in current positions, I'm getting following error:
The error is not exactly related to what I'm doing, but is always happening when I'm deleting a
MediaSource
from the playlist that hadPlayerMessage
and I'm adding it again and trying to add itsPlayerMessage
sFrom what I can see in the crash report it says "IndexOutOfBoundsException: Index: 14, Size: 1", so it seems like the messages were removed from the list, but it somehow tries to iterate through them with higher index than the number of the items currently on the list.
Question
My question is: is it correct use case of the
PlayerMessage
? Maybe there is a better tool for this use case? Ideally it would be if I could add the "points" toMediaSource
directly and be notified when user reached one, but I didn't find a way to do that.It I'm not abusing
PlayerMessage
, then why I'm getting an error when trying to add them more?The text was updated successfully, but these errors were encountered: