当前位置: 首页>>代码示例>>Java>>正文


Java AdaptiveTrackSelection类代码示例

本文整理汇总了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;
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:24,代码来源:ExoUserPlayer.java

示例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;
}
 
开发者ID:mo3rfan,项目名称:syncplayer,代码行数:26,代码来源:MediaService.java

示例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);
}
 
开发者ID:Tubitv,项目名称:TubiPlayer,代码行数:24,代码来源:TubiPlayerActivity.java

示例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);
}
 
开发者ID:googlecodelabs,项目名称:exoplayer-intro,代码行数:19,代码来源:PlayerActivity.java

示例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();
}
 
开发者ID:xinpianchang,项目名称:NSMPlayer-Android,代码行数:19,代码来源:WrapExoPlayer.java

示例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);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:21,代码来源:VideoPlayer.java

示例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);
}
 
开发者ID:akexorcist,项目名称:Android-O-Feature,代码行数:17,代码来源:PictureInPictureActivity.java

示例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();
}
 
开发者ID:Foso,项目名称:ExoPlayer-with-MediaControls,代码行数:19,代码来源:MainActivity.java

示例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);
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:20,代码来源:KExoMediaPlayer.java

示例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);
}
 
开发者ID:yusufcakmak,项目名称:ExoPlayerSample,代码行数:17,代码来源:PlayListActivity.java

示例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);
}
 
开发者ID:brianwernick,项目名称:ExoMedia,代码行数:22,代码来源:ExoMediaPlayer.java

示例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);
}
 
开发者ID:googlesamples,项目名称:androidtv-Leanback,代码行数:19,代码来源:PlaybackFragment.java

示例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);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:8,代码来源:ExoVideoPlayer.java

示例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);
}
 
开发者ID:hiliving,项目名称:P2Video-master,代码行数:41,代码来源:PlayerActivity.java

示例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);
}
 
开发者ID:googlecodelabs,项目名称:exoplayer-intro,代码行数:16,代码来源:PlayerActivity.java


注:本文中的com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。