mirror of
https://github.com/androidx/media.git
synced 2025-05-04 06:00:37 +08:00

All events issued from ExoPlayerImpl (i.e. Player.EventListener events) currently try to use the media period data from the playing media period as set in the playback thread queue. This is only correct as long as there no pending masking operations in ExoPlayerImpl. That's why we currently disable this whenever the timeline is empty or a seek is pending. Since adding all the playlist API methods to the player, this is no longer the right choice. Moreover, we don't have a definite API that tells AnalyticsCollector when a playlist API call has been handled (and we don't want to have one). We can fix this by always using the current Player position information as the source of truth (instead of the media period queue). This is definitely more correct and also works while a masking operation is pending. To fill in the additional information from the media period queue, we can look up a matching media period. This may not be the first one in the list if an operation is pending. The new methods are similar to the previous tryResolveWindowIndex method, but: 1. They are always used (i.e. the current Player state is the main source of truth) 2. They also check the correct ad playback state, that was just ignored previously. PiperOrigin-RevId: 290284916