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.Download;
|
||||||
import com.google.android.exoplayer2.offline.DownloadCursor;
|
import com.google.android.exoplayer2.offline.DownloadCursor;
|
||||||
import com.google.android.exoplayer2.offline.DownloadHelper;
|
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.DownloadIndex;
|
||||||
import com.google.android.exoplayer2.offline.DownloadManager;
|
import com.google.android.exoplayer2.offline.DownloadManager;
|
||||||
import com.google.android.exoplayer2.offline.DownloadRequest;
|
import com.google.android.exoplayer2.offline.DownloadRequest;
|
||||||
@ -248,13 +249,13 @@ public class DownloadTracker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareError(@NonNull DownloadHelper helper, @NonNull IOException e) {
|
public void onPrepareError(@NonNull DownloadHelper helper, @NonNull IOException e) {
|
||||||
Toast.makeText(context, R.string.download_start_error, Toast.LENGTH_LONG).show();
|
boolean isLiveContent = e instanceof LiveContentUnsupportedException;
|
||||||
Log.e(
|
int toastStringId =
|
||||||
TAG,
|
isLiveContent ? R.string.download_live_unsupported : R.string.download_start_error;
|
||||||
e instanceof DownloadHelper.LiveContentUnsupportedException
|
String logMessage =
|
||||||
? "Downloading live content unsupported"
|
isLiveContent ? "Downloading live content unsupported" : "Failed to start download";
|
||||||
: "Failed to start download",
|
Toast.makeText(context, toastStringId, Toast.LENGTH_LONG).show();
|
||||||
e);
|
Log.e(TAG, logMessage, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialogInterface.OnClickListener implementation.
|
// DialogInterface.OnClickListener implementation.
|
||||||
|
@ -35,18 +35,6 @@ import java.util.Map;
|
|||||||
/** Util to read from and populate an intent. */
|
/** Util to read from and populate an intent. */
|
||||||
public class IntentUtil {
|
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.
|
// Actions.
|
||||||
|
|
||||||
public static final String ACTION_VIEW = "com.google.android.exoplayer.demo.action.VIEW";
|
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 =
|
MediaItem.PlaybackProperties playbackProperties =
|
||||||
checkNotNull(playlistHolder.mediaItems.get(0).playbackProperties);
|
checkNotNull(playlistHolder.mediaItems.get(0).playbackProperties);
|
||||||
if (((IntentUtil.Tag) checkNotNull(playbackProperties.tag)).isLive) {
|
|
||||||
return R.string.download_live_unsupported;
|
|
||||||
}
|
|
||||||
if (playbackProperties.adTagUri != null) {
|
if (playbackProperties.adTagUri != null) {
|
||||||
return R.string.download_ads_unsupported;
|
return R.string.download_ads_unsupported;
|
||||||
}
|
}
|
||||||
@ -347,7 +344,6 @@ public class SampleChooserActivity extends AppCompatActivity
|
|||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
String extension = null;
|
String extension = null;
|
||||||
String title = null;
|
String title = null;
|
||||||
boolean isLive = false;
|
|
||||||
ArrayList<PlaylistHolder> children = null;
|
ArrayList<PlaylistHolder> children = null;
|
||||||
Uri subtitleUri = null;
|
Uri subtitleUri = null;
|
||||||
String subtitleMimeType = null;
|
String subtitleMimeType = null;
|
||||||
@ -376,9 +372,6 @@ public class SampleChooserActivity extends AppCompatActivity
|
|||||||
case "ad_tag_uri":
|
case "ad_tag_uri":
|
||||||
mediaItem.setAdTagUri(reader.nextString());
|
mediaItem.setAdTagUri(reader.nextString());
|
||||||
break;
|
break;
|
||||||
case "is_live":
|
|
||||||
isLive = reader.nextBoolean();
|
|
||||||
break;
|
|
||||||
case "drm_scheme":
|
case "drm_scheme":
|
||||||
mediaItem.setDrmUuid(Util.getDrmUuid(reader.nextString()));
|
mediaItem.setDrmUuid(Util.getDrmUuid(reader.nextString()));
|
||||||
break;
|
break;
|
||||||
@ -443,8 +436,7 @@ public class SampleChooserActivity extends AppCompatActivity
|
|||||||
mediaItem
|
mediaItem
|
||||||
.setUri(uri)
|
.setUri(uri)
|
||||||
.setMediaMetadata(new MediaMetadata.Builder().setTitle(title).build())
|
.setMediaMetadata(new MediaMetadata.Builder().setTitle(title).build())
|
||||||
.setMimeType(adaptiveMimeType)
|
.setMimeType(adaptiveMimeType);
|
||||||
.setTag(new IntentUtil.Tag(isLive));
|
|
||||||
if (subtitleUri != null) {
|
if (subtitleUri != null) {
|
||||||
MediaItem.Subtitle subtitle =
|
MediaItem.Subtitle subtitle =
|
||||||
new MediaItem.Subtitle(
|
new MediaItem.Subtitle(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user