Search in sources :

Example 6 with ParsingLoadable

use of androidx.media3.exoplayer.upstream.ParsingLoadable in project media by androidx.

the class DefaultHlsPlaylistTracker method onLoadCompleted.

// Loader.Callback implementation.
@Override
public void onLoadCompleted(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) {
    HlsPlaylist result = loadable.getResult();
    HlsMultivariantPlaylist multivariantPlaylist;
    boolean isMediaPlaylist = result instanceof HlsMediaPlaylist;
    if (isMediaPlaylist) {
        multivariantPlaylist = HlsMultivariantPlaylist.createSingleVariantMultivariantPlaylist(result.baseUri);
    } else /* result instanceof HlsMultivariantPlaylist */
    {
        multivariantPlaylist = (HlsMultivariantPlaylist) result;
    }
    this.multivariantPlaylist = multivariantPlaylist;
    primaryMediaPlaylistUrl = multivariantPlaylist.variants.get(0).url;
    // Add a temporary playlist listener for loading the first primary playlist.
    listeners.add(new FirstPrimaryMediaPlaylistListener());
    createBundles(multivariantPlaylist.mediaPlaylistUrls);
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    MediaPlaylistBundle primaryBundle = playlistBundles.get(primaryMediaPlaylistUrl);
    if (isMediaPlaylist) {
        // We don't need to load the playlist again. We can use the same result.
        primaryBundle.processLoadedPlaylist((HlsMediaPlaylist) result, loadEventInfo);
    } else {
        primaryBundle.loadPlaylist();
    }
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    eventDispatcher.loadCompleted(loadEventInfo, C.DATA_TYPE_MANIFEST);
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo)

Example 7 with ParsingLoadable

use of androidx.media3.exoplayer.upstream.ParsingLoadable in project media by androidx.

the class SsMediaSource method startLoadingManifest.

private void startLoadingManifest() {
    if (manifestLoader.hasFatalError()) {
        return;
    }
    ParsingLoadable<SsManifest> loadable = new ParsingLoadable<>(manifestDataSource, manifestUri, C.DATA_TYPE_MANIFEST, manifestParser);
    long elapsedRealtimeMs = manifestLoader.startLoading(loadable, this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type));
    manifestEventDispatcher.loadStarted(new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, elapsedRealtimeMs), loadable.type);
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo) ParsingLoadable(androidx.media3.exoplayer.upstream.ParsingLoadable) SsManifest(androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest)

Example 8 with ParsingLoadable

use of androidx.media3.exoplayer.upstream.ParsingLoadable in project media by androidx.

the class SsMediaSource method onLoadCanceled.

@Override
public void onLoadCanceled(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    manifestEventDispatcher.loadCanceled(loadEventInfo, loadable.type);
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo)

Example 9 with ParsingLoadable

use of androidx.media3.exoplayer.upstream.ParsingLoadable in project media by androidx.

the class SsMediaSource method onLoadCompleted.

// Loader.Callback implementation
@Override
public void onLoadCompleted(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    manifestEventDispatcher.loadCompleted(loadEventInfo, loadable.type);
    manifest = loadable.getResult();
    manifestLoadStartTimestamp = elapsedRealtimeMs - loadDurationMs;
    processManifest();
    scheduleManifestRefresh();
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo)

Example 10 with ParsingLoadable

use of androidx.media3.exoplayer.upstream.ParsingLoadable in project media by androidx.

the class SsMediaSource method onLoadError.

@Override
public LoadErrorAction onLoadError(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    MediaLoadData mediaLoadData = new MediaLoadData(loadable.type);
    long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor(new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount));
    LoadErrorAction loadErrorAction = retryDelayMs == C.TIME_UNSET ? Loader.DONT_RETRY_FATAL : Loader.createRetryAction(/* resetErrorCount= */
    false, retryDelayMs);
    boolean wasCanceled = !loadErrorAction.isRetry();
    manifestEventDispatcher.loadError(loadEventInfo, loadable.type, error, wasCanceled);
    if (wasCanceled) {
        loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    }
    return loadErrorAction;
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo) MediaLoadData(androidx.media3.exoplayer.source.MediaLoadData) LoadErrorInfo(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo) LoadErrorAction(androidx.media3.exoplayer.upstream.Loader.LoadErrorAction)

Aggregations

LoadEventInfo (androidx.media3.exoplayer.source.LoadEventInfo)14 MediaLoadData (androidx.media3.exoplayer.source.MediaLoadData)3 LoadErrorInfo (androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy.LoadErrorInfo)3 LoadErrorAction (androidx.media3.exoplayer.upstream.Loader.LoadErrorAction)2 ParsingLoadable (androidx.media3.exoplayer.upstream.ParsingLoadable)2 DashManifest (androidx.media3.exoplayer.dash.manifest.DashManifest)1 SsManifest (androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest)1 Loader (androidx.media3.exoplayer.upstream.Loader)1