Skip to content

Commit

Permalink
remove unused saveInstanceState and add check to timeline change
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Oct 23, 2024
1 parent 81b32dd commit b44acdd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.media3.common.C
import androidx.media3.common.MediaItem
import androidx.media3.common.PlaybackException
import androidx.media3.common.Player
import androidx.media3.common.Player.TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED
import androidx.media3.common.Timeline
import androidx.media3.common.Tracks
import androidx.media3.common.util.UnstableApi
Expand Down Expand Up @@ -202,9 +203,11 @@ class NewPlayerImpl(

override fun onTimelineChanged(timeline: Timeline, reason: Int) {
// TODO shouldn't you check that reason == TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED
mutablePlaylist.update {
(0..<newExoPlayer.mediaItemCount).map {
newExoPlayer.getMediaItemAt(it)
if(reason == TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED) {
mutablePlaylist.update {
(0..<newExoPlayer.mediaItemCount).map {
newExoPlayer.getMediaItemAt(it)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ private const val TAG = "VideoPlayerViewModel"
@UnstableApi
@HiltViewModel
class NewPlayerViewModelImpl @Inject constructor(
// TODO this seems unused? If you planned to save things inside here, explain your plans so they
// can be implemented by future contributors
private val savedStateHandle: SavedStateHandle,
application: Application,
) : AndroidViewModel(application), InternalNewPlayerViewModel {

Expand Down

0 comments on commit b44acdd

Please sign in to comment.