Skip to content

Commit

Permalink
bug fix: uncaught exception when CastSession ends in "CAST_ONLY" mode
Browse files Browse the repository at this point in the history
---------------------------------------------------------------------

issue:
  * uncaught exception leads to crash

steps to reproduce:
  * pause "VideoActivity"
  * click "stop" on TV remote control to end CastSession

---------------------------------------------------------------------

CastPlayer:
===========

onSessionEnded()
 -> setRemoteMediaClient(null)
    -> sessionAvailabilityListener.onCastSessionUnavailable()

VideoManager:
=============

onCastSessionUnavailable()
 -> release(false)
    -> release_castPlayer(false)
       -> castPlayer.release()

CastPlayer:
===========

release()
 -> sessionManager.endCurrentSession(false)
    -> ERROR: because this entire chain of events started when the current session ended..

solution:
=========

in: VideoManager
in: -> onCastSessionUnavailable
old:   -> release(false)
new:   -> release(true)  // retain_cast_session

---------------------------------------------------------------------

old:
====

  @OverRide
  public void onCastSessionUnavailable() {
    if (castPlayer == null) return;

    if (playbackMode == PlaybackMode.CAST_ONLY) {
      setPlaybackMode(PlaybackMode.RELEASED);
    }
    else {
      setCurrentPlayer(exoPlayer);
    }
  }

new:
====

  @OverRide
  public void onCastSessionUnavailable() {
    if (castPlayer == null) return;

    if (playbackMode == PlaybackMode.CAST_ONLY) {
      setPlaybackMode(PlaybackMode.RELEASED_ALL_BUT_CAST_SESSION);
    }
    else {
      setCurrentPlayer(exoPlayer);
    }
  }

---------------------------------------------------------------------
  • Loading branch information
warren-bank committed May 17, 2019
1 parent 928aea7 commit a6a0b1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public void onCastSessionUnavailable() {
if (castPlayer == null) return;

if (playbackMode == PlaybackMode.CAST_ONLY) {
setPlaybackMode(PlaybackMode.RELEASED);
setPlaybackMode(PlaybackMode.RELEASED_ALL_BUT_CAST_SESSION);
}
else {
setCurrentPlayer(exoPlayer);
Expand Down
4 changes: 2 additions & 2 deletions constants.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project.ext {
releaseVersionCode = 004050016
releaseVersion = '004.05.00-16API'
releaseVersionCode = 004060016
releaseVersion = '004.06.00-16API'
minSdkVersion = 16
targetSdkVersion = 28
compileSdkVersion = 28
Expand Down

0 comments on commit a6a0b1b

Please sign in to comment.