use of com.google.android.exoplayer2.source.MediaSource.Listener in project ExoPlayer by google.
the class SimpleExoPlayer method buildAudioRenderers.
/**
* Builds audio renderers for use by the player.
*
* @param context The {@link Context} associated with the player.
* @param mainHandler A handler associated with the main thread's looper.
* @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the player will
* not be used for DRM protected playbacks.
* @param extensionRendererMode The extension renderer mode.
* @param eventListener An event listener.
* @param audioProcessors An array of {@link AudioProcessor}s that will process PCM audio buffers
* before output. May be empty.
* @param out An array to which the built renderers should be appended.
*/
protected void buildAudioRenderers(Context context, Handler mainHandler, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, @ExtensionRendererMode int extensionRendererMode, AudioRendererEventListener eventListener, AudioProcessor[] audioProcessors, ArrayList<Renderer> out) {
out.add(new MediaCodecAudioRenderer(MediaCodecSelector.DEFAULT, drmSessionManager, true, mainHandler, eventListener, AudioCapabilities.getCapabilities(context), audioProcessors));
if (extensionRendererMode == EXTENSION_RENDERER_MODE_OFF) {
return;
}
int extensionRendererIndex = out.size();
if (extensionRendererMode == EXTENSION_RENDERER_MODE_PREFER) {
extensionRendererIndex--;
}
try {
Class<?> clazz = Class.forName("com.google.android.exoplayer2.ext.opus.LibopusAudioRenderer");
Constructor<?> constructor = clazz.getConstructor(Handler.class, AudioRendererEventListener.class, AudioProcessor[].class);
Renderer renderer = (Renderer) constructor.newInstance(mainHandler, componentListener, audioProcessors);
out.add(extensionRendererIndex++, renderer);
Log.i(TAG, "Loaded LibopusAudioRenderer.");
} catch (ClassNotFoundException e) {
// Expected if the app was built without the extension.
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
Class<?> clazz = Class.forName("com.google.android.exoplayer2.ext.flac.LibflacAudioRenderer");
Constructor<?> constructor = clazz.getConstructor(Handler.class, AudioRendererEventListener.class, AudioProcessor[].class);
Renderer renderer = (Renderer) constructor.newInstance(mainHandler, componentListener, audioProcessors);
out.add(extensionRendererIndex++, renderer);
Log.i(TAG, "Loaded LibflacAudioRenderer.");
} catch (ClassNotFoundException e) {
// Expected if the app was built without the extension.
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
Class<?> clazz = Class.forName("com.google.android.exoplayer2.ext.ffmpeg.FfmpegAudioRenderer");
Constructor<?> constructor = clazz.getConstructor(Handler.class, AudioRendererEventListener.class, AudioProcessor[].class);
Renderer renderer = (Renderer) constructor.newInstance(mainHandler, componentListener, audioProcessors);
out.add(extensionRendererIndex++, renderer);
Log.i(TAG, "Loaded FfmpegAudioRenderer.");
} catch (ClassNotFoundException e) {
// Expected if the app was built without the extension.
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.google.android.exoplayer2.source.MediaSource.Listener in project ExoPlayer by google.
the class HlsMediaSource method prepareSource.
@Override
public void prepareSource(ExoPlayer player, boolean isTopLevelSource, Listener listener) {
Assertions.checkState(playlistTracker == null);
playlistTracker = new HlsPlaylistTracker(manifestUri, dataSourceFactory, eventDispatcher, minLoadableRetryCount, this);
sourceListener = listener;
playlistTracker.start();
}
use of com.google.android.exoplayer2.source.MediaSource.Listener in project ExoPlayer by google.
the class DashMediaSource method prepareSource.
// MediaSource implementation.
@Override
public void prepareSource(ExoPlayer player, boolean isTopLevelSource, Listener listener) {
sourceListener = listener;
if (sideloadedManifest) {
loaderErrorThrower = new LoaderErrorThrower.Dummy();
processManifest(false);
} else {
dataSource = manifestDataSourceFactory.createDataSource();
loader = new Loader("Loader:DashMediaSource");
loaderErrorThrower = loader;
handler = new Handler();
startLoadingManifest();
}
}
use of com.google.android.exoplayer2.source.MediaSource.Listener in project ExoPlayer by google.
the class ClippingMediaSourceTest method getClippedTimeline.
/**
* Wraps the specified timeline in a {@link ClippingMediaSource} and returns the clipped timeline.
*/
private Timeline getClippedTimeline(Timeline timeline, long startMs, long endMs) {
mockMediaSourceSourceWithTimeline(timeline);
new ClippingMediaSource(mockMediaSource, startMs, endMs).prepareSource(null, true, new Listener() {
@Override
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
clippedTimeline = timeline;
}
});
return clippedTimeline;
}
use of com.google.android.exoplayer2.source.MediaSource.Listener in project ExoPlayer by google.
the class SsMediaSource method prepareSource.
// MediaSource implementation.
@Override
public void prepareSource(ExoPlayer player, boolean isTopLevelSource, Listener listener) {
sourceListener = listener;
if (manifest != null) {
manifestLoaderErrorThrower = new LoaderErrorThrower.Dummy();
processManifest();
} else {
manifestDataSource = manifestDataSourceFactory.createDataSource();
manifestLoader = new Loader("Loader:Manifest");
manifestLoaderErrorThrower = manifestLoader;
manifestRefreshHandler = new Handler();
startLoadingManifest();
}
}
Aggregations