當前位置: 首頁>>代碼示例>>Java>>正文


Java TrackSelection.Factory方法代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.trackselection.TrackSelection.Factory方法的典型用法代碼示例。如果您正苦於以下問題:Java TrackSelection.Factory方法的具體用法?Java TrackSelection.Factory怎麽用?Java TrackSelection.Factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.exoplayer2.trackselection.TrackSelection的用法示例。


在下文中一共展示了TrackSelection.Factory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createFullPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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: prepareAsync

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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

示例3: setupExoPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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

示例4: initPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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

示例5: initExoPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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

示例6: KExoMediaPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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

示例7: loadVideo

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
public void loadVideo(){
//        CommonTools.showErrorLog("test"+"11111111111");
//        CommonTools.showErrorLog("test"+playerPosition);
        if (player == null){
            TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
            trackSelector = new DefaultTrackSelector(mainHandler, videoTrackSelectionFactory);
            player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, new DefaultLoadControl(), null, false);
            player.addListener(this);
            setPlayer(player);
//            CommonTools.showErrorLog("test"+"222222222");
            if (playerPosition > 0){
//                CommonTools.showErrorLog("test"+"3333333333");
                player.seekTo(playerPosition);
            }
            player.setPlayWhenReady(isAutoPlay);
        }
        if (uri == null){
//            CommonTools.showToast(getContext(), "請選擇一個視頻來播放");
            return;
        }
        MediaSource mediaSource = buildMediaSource(uri, null);
        player.prepare(mediaSource);
    }
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:24,代碼來源:CustomExoPlayerView.java

示例8: initializePlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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

示例9: setSelectedTrack

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
public void setSelectedTrack(@NonNull RendererType type, int index) {
    // Retrieves the available tracks
    int exoPlayerTrackIndex = getExoPlayerTrackType(type);
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
    TrackGroupArray trackGroupArray = mappedTrackInfo == null ? null : mappedTrackInfo.getTrackGroups(exoPlayerTrackIndex);
    if (trackGroupArray == null || trackGroupArray.length == 0) {
        return;
    }

    // Creates the track selection override
    int[] tracks = new int[] {index};
    TrackSelection.Factory factory = tracks.length == 1 ? new FixedTrackSelection.Factory() : adaptiveTrackSelectionFactory;
    MappingTrackSelector.SelectionOverride selectionOverride = new MappingTrackSelector.SelectionOverride(factory, exoPlayerTrackIndex, tracks);

    // Specifies the correct track to use
    trackSelector.setSelectionOverride(exoPlayerTrackIndex, trackGroupArray, selectionOverride);
}
 
開發者ID:brianwernick,項目名稱:ExoMedia,代碼行數:18,代碼來源:ExoMediaPlayer.java

示例10: initializePlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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

示例11: initializePlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private void initializePlayer() {
    if (player == null) {
        TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER);
        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        player = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, new DefaultLoadControl());
        player.addListener(this);
        exoPlayerView.setPlayer(player);
        if (isTimelineStatic) {
            if (playerPosition == C.TIME_UNSET) {
                player.seekToDefaultPosition(playerWindow);
            } else {
                player.seekTo(playerWindow, playerPosition);
            }
        }
        audioBecomingNoisyReceiver.setListener(this);
        setPlayWhenReady(!isPaused);
        playerNeedsSource = true;
    }
    if (playerNeedsSource && srcUri != null) {
        MediaSource mediaSource = buildMediaSource(srcUri, extension);
        mediaSource = repeat ? new LoopingMediaSource(mediaSource) : mediaSource;
        player.prepare(mediaSource, !shouldRestorePosition, true);
        playerNeedsSource = false;

        eventEmitter.loadStart();
        loadVideoStarted = true;
    }
}
 
開發者ID:12d,項目名稱:react-native-videoplayer,代碼行數:29,代碼來源:ReactExoplayerView.java

示例12: createPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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

示例13: onCreate

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (!isPlaying) {
        Handler mainHandler = new Handler();
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);

        LoadControl loadControl = new DefaultLoadControl();

        SimpleExoPlayer player =
                ExoPlayerFactory.newSimpleInstance(MainActivity.this, trackSelector, loadControl);
        SimpleExoPlayerView playerView = (SimpleExoPlayerView) findViewById(R.id.videoView);
        playerView.setPlayer(player);
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MainActivity.this,
                Util.getUserAgent(MainActivity.this, "yourApplicationName"));
        MediaSource mediaSource = new ExtractorMediaSource(Uri.parse("https://r7---sn-3c27ln7k.googlevideo.com/videoplayback?id=6fb497d0971b8cdf&itag=22&source=picasa&begin=0&requiressl=yes&mm=30&mn=sn-3c27ln7k&ms=nxu&mv=m&nh=IgphcjAzLmticDAxKgkxMjcuMC4wLjE&pl=22&sc=yes&mime=video/mp4&lmt=1486083166327499&mt=1486135406&ip=134.249.158.189&ipbits=8&expire=1486164239&sparams=ip,ipbits,expire,id,itag,source,requiressl,mm,mn,ms,mv,nh,pl,sc,mime,lmt&signature=3BB06D8D4294F8C49B3CE910B3D6849954302BB1.02ABE00700DFCEF715E72D0EFB73B67841E659F8&key=ck2&ratebypass=yes&title=%5BAnime365%5D%20Kuzu%20no%20Honkai%20-%2004%20(t1174045)"), dataSourceFactory,
                new DefaultExtractorsFactory(), null, null);
        player.prepare(mediaSource);
        player.setPlayWhenReady(true);

    }
}
 
開發者ID:CrazyDude1994,項目名稱:lostfilm-android-client,代碼行數:28,代碼來源:MainActivity.java

示例14: createFullPlayer

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的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;
}
 
開發者ID:rubensousa,項目名稱:PreviewSeekBar,代碼行數:14,代碼來源:ExoPlayerManager.java

示例15: createTrackSelector

import com.google.android.exoplayer2.trackselection.TrackSelection; //導入方法依賴的package包/類
private TrackSelector createTrackSelector() {
    // Create a default TrackSelector
    // Measures bandwidth during playback. Can be null if not required.
    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);
    return trackSelector;
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:11,代碼來源:VideoPlayerActivity.java


注:本文中的com.google.android.exoplayer2.trackselection.TrackSelection.Factory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。