本文整理匯總了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;
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}