Demo app: Remove is_live from exolist.json
It's not used in the public exolist.json file. It's only use is to disable the download icon for live content, but it's quite easy to forget (there are live samples in our internal exolist.json files that omit this property!). It's better just to show a clear error message toast when the download actually fails for this reason. PiperOrigin-RevId: 326281649
This commit is contained in:
parent
a8a32d6bec
commit
a7b1b56064
@ -35,6 +35,7 @@ import com.google.android.exoplayer2.drm.OfflineLicenseHelper;
|
||||
import com.google.android.exoplayer2.offline.Download;
|
||||
import com.google.android.exoplayer2.offline.DownloadCursor;
|
||||
import com.google.android.exoplayer2.offline.DownloadHelper;
|
||||
import com.google.android.exoplayer2.offline.DownloadHelper.LiveContentUnsupportedException;
|
||||
import com.google.android.exoplayer2.offline.DownloadIndex;
|
||||
import com.google.android.exoplayer2.offline.DownloadManager;
|
||||
import com.google.android.exoplayer2.offline.DownloadRequest;
|
||||
@ -248,13 +249,13 @@ public class DownloadTracker {
|
||||
|
||||
@Override
|
||||
public void onPrepareError(@NonNull DownloadHelper helper, @NonNull IOException e) {
|
||||
Toast.makeText(context, R.string.download_start_error, Toast.LENGTH_LONG).show();
|
||||
Log.e(
|
||||
TAG,
|
||||
e instanceof DownloadHelper.LiveContentUnsupportedException
|
||||
? "Downloading live content unsupported"
|
||||
: "Failed to start download",
|
||||
e);
|
||||
boolean isLiveContent = e instanceof LiveContentUnsupportedException;
|
||||
int toastStringId =
|
||||
isLiveContent ? R.string.download_live_unsupported : R.string.download_start_error;
|
||||
String logMessage =
|
||||
isLiveContent ? "Downloading live content unsupported" : "Failed to start download";
|
||||
Toast.makeText(context, toastStringId, Toast.LENGTH_LONG).show();
|
||||
Log.e(TAG, logMessage, e);
|
||||
}
|
||||
|
||||
// DialogInterface.OnClickListener implementation.
|
||||
|
@ -35,18 +35,6 @@ import java.util.Map;
|
||||
/** Util to read from and populate an intent. */
|
||||
public class IntentUtil {
|
||||
|
||||
/** A tag to hold custom playback configuration attributes. */
|
||||
public static class Tag {
|
||||
|
||||
/** Whether the stream is a live stream. */
|
||||
public final boolean isLive;
|
||||
|
||||
/** Creates an instance. */
|
||||
public Tag(boolean isLive) {
|
||||
this.isLive = isLive;
|
||||
}
|
||||
}
|
||||
|
||||
// Actions.
|
||||
|
||||
public static final String ACTION_VIEW = "com.google.android.exoplayer.demo.action.VIEW";
|
||||
|
@ -253,9 +253,6 @@ public class SampleChooserActivity extends AppCompatActivity
|
||||
}
|
||||
MediaItem.PlaybackProperties playbackProperties =
|
||||
checkNotNull(playlistHolder.mediaItems.get(0).playbackProperties);
|
||||
if (((IntentUtil.Tag) checkNotNull(playbackProperties.tag)).isLive) {
|
||||
return R.string.download_live_unsupported;
|
||||
}
|
||||
if (playbackProperties.adTagUri != null) {
|
||||
return R.string.download_ads_unsupported;
|
||||
}
|
||||
@ -347,7 +344,6 @@ public class SampleChooserActivity extends AppCompatActivity
|
||||
Uri uri = null;
|
||||
String extension = null;
|
||||
String title = null;
|
||||
boolean isLive = false;
|
||||
ArrayList<PlaylistHolder> children = null;
|
||||
Uri subtitleUri = null;
|
||||
String subtitleMimeType = null;
|
||||
@ -376,9 +372,6 @@ public class SampleChooserActivity extends AppCompatActivity
|
||||
case "ad_tag_uri":
|
||||
mediaItem.setAdTagUri(reader.nextString());
|
||||
break;
|
||||
case "is_live":
|
||||
isLive = reader.nextBoolean();
|
||||
break;
|
||||
case "drm_scheme":
|
||||
mediaItem.setDrmUuid(Util.getDrmUuid(reader.nextString()));
|
||||
break;
|
||||
@ -443,8 +436,7 @@ public class SampleChooserActivity extends AppCompatActivity
|
||||
mediaItem
|
||||
.setUri(uri)
|
||||
.setMediaMetadata(new MediaMetadata.Builder().setTitle(title).build())
|
||||
.setMimeType(adaptiveMimeType)
|
||||
.setTag(new IntentUtil.Tag(isLive));
|
||||
.setMimeType(adaptiveMimeType);
|
||||
if (subtitleUri != null) {
|
||||
MediaItem.Subtitle subtitle =
|
||||
new MediaItem.Subtitle(
|
||||
|
Loading…
x
Reference in New Issue
Block a user