本文整理汇总了Java中com.google.android.exoplayer2.DefaultRenderersFactory类的典型用法代码示例。如果您正苦于以下问题:Java DefaultRenderersFactory类的具体用法?Java DefaultRenderersFactory怎么用?Java DefaultRenderersFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultRenderersFactory类属于com.google.android.exoplayer2包,在下文中一共展示了DefaultRenderersFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_DEFAULT_CHANNEL_ID, getString(R.string.notification_channel_name), NotificationManagerCompat.IMPORTANCE_DEFAULT);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(notificationChannel);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build();
audioFocusRequest = new AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
.setOnAudioFocusChangeListener(audioFocusChangeListener)
.setAcceptsDelayedFocusGain(false)
.setWillPauseWhenDucked(true)
.setAudioAttributes(audioAttributes)
.build();
}
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mediaSession = new MediaSessionCompat(this, "PlayerService");
mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
mediaSession.setCallback(mediaSessionCallback);
Context appContext = getApplicationContext();
Intent activityIntent = new Intent(appContext, MainActivity.class);
mediaSession.setSessionActivity(PendingIntent.getActivity(appContext, 0, activityIntent, 0));
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null, appContext, MediaButtonReceiver.class);
mediaSession.setMediaButtonReceiver(PendingIntent.getBroadcast(appContext, 0, mediaButtonIntent, 0));
exoPlayer = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this), new DefaultTrackSelector(), new DefaultLoadControl());
exoPlayer.addListener(exoPlayerListener);
DataSource.Factory httpDataSourceFactory = new OkHttpDataSourceFactory(new OkHttpClient(), Util.getUserAgent(this, getString(R.string.app_name)), null);
Cache cache = new SimpleCache(new File(this.getCacheDir().getAbsolutePath() + "/exoplayer"), new LeastRecentlyUsedCacheEvictor(1024 * 1024 * 100)); // 100 Mb max
this.dataSourceFactory = new CacheDataSourceFactory(cache, httpDataSourceFactory, CacheDataSource.FLAG_BLOCK_ON_CACHE | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
this.extractorsFactory = new DefaultExtractorsFactory();
}
示例2: createFullPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
/***
* 创建实例播放实例,并不开始缓冲
**/
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
BufferingLoadControl loadControl = new BufferingLoadControl();
if (null == modelType) {
setDefaultLoadModel();
} else {
loadControl.setListener(new LoadListener() {
@Override
public void onProgress(long pro) {
getPlayerViewListener().showNetSpeed(String.valueOf(pro) + "%");
}
});
}
DefaultRenderersFactory rf = new DefaultRenderersFactory(activity, drmSessionManager, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(rf, trackSelector, loadControl);
player.setPlaybackParameters(playbackParameters);
getPlayerViewListener().setPlayer(player);
return player;
}
示例3: initializePlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private void initializePlayer() {
if (player == null) {
// a factory to create an AdaptiveVideoTrackSelection
TrackSelection.Factory adaptiveTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
// using a DefaultTrackSelector with an adaptive video selection factory
player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this),
new DefaultTrackSelector(adaptiveTrackSelectionFactory), new DefaultLoadControl());
player.addListener(componentListener);
player.addVideoDebugListener(componentListener);
player.addAudioDebugListener(componentListener);
playerView.setPlayer(player);
player.setPlayWhenReady(playWhenReady);
player.seekTo(currentWindow, playbackPosition);
}
MediaSource mediaSource = buildMediaSource(Uri.parse(getString(R.string.media_url_dash)));
player.prepare(mediaSource, true, false);
}
示例4: setupExoPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private void setupExoPlayer() {
TrackSelection.Factory adaptiveTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
exoPlayer = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(this),
new DefaultTrackSelector(adaptiveTrackSelectionFactory),
new DefaultLoadControl());
pvVideoPreview.setPlayer(exoPlayer);
exoPlayer.setPlayWhenReady(true);
Uri uri = Uri.parse("asset:///sample_video.mp4");
MediaSource mediaSource = createMediaSource(this, uri);
LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource);
exoPlayer.prepare(loopingMediaSource, true, false);
}
示例5: initializePlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private void initializePlayer() {
if (player == null) {
player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this),
new DefaultTrackSelector(), new DefaultLoadControl());
playerView.setPlayer(player);
player.setPlayWhenReady(playWhenReady);
player.seekTo(currentWindow, playbackPosition);
}
MediaSource mediaSource = buildMediaSource(Uri.parse(getString(R.string.media_url_mp4)));
player.prepare(mediaSource, true, false);
}
示例6: initializePlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private void initializePlayer() {
if (player == null) {
// a factory to create an AdaptiveVideoTrackSelection
TrackSelection.Factory adaptiveTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
// let the factory create a player instance with default components
player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this),
new DefaultTrackSelector(adaptiveTrackSelectionFactory), new DefaultLoadControl());
playerView.setPlayer(player);
player.setPlayWhenReady(playWhenReady);
player.seekTo(currentWindow, playbackPosition);
}
MediaSource mediaSource = buildMediaSource(Uri.parse(getString(R.string.media_url_dash)));
player.prepare(mediaSource, true, false);
}
示例7: setupPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private SimpleExoPlayer setupPlayer(){
Log.d(TAG,"Setting up Player.");
videoView.setKeepScreenOn(true);
mUserAgent = Util.getUserAgent(getContext(), getResources().getString(R.string.app_name));
AdaptiveTrackSelection.Factory trackSelectorFactory
= new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
DefaultTrackSelector trackSelector = new DefaultTrackSelector(trackSelectorFactory);
LoadControl loadControl = new DefaultLoadControl();
DefaultRenderersFactory renderersFactory
= new DefaultRenderersFactory(getContext(), null, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);
exoPlayer = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl);
MyListener listener = new MyListener(exoPlayer, this);
exoPlayer.addVideoListener(listener);
exoPlayer.addListener(listener);
exoPlayer.setPlayWhenReady(mPlaybackState);
exoPlayer.prepare(buildMediaSource(Uri.parse(mRecording.getRecordingUrl()),""));
return exoPlayer;
}
示例8: createFullPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory
= new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(playerView.getContext()),
trackSelector, loadControl);
player.setPlayWhenReady(true);
player.prepare(mediaSourceBuilder.getMediaSource(false));
player.addListener(eventListener);
return player;
}
示例9: createFullPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory
= new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(playerView.getContext()),
trackSelector, loadControl);
player.setPlayWhenReady(true);
player.prepare(mediaSourceBuilder.getMediaSource(false));
player.addListener(this);
return player;
}
示例10: createPreviewPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private SimpleExoPlayer createPreviewPlayer() {
TrackSelection.Factory videoTrackSelectionFactory = new WorstVideoTrackSelection.Factory();
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new PreviewLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(playerView.getContext()),
trackSelector, loadControl);
player.setPlayWhenReady(false);
player.setVolume(0f);
player.prepare(mediaSourceBuilder.getMediaSource(true));
return player;
}
示例11: createExoPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
private void createExoPlayer() {
if (mExoPlayer != null) {
releaseExoPlayer();
}
// create default TrackSelector
TrackSelector trackSelector = new DefaultTrackSelector();
// create default LoadControl - double the buffer
LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE * 2));
// create the player
mExoPlayer = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(getApplicationContext()), trackSelector, loadControl);
}
示例12: prepareAsync
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
@Override
public void prepareAsync() throws IllegalStateException {
if (mInternalPlayer != null)
throw new IllegalStateException("can't prepare a prepared player");
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
mTrackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
mEventLogger = new EventLogger(mTrackSelector);
boolean preferExtensionDecoders = true;
boolean useExtensionRenderers = true;//是否开启扩展
@DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode = useExtensionRenderers
? (preferExtensionDecoders ? DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER
: DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON)
: DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF;
renderersFactory = new DefaultRenderersFactory(mAppContext, null, extensionRendererMode);
DefaultLoadControl loadControl = new DefaultLoadControl();
mInternalPlayer = new SimpleExoPlayer2(renderersFactory, mTrackSelector, loadControl);
mInternalPlayer.addListener(this);
mInternalPlayer.setVideoDebugListener(this);
mInternalPlayer.setAudioDebugListener(this);
mInternalPlayer.addListener(mEventLogger);
if (mSpeedPlaybackParameters != null) {
mInternalPlayer.setPlaybackParameters(mSpeedPlaybackParameters);
}
if (mSurface != null)
mInternalPlayer.setVideoSurface(mSurface);
mInternalPlayer.prepare(mMediaSource);
mInternalPlayer.setPlayWhenReady(false);
}
示例13: initExoPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
/**--------------------- 创建SimpleExoPlayer ----------------------------**/
private void initExoPlayer() {
mMediaDataSourceFactory = buildDataSourceFactory(true);
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
mTrackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
mEventLogger = new EventLogger(mTrackSelector);
mMainHandler = new Handler(Looper.getMainLooper());
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(mContext,
null, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF);
mExoPlayer = ExoPlayerFactory.newSimpleInstance(renderersFactory, mTrackSelector);
mExoPlayer.addListener(mEventLogger);
mExoPlayer.setAudioDebugListener(mEventLogger);
mExoPlayer.setVideoDebugListener(mEventLogger);
mExoPlayer.setMetadataOutput(mEventLogger);
mExoPlayer.setTextOutput(null);
mExoPlayer.setVideoListener(null);
mExoPlayer.removeListener(this);
mExoPlayer.setVideoTextureView(null);
mExoPlayer.setVideoListener(this);
mExoPlayer.addListener(this);
mExoPlayer.setTextOutput(this);
}
示例14: ExoPlayerPlayableFilePreparationSourceProvider
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
public ExoPlayerPlayableFilePreparationSourceProvider(Context context, BestMatchUriProvider bestMatchUriProvider, RemoteFileUriProvider remoteFileUriProvider, Library library) {
this.bestMatchUriProvider = bestMatchUriProvider;
this.remoteFileUriProvider = remoteFileUriProvider;
final AudioCacheConfiguration audioCacheConfiguration = new AudioCacheConfiguration(library);
final CachedFilesProvider cachedFilesProvider = new CachedFilesProvider(context, audioCacheConfiguration);
final DiskFileAccessTimeUpdater diskFileAccessTimeUpdater = new DiskFileAccessTimeUpdater(context);
final IDiskCacheDirectoryProvider diskCacheDirectoryProvider = new AndroidDiskCacheDirectoryProvider(context);
final DiskFileCacheStreamSupplier diskFileCacheStream = new DiskFileCacheStreamSupplier(
diskCacheDirectoryProvider,
audioCacheConfiguration,
new DiskFileCachePersistence(
context,
diskCacheDirectoryProvider,
audioCacheConfiguration,
cachedFilesProvider,
diskFileAccessTimeUpdater),
cachedFilesProvider);
extractorMediaSourceFactoryProvider = new ExtractorMediaSourceFactoryProvider(context, library, diskFileCacheStream);
diskFileCache =
new DiskFileCache(
context,
diskCacheDirectoryProvider,
audioCacheConfiguration,
diskFileCacheStream,
cachedFilesProvider,
diskFileAccessTimeUpdater);
renderersFactory = new DefaultRenderersFactory(context);
handler = new Handler(context.getMainLooper());
}
示例15: buildExoPlayer
import com.google.android.exoplayer2.DefaultRenderersFactory; //导入依赖的package包/类
@SuppressWarnings("unused")
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
MappingTrackSelector trackSelector,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
RenderersFactory renderersFactory = new DefaultRenderersFactory(host, drmSessionManager,
DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF, 0);
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector);
player.setVideoSurface(surface);
return player;
}