@@ -489,10 +489,7 @@ private void initPlayer(final boolean playOnReady) {
489489 simpleExoPlayer .addTextOutput (binding .subtitleView );
490490
491491 // Setup audio session with onboard equalizer
492- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP ) {
493- trackSelector .setParameters (trackSelector .buildUponParameters ()
494- .setTunnelingAudioSessionId (C .generateAudioSessionIdV21 (context )));
495- }
492+ trackSelector .setParameters (trackSelector .buildUponParameters ().setTunnelingEnabled (true ));
496493 }
497494
498495 private void initListeners () {
@@ -624,10 +621,10 @@ public void handleIntent(@NonNull final Intent intent) {
624621 && newQueue .getItem ().getUrl ().equals (playQueue .getItem ().getUrl ())
625622 && newQueue .getItem ().getRecoveryPosition () != PlayQueueItem .RECOVERY_UNSET ) {
626623 // Player can have state = IDLE when playback is stopped or failed
627- // and we should retry() in this case
624+ // and we should retry in this case
628625 if (simpleExoPlayer .getPlaybackState ()
629626 == com .google .android .exoplayer2 .Player .STATE_IDLE ) {
630- simpleExoPlayer .retry ();
627+ simpleExoPlayer .prepare ();
631628 }
632629 simpleExoPlayer .seekTo (playQueue .getIndex (), newQueue .getItem ().getRecoveryPosition ());
633630 simpleExoPlayer .setPlayWhenReady (playWhenReady );
@@ -638,10 +635,10 @@ public void handleIntent(@NonNull final Intent intent) {
638635 && !playQueue .isDisposed ()) {
639636 // Do not re-init the same PlayQueue. Save time
640637 // Player can have state = IDLE when playback is stopped or failed
641- // and we should retry() in this case
638+ // and we should retry in this case
642639 if (simpleExoPlayer .getPlaybackState ()
643640 == com .google .android .exoplayer2 .Player .STATE_IDLE ) {
644- simpleExoPlayer .retry ();
641+ simpleExoPlayer .prepare ();
645642 }
646643 simpleExoPlayer .setPlayWhenReady (playWhenReady );
647644
@@ -1649,7 +1646,7 @@ public void onStartTrackingTouch(final SeekBar seekBar) {
16491646
16501647 saveWasPlaying ();
16511648 if (isPlaying ()) {
1652- simpleExoPlayer .setPlayWhenReady ( false );
1649+ simpleExoPlayer .pause ( );
16531650 }
16541651
16551652 showControls (0 );
@@ -1665,7 +1662,7 @@ public void onStopTrackingTouch(final SeekBar seekBar) {
16651662
16661663 seekTo (seekBar .getProgress ());
16671664 if (wasPlaying || simpleExoPlayer .getDuration () == seekBar .getProgress ()) {
1668- simpleExoPlayer .setPlayWhenReady ( true );
1665+ simpleExoPlayer .play ( );
16691666 }
16701667
16711668 binding .playbackCurrentTime .setText (getTimeString (seekBar .getProgress ()));
@@ -1908,7 +1905,7 @@ public void onPlayerStateChanged(final boolean playWhenReady, final int playback
19081905 }
19091906
19101907 @ Override // exoplayer listener
1911- public void onLoadingChanged (final boolean isLoading ) {
1908+ public void onIsLoadingChanged (final boolean isLoading ) {
19121909 if (DEBUG ) {
19131910 Log .d (TAG , "ExoPlayer - onLoadingChanged() called with: "
19141911 + "isLoading = [" + isLoading + "]" );
@@ -1952,7 +1949,8 @@ public void onPlaybackUnblock(final MediaSource mediaSource) {
19521949 if (currentState == STATE_BLOCKED ) {
19531950 changeState (STATE_BUFFERING );
19541951 }
1955- simpleExoPlayer .prepare (mediaSource );
1952+ simpleExoPlayer .setMediaSource (mediaSource );
1953+ simpleExoPlayer .prepare ();
19561954 }
19571955
19581956 public void changeState (final int state ) {
@@ -2351,6 +2349,12 @@ public void onPositionDiscontinuity(@DiscontinuityReason final int discontinuity
23512349 break ;
23522350 }
23532351 case DISCONTINUITY_REASON_SEEK :
2352+ if (DEBUG ) {
2353+ Log .d (TAG , "ExoPlayer - onSeekProcessed() called" );
2354+ }
2355+ if (isPrepared ) {
2356+ saveStreamProgressState ();
2357+ }
23542358 case DISCONTINUITY_REASON_SEEK_ADJUSTMENT :
23552359 case DISCONTINUITY_REASON_INTERNAL :
23562360 if (playQueue .getIndex () != newWindowIndex ) {
@@ -2415,10 +2419,8 @@ public void onPlayerError(@NonNull final ExoPlaybackException error) {
24152419 setRecovery ();
24162420 reloadPlayQueueManager ();
24172421 break ;
2418- case ExoPlaybackException .TYPE_OUT_OF_MEMORY :
24192422 case ExoPlaybackException .TYPE_REMOTE :
24202423 case ExoPlaybackException .TYPE_RENDERER :
2421- case ExoPlaybackException .TYPE_TIMEOUT :
24222424 default :
24232425 showUnrecoverableError (error );
24242426 onPlaybackShutdown ();
@@ -2623,16 +2625,6 @@ public void seekToDefault() {
26232625 simpleExoPlayer .seekToDefaultPosition ();
26242626 }
26252627 }
2626-
2627- @ Override // exoplayer override
2628- public void onSeekProcessed () {
2629- if (DEBUG ) {
2630- Log .d (TAG , "ExoPlayer - onSeekProcessed() called" );
2631- }
2632- if (isPrepared ) {
2633- saveStreamProgressState ();
2634- }
2635- }
26362628 //endregion
26372629
26382630
@@ -2660,7 +2652,7 @@ public void play() {
26602652 }
26612653 }
26622654
2663- simpleExoPlayer .setPlayWhenReady ( true );
2655+ simpleExoPlayer .play ( );
26642656 saveStreamProgressState ();
26652657 }
26662658
@@ -2673,7 +2665,7 @@ public void pause() {
26732665 }
26742666
26752667 audioReactor .abandonAudioFocus ();
2676- simpleExoPlayer .setPlayWhenReady ( false );
2668+ simpleExoPlayer .pause ( );
26772669 saveStreamProgressState ();
26782670 }
26792671
0 commit comments