mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fail at preparation when trying to download live content.
PiperOrigin-RevId: 275293735
This commit is contained in:
parent
36f8bd78f7
commit
0c0a67bb93
2 changed files with 17 additions and 1 deletions
|
|
@ -216,7 +216,12 @@ public class DownloadTracker {
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareError(DownloadHelper helper, IOException e) {
|
public void onPrepareError(DownloadHelper helper, IOException e) {
|
||||||
Toast.makeText(context, R.string.download_start_error, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.download_start_error, Toast.LENGTH_LONG).show();
|
||||||
Log.e(TAG, "Failed to start download", e);
|
Log.e(
|
||||||
|
TAG,
|
||||||
|
e instanceof DownloadHelper.LiveContentUnsupportedException
|
||||||
|
? "Downloading live content unsupported"
|
||||||
|
: "Failed to start download",
|
||||||
|
e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialogInterface.OnClickListener implementation.
|
// DialogInterface.OnClickListener implementation.
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,9 @@ public final class DownloadHelper {
|
||||||
void onPrepareError(DownloadHelper helper, IOException e);
|
void onPrepareError(DownloadHelper helper, IOException e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Thrown at an attempt to download live content. */
|
||||||
|
public static class LiveContentUnsupportedException extends IOException {}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static final Constructor<? extends MediaSourceFactory> DASH_FACTORY_CONSTRUCTOR =
|
private static final Constructor<? extends MediaSourceFactory> DASH_FACTORY_CONSTRUCTOR =
|
||||||
getConstructor("com.google.android.exoplayer2.source.dash.DashMediaSource$Factory");
|
getConstructor("com.google.android.exoplayer2.source.dash.DashMediaSource$Factory");
|
||||||
|
|
@ -999,6 +1002,14 @@ public final class DownloadHelper {
|
||||||
// Ignore dynamic updates.
|
// Ignore dynamic updates.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (timeline.getWindow(/* windowIndex= */ 0, new Timeline.Window()).isLive) {
|
||||||
|
downloadHelperHandler
|
||||||
|
.obtainMessage(
|
||||||
|
DOWNLOAD_HELPER_CALLBACK_MESSAGE_FAILED,
|
||||||
|
/* obj= */ new LiveContentUnsupportedException())
|
||||||
|
.sendToTarget();
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
mediaPeriods = new MediaPeriod[timeline.getPeriodCount()];
|
mediaPeriods = new MediaPeriod[timeline.getPeriodCount()];
|
||||||
for (int i = 0; i < mediaPeriods.length; i++) {
|
for (int i = 0; i < mediaPeriods.length; i++) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue