Fix for a hang when attempting to stream a non-existing content.

 -- StreamStarter Activity is binding the the MediaPlaybackService. As part of this, it is registering for the intent "ASYNC_OPEN_COMPLETE".
 -- In the normal scenario, after prepareAsync completes, the OnPreparedListener is fired. This ends up broadcasting the "ASYNC_OPEN_COMPLETE" intent.
 -- Since the StreamStarter Activity has registered for the intent, it will receive the even on it's listener, "onReceive". Here, the MediaPlaybackService
    "play" is called which starts the actual playback. And, the PLAYBACK_VIEWER intent is sent. This starts the MediaPlaybackActivity. And, "finish" is
    called in the StreamStarter Activity that will kill the activity. From this point, the MediaPlayback Activity takes over (this activity is the screen
    where you see the progress bar, and the metadata stuff).
 -- Now, in this scenario, there is a failure in the "prepareAsync" command. Because of this the ASYNC_OPEN_COMPLETE intent is never broadcasted, and
    hence the StreamStarterActivity never finishes.

- Proposed solution:
  -- Register the StreamStarter Activity to another intent (PLAYBACK_COMPLETE).
  -- In OnReceive call, add a condition that when the received intent is PLAYBACK_COMPLETE, "finish" the activity.
     needs to be broadcasted only if this is a single attempt playback, i.e., if "mOneShot" is "true".
2 files changed