Skip to content

Commit

Permalink
Allow the user to retry playing the stream if playback fails for some…
Browse files Browse the repository at this point in the history
… reason
  • Loading branch information
samfundev committed Sep 15, 2019
1 parent dab8ab1 commit 99bef42
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1265,18 +1265,24 @@ public void finished(HashMap<String, String> url) {
private void playbackFailed() {
mBufferingView.stop();
if (vodId == null) {
showSnackbar(getString(R.string.stream_playback_failed), SNACKBAR_SHOW_DURATION);
showSnackbar(getString(R.string.stream_playback_failed), SNACKBAR_SHOW_DURATION, "Retry", v -> startStreamWithTask());
} else {
showSnackbar(getString(R.string.vod_playback_failed), SNACKBAR_SHOW_DURATION);
showSnackbar(getString(R.string.vod_playback_failed), SNACKBAR_SHOW_DURATION, "Retry", v -> startStreamWithTask());
}
}

private void showSnackbar(String message, int duration) {
showSnackbar(message, duration, null, null);
}

private void showSnackbar(String message, int duration, String actionText, View.OnClickListener action) {
if (getActivity() != null && !isDetached()) {
View mainView = ((StreamActivity) getActivity()).getMainContentLayout();

if ((snackbar == null || !snackbar.isShown()) && mainView != null) {
snackbar = Snackbar.make(mainView, message, duration);
if (actionText != null)
snackbar.setAction(actionText, action);
snackbar.show();
}
}
Expand Down

0 comments on commit 99bef42

Please sign in to comment.