本文整理汇总了Java中com.google.android.exoplayer2.Renderer类的典型用法代码示例。如果您正苦于以下问题:Java Renderer类的具体用法?Java Renderer怎么用?Java Renderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Renderer类属于com.google.android.exoplayer2包,在下文中一共展示了Renderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setVideoSurfaceInternal
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
private void setVideoSurfaceInternal(Surface surface, boolean ownsSurface) {
// Note: We don't turn this method into a no-op if the surface is being replaced with itself
// so as to ensure onRenderedFirstFrame callbacks are still called in this case.
ExoPlayerMessage[] messages = new ExoPlayerMessage[videoRendererCount];
int count = 0;
for (Renderer renderer : renderers) {
if (renderer.getTrackType() == C.TRACK_TYPE_VIDEO) {
messages[count++] = new ExoPlayerMessage(renderer, C.MSG_SET_SURFACE, surface);
}
}
if (this.surface != null && this.surface != surface) {
// We're replacing a surface. Block to ensure that it's not accessed after the method returns.
player.blockingSendMessages(messages);
// If we created the previous surface, we are responsible for releasing it.
if (this.ownsSurface) {
this.surface.release();
}
} else {
player.sendMessages(messages);
}
this.surface = surface;
this.ownsSurface = ownsSurface;
}
示例2: createRenderers
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
public Renderer[] createRenderers(Handler eventHandler,
VideoRendererEventListener videoRendererEventListener,
AudioRendererEventListener audioRendererEventListener,
TextOutput textRendererOutput,
MetadataOutput metadataRendererOutput) {
ArrayList<Renderer> renderersList = new ArrayList<>();
buildVideoRenderers(context, drmSessionManager, allowedVideoJoiningTimeMs,
eventHandler, videoRendererEventListener, extensionRendererMode, renderersList);
buildAudioRenderers(context, drmSessionManager, buildAudioProcessors(),
eventHandler, audioRendererEventListener, extensionRendererMode, renderersList);
buildTextRenderers(textRendererOutput, eventHandler.getLooper(),
renderersList);
buildMetadataRenderers(metadataRendererOutput, eventHandler.getLooper(),
renderersList);
buildMiscellaneousRenderers();
return renderersList.toArray(new Renderer[renderersList.size()]);
}
示例3: run
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
public void run() {
Looper.prepare();
LibvpxVideoRenderer videoRenderer = new LibvpxVideoRenderer(true, 0);
DefaultTrackSelector trackSelector = new DefaultTrackSelector();
player = ExoPlayerFactory.newInstance(new Renderer[] {videoRenderer}, trackSelector);
player.addListener(this);
ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"),
MatroskaExtractor.FACTORY,
null,
null);
player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer,
LibvpxVideoRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
new VpxVideoSurfaceView(context)));
player.prepare(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
示例4: run
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
public void run() {
Looper.prepare();
LibopusAudioRenderer audioRenderer = new LibopusAudioRenderer();
DefaultTrackSelector trackSelector = new DefaultTrackSelector();
player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector);
player.addListener(this);
ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"),
MatroskaExtractor.FACTORY,
null,
null);
player.prepare(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
示例5: run
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
public void run() {
Looper.prepare();
LibflacAudioRenderer audioRenderer = new LibflacAudioRenderer();
DefaultTrackSelector trackSelector = new DefaultTrackSelector();
player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector);
player.addListener(this);
ExtractorMediaSource mediaSource = new ExtractorMediaSource(
uri,
new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"),
MatroskaExtractor.FACTORY,
null,
null);
player.prepare(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
示例6: buildAudioRenderers
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@NonNull
protected List<Renderer> buildAudioRenderers() {
List<Renderer> renderers = new ArrayList<>();
renderers.add(new MediaCodecAudioRenderer(MediaCodecSelector.DEFAULT, drmSessionManager, true, handler, audioRendererEventListener, AudioCapabilities.getCapabilities(context)));
// Adds any registered classes
List<String> classNames = ExoMedia.Data.registeredRendererClasses.get(ExoMedia.RendererType.AUDIO);
if (classNames != null) {
for (String className: classNames) {
try {
Class<?> clazz = Class.forName(className);
Constructor<?> constructor = clazz.getConstructor(Handler.class, AudioRendererEventListener.class);
Renderer renderer = (Renderer) constructor.newInstance(handler, audioRendererEventListener);
renderers.add(renderer);
} catch (Exception e) {
// Purposefully left blank
}
}
}
return renderers;
}
示例7: buildVideoRenderers
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@NonNull
protected List<Renderer> buildVideoRenderers() {
List<Renderer> renderers = new ArrayList<>();
renderers.add(new MediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT, videoJoiningTimeMs, drmSessionManager, false, handler, videoRendererEventListener, droppedFrameNotificationAmount));
// Adds any registered classes
List<String> classNames = ExoMedia.Data.registeredRendererClasses.get(ExoMedia.RendererType.VIDEO);
if (classNames != null) {
for (String className: classNames) {
try {
Class<?> clazz = Class.forName(className);
Constructor<?> constructor = clazz.getConstructor(boolean.class, long.class, Handler.class, VideoRendererEventListener.class, int.class);
Renderer renderer = (Renderer) constructor.newInstance(true, videoJoiningTimeMs, handler, videoRendererEventListener, droppedFrameNotificationAmount);
renderers.add(renderer);
} catch (Exception e) {
// Purposefully left blank
}
}
}
return renderers;
}
示例8: ExoMediaPlayer
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
public ExoMediaPlayer(@NonNull Context context) {
this.context = context;
bufferRepeater.setRepeaterDelay(BUFFER_REPEAT_DELAY);
bufferRepeater.setRepeatListener(new BufferRepeatListener());
mainHandler = new Handler();
ComponentListener componentListener = new ComponentListener();
RendererProvider rendererProvider = new RendererProvider(context, mainHandler, componentListener, componentListener, componentListener, componentListener);
rendererProvider.setDrmSessionManager(generateDrmSessionManager());
renderers = rendererProvider.generate();
adaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
trackSelector = new DefaultTrackSelector(adaptiveTrackSelectionFactory);
LoadControl loadControl = ExoMedia.Data.loadControl != null ? ExoMedia.Data.loadControl : new DefaultLoadControl();
player = ExoPlayerFactory.newInstance(renderers.toArray(new Renderer[renderers.size()]), trackSelector, loadControl);
player.addListener(this);
}
示例9: sendMessage
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
protected void sendMessage(int renderType, int messageType, Object message, boolean blocking) {
if (renderers.isEmpty()) {
return;
}
List<ExoPlayer.ExoPlayerMessage> messages = new ArrayList<>();
for (Renderer renderer : renderers) {
if (renderer.getTrackType() == renderType) {
messages.add(new ExoPlayer.ExoPlayerMessage(renderer, messageType, message));
}
}
if (blocking) {
player.blockingSendMessages(messages.toArray(new ExoPlayer.ExoPlayerMessage[messages.size()]));
} else {
player.sendMessages(messages.toArray(new ExoPlayer.ExoPlayerMessage[messages.size()]));
}
}
示例10: run
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
public void run() {
Looper.prepare();
LibvpxVideoRenderer videoRenderer = new LibvpxVideoRenderer(true, 0);
DefaultTrackSelector trackSelector = new DefaultTrackSelector();
player = ExoPlayerFactory.newInstance(new Renderer[] {videoRenderer}, trackSelector);
player.addListener(this);
MediaSource mediaSource =
new ExtractorMediaSource.Factory(
new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"))
.setExtractorsFactory(MatroskaExtractor.FACTORY)
.createMediaSource(uri);
player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer,
LibvpxVideoRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
new VpxVideoSurfaceView(context)));
player.prepare(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
示例11: run
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
public void run() {
Looper.prepare();
LibopusAudioRenderer audioRenderer = new LibopusAudioRenderer();
DefaultTrackSelector trackSelector = new DefaultTrackSelector();
player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector);
player.addListener(this);
MediaSource mediaSource =
new ExtractorMediaSource.Factory(
new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"))
.setExtractorsFactory(MatroskaExtractor.FACTORY)
.createMediaSource(uri);
player.prepare(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
示例12: run
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
public void run() {
Looper.prepare();
LibflacAudioRenderer audioRenderer = new LibflacAudioRenderer();
DefaultTrackSelector trackSelector = new DefaultTrackSelector();
player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector);
player.addListener(this);
MediaSource mediaSource =
new ExtractorMediaSource.Factory(
new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"))
.setExtractorsFactory(MatroskaExtractor.FACTORY)
.createMediaSource(uri);
player.prepare(mediaSource);
player.setPlayWhenReady(true);
Looper.loop();
}
示例13: FakeExoPlayer
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
public FakeExoPlayer(Renderer[] renderers, TrackSelector trackSelector,
LoadControl loadControl) {
this.renderers = renderers;
this.trackSelector = trackSelector;
this.loadControl = loadControl;
this.eventListeners = new CopyOnWriteArraySet<>();
Looper eventListenerLooper = Looper.myLooper();
this.eventListenerHandler = new Handler(eventListenerLooper != null ? eventListenerLooper
: Looper.getMainLooper());
this.playbackThread = new HandlerThread("FakeExoPlayer Thread");
playbackThread.start();
this.playbackHandler = new Handler(playbackThread.getLooper());
this.isStartingUp = true;
this.isLoading = false;
this.playbackState = Player.STATE_IDLE;
this.durationUs = C.TIME_UNSET;
}
示例14: onTracksSelected
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
public void onTracksSelected(Renderer[] renderers, TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
targetBufferSize = 0;
for (int i = 0; i < renderers.length; i++) {
if (trackSelections.get(i) != null) {
targetBufferSize += Util.getDefaultBufferSize(renderers[i].getTrackType());
}
}
allocator.setTargetBufferSize(targetBufferSize);
}
示例15: buildVideoRenderers
import com.google.android.exoplayer2.Renderer; //导入依赖的package包/类
@Override
protected void buildVideoRenderers(Context context, Handler mainHandler,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
@ExtensionRendererMode int extensionRendererMode, VideoRendererEventListener eventListener,
long allowedVideoJoiningTimeMs, ArrayList<Renderer> out) {
out.add(new DebugMediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT,
allowedVideoJoiningTimeMs, mainHandler, drmSessionManager, eventListener,
MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY));
}