本文整理汇总了Java中com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection类的典型用法代码示例。如果您正苦于以下问题:Java AdaptiveTrackSelection类的具体用法?Java AdaptiveTrackSelection怎么用?Java AdaptiveTrackSelection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AdaptiveTrackSelection类属于com.google.android.exoplayer2.trackselection包,在下文中一共展示了AdaptiveTrackSelection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFullPlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的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;
}
示例2: onBind
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
@Override
public IBinder onBind(final Intent intent) {
bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "SyncPlayer"), bandwidthMeter);
extractorsFactory = new DefaultExtractorsFactory();
TrackSelector trackSelector =
new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player =
ExoPlayerFactory.newSimpleInstance(getApplicationContext(), trackSelector, loadControl);
mMediaPlayer = player;
setCompletionListener();
nbuilder.setSmallIcon(R.mipmap.ic_launcher);
return mBinder;
}
示例3: initPlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
protected void initPlayer() {
// 1. Create a default TrackSelector
mMainHandler = new Handler();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
mTrackSelector =
new DefaultTrackSelector(videoTrackSelectionFactory);
mTrackSelectionHelper = new TrackSelectionHelper(this, mTrackSelector,videoTrackSelectionFactory);
// 3. Create the mTubiExoPlayer
mTubiExoPlayer = ExoPlayerFactory.newSimpleInstance(this, mTrackSelector);
mEventLogger = new EventLogger(mTrackSelector);
mTubiExoPlayer.addListener(mEventLogger);
mTubiExoPlayer.setAudioDebugListener(mEventLogger);
mTubiExoPlayer.setVideoDebugListener(mEventLogger);
mTubiExoPlayer.setMetadataOutput(mEventLogger);
mTubiPlayerView.setPlayer(mTubiExoPlayer, this);
mTubiPlayerView.setMediaModel(mediaModel,true);
mTubiPlayerView.setTrackSelectionHelper(mTrackSelectionHelper);
}
示例4: initializePlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的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);
}
示例5: prepareAsync
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
@Override
public void prepareAsync() throws IllegalStateException {
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
DefaultTrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
mInternalMediaPlayer = InternalExoPlayer.newInstance(mAppContext, trackSelector);
mEventListener = new ExoEventListener();
mInternalMediaPlayer.addListener(mEventListener);
mVideoListener = new ExoVideoListener();
mInternalMediaPlayer.addVideoListener(mVideoListener);
MediaSource mediaSource = buildMediaSource(mUri, mHeaders);
mInternalMediaPlayer.setVideoSurface(mSurface);
mInternalMediaPlayer.prepare(mediaSource);
notifyOnPrepared();
}
示例6: setExoViewSource
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
private void setExoViewSource(@NonNull MasterSecret masterSecret, @NonNull VideoSlide videoSource)
throws IOException
{
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
exoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
exoView.setPlayer(exoPlayer);
DefaultDataSourceFactory defaultDataSourceFactory = new DefaultDataSourceFactory(getContext(), "GenericUserAgent", null);
AttachmentDataSourceFactory attachmentDataSourceFactory = new AttachmentDataSourceFactory(getContext(), masterSecret, defaultDataSourceFactory, null);
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource mediaSource = new ExtractorMediaSource(videoSource.getUri(), attachmentDataSourceFactory, extractorsFactory, null, null);
exoPlayer.prepare(mediaSource);
exoPlayer.setPlayWhenReady(true);
}
示例7: setupExoPlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的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);
}
示例8: initExoPlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
private void initExoPlayer(MediaSource sampleSource) {
if (exoPlayer == null) {
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
// 2. Create the player
exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
}
exoPlayer.prepare(sampleSource);
exoPlayer.setVideoSurfaceView(svPlayer);
exoPlayer.setPlayWhenReady(true);
initMediaControls();
}
示例9: KExoMediaPlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
public KExoMediaPlayer(Context context) {
this.context = context.getApplicationContext();
// [email protected]@=========
TrackSelection.Factory trackSelectionFactory =
new AdaptiveTrackSelection.Factory(BANDWIDTH_METER);
DefaultTrackSelector trackSelector = new DefaultTrackSelector(trackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this.context, trackSelector, new DefaultLoadControl(),
null);
player.addListener(eventLogger);
player.addListener(playerListener);
player.setVideoListener(playerListener);
player.setPlayWhenReady(false);
mainHandler = new Handler();
userAgent = Util.getUserAgent(this.context, "KExoMediaPlayer");
mediaDataSourceFactory = new DefaultDataSourceFactory(this.context, userAgent, BANDWIDTH_METER);
}
示例10: initializePlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
private void initializePlayer() {
simpleExoPlayerView.requestFocus();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
simpleExoPlayerView.setPlayer(player);
MediaSource[] mediaSources = new MediaSource[videos.size()];
for (int i = 0; i < videos.size(); i++) {
mediaSources[i] = buildMediaSource(Uri.parse(videos.get(i).videoUrl));
}
MediaSource mediaSource = mediaSources.length == 1 ? mediaSources[0]
: new ConcatenatingMediaSource(mediaSources);
player.prepare(mediaSource);
}
示例11: ExoMediaPlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的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);
}
示例12: initializePlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
private void initializePlayer() {
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
mTrackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
mPlayer = ExoPlayerFactory.newSimpleInstance(getActivity(), mTrackSelector);
mPlayerAdapter = new LeanbackPlayerAdapter(getActivity(), mPlayer, UPDATE_DELAY);
mPlaylistActionListener = new PlaylistActionListener(mPlaylist);
mPlayerGlue = new VideoPlayerGlue(getActivity(), mPlayerAdapter, mPlaylistActionListener);
mPlayerGlue.setHost(new VideoFragmentGlueHost(this));
mPlayerGlue.playWhenPrepared();
play(mVideo);
ArrayObjectAdapter mRowsAdapter = initializeRelatedVideosRow();
setAdapter(mRowsAdapter);
}
示例13: createPlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
private static SimpleExoPlayer createPlayer(Context context) {
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
return ExoPlayerFactory.newSimpleInstance(context.getApplicationContext(), trackSelector);
}
示例14: startPlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的package包/类
/**
* 播放启动视频
*/
private void startPlayer() {
// 0. set player view
playerView = (SimpleExoPlayerView) findViewById(R.id.playerView);
playerView.setUseController(false);
playerView.getKeepScreenOn();
playerView.setResizeMode(RESIZE_MODE_FILL);
// 1. Create a default TrackSelector
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
// 2. Create a default LoadControl
loadControl = new DefaultLoadControl();
// 3. Create the mPlayer
mPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
mPlayer.addListener(this);
// 4. set player
playerView.setPlayer(mPlayer);
mPlayer.setPlayWhenReady(true);
// 5. prepare to play
File file = new File(Constants.FILE_VIDEO_FLODER, "jcode.mp4");
if (file.isFile() && file.exists()) {
mUri = Uri.fromFile(file);
} else {
Toast.makeText(this,"文件未找到",Toast.LENGTH_SHORT).show();
return;
}
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, "UserAgent");
videoSource = new ExtractorMediaSource(mUri, dataSourceFactory, extractorsFactory, null, null);
// 6. ready to play
mPlayer.prepare(videoSource);
}
示例15: initializePlayer
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; //导入依赖的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);
}