本文整理汇总了Java中com.google.android.exoplayer2.trackselection.TrackSelector类的典型用法代码示例。如果您正苦于以下问题:Java TrackSelector类的具体用法?Java TrackSelector怎么用?Java TrackSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TrackSelector类属于com.google.android.exoplayer2.trackselection包,在下文中一共展示了TrackSelector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFullPlayer
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的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.TrackSelector; //导入依赖的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: initializePlayer
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的package包/类
private void initializePlayer(Uri videoUri){
if (mExoPlayer == null){
TrackSelector trackSelector = new DefaultTrackSelector();
LoadControl loadControl = new DefaultLoadControl();
mExoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
mExoPlayer.addListener(this);
mExoPlayer.seekTo(currentPosition);
mPlayerView.setPlayer(mExoPlayer);
String userAgent = Util.getUserAgent(getContext(), "Tasty");
MediaSource mediaSource = new ExtractorMediaSource(videoUri, new DefaultDataSourceFactory(
getContext(), userAgent), new DefaultExtractorsFactory(), null, null);
mExoPlayer.prepare(mediaSource);
if (playWhenReady) mExoPlayer.setPlayWhenReady(true);
else mExoPlayer.setPlayWhenReady(false);
}
}
示例4: setExoViewSource
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的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);
}
示例5: MediaPeriodHolder
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的package包/类
public MediaPeriodHolder(Renderer[] renderers, RendererCapabilities[] rendererCapabilities,
long rendererPositionOffsetUs, TrackSelector trackSelector, LoadControl loadControl,
MediaSource mediaSource, Object periodUid, int periodIndex, boolean isLastPeriod,
long startPositionUs) {
this.renderers = renderers;
this.rendererCapabilities = rendererCapabilities;
this.rendererPositionOffsetUs = rendererPositionOffsetUs;
this.trackSelector = trackSelector;
this.loadControl = loadControl;
this.mediaSource = mediaSource;
this.uid = Assertions.checkNotNull(periodUid);
this.index = periodIndex;
this.isLast = isLastPeriod;
this.startPositionUs = startPositionUs;
sampleStreams = new SampleStream[renderers.length];
mayRetainStreamFlags = new boolean[renderers.length];
mediaPeriod = mediaSource.createPeriod(periodIndex, loadControl.getAllocator(),
startPositionUs);
}
示例6: initExoPlayer
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的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();
}
示例7: ExoPlayerImpl
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的package包/类
/**
* Constructs an instance. Must be called from a thread that has an associated {@link Looper}.
*
* @param renderers The {@link Renderer}s that will be used by the instance.
* @param trackSelector The {@link TrackSelector} that will be used by the instance.
* @param loadControl The {@link LoadControl} that will be used by the instance.
*/
@SuppressLint("HandlerLeak")
public ExoPlayerImpl(Renderer[] renderers, TrackSelector trackSelector, LoadControl loadControl) {
Log.i(TAG, "Init " + ExoPlayerLibraryInfo.VERSION + " [" + Util.DEVICE_DEBUG_INFO + "]");
Assertions.checkState(renderers.length > 0);
this.renderers = Assertions.checkNotNull(renderers);
this.trackSelector = Assertions.checkNotNull(trackSelector);
this.playWhenReady = false;
this.playbackState = STATE_IDLE;
this.listeners = new CopyOnWriteArraySet<>();
emptyTrackSelections = new TrackSelectionArray(new TrackSelection[renderers.length]);
timeline = Timeline.EMPTY;
window = new Timeline.Window();
period = new Timeline.Period();
trackGroups = TrackGroupArray.EMPTY;
trackSelections = emptyTrackSelections;
eventHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
ExoPlayerImpl.this.handleEvent(msg);
}
};
playbackInfo = new ExoPlayerImplInternal.PlaybackInfo(0, 0);
internalPlayer = new ExoPlayerImplInternal(renderers, trackSelector, loadControl, playWhenReady,
eventHandler, playbackInfo, this);
}
示例8: ExoPlayerImpl
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的package包/类
/**
* Constructs an instance. Must be called from a thread that has an associated {@link Looper}.
*
* @param renderers The {@link Renderer}s that will be used by the instance.
* @param trackSelector The {@link TrackSelector} that will be used by the instance.
* @param loadControl The {@link LoadControl} that will be used by the instance.
*/
@SuppressLint("HandlerLeak")
public ExoPlayerImpl(Renderer[] renderers, TrackSelector<?> trackSelector,
LoadControl loadControl) {
Log.i(TAG, "Init " + ExoPlayerLibraryInfo.VERSION);
Assertions.checkNotNull(renderers);
Assertions.checkState(renderers.length > 0);
this.playWhenReady = false;
this.playbackState = STATE_IDLE;
this.listeners = new CopyOnWriteArraySet<>();
window = new Timeline.Window();
period = new Timeline.Period();
eventHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
ExoPlayerImpl.this.handleEvent(msg);
}
};
playbackInfo = new ExoPlayerImplInternal.PlaybackInfo(0, 0);
internalPlayer = new ExoPlayerImplInternal<>(renderers, trackSelector, loadControl,
playWhenReady, eventHandler, playbackInfo);
}
示例9: FakeExoPlayer
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的package包/类
public FakeExoPlayer(Renderer[] renderers, TrackSelector trackSelector,
LoadControl loadControl) {
this.renderers = renderers;
this.trackSelector = trackSelector;
this.loadControl = loadControl;
this.eventListeners = new CopyOnWriteArraySet<>();
Looper eventListenerLooper = Looper.myLooper();
this.eventListenerHandler = new Handler(eventListenerLooper != null ? eventListenerLooper
: Looper.getMainLooper());
this.playbackThread = new HandlerThread("FakeExoPlayer Thread");
playbackThread.start();
this.playbackHandler = new Handler(playbackThread.getLooper());
this.isStartingUp = true;
this.isLoading = false;
this.playbackState = Player.STATE_IDLE;
this.durationUs = C.TIME_UNSET;
}
示例10: MediaPeriodHolder
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的package包/类
public MediaPeriodHolder(Renderer[] renderers, RendererCapabilities[] rendererCapabilities,
long rendererPositionOffsetUs, TrackSelector trackSelector, LoadControl loadControl,
MediaSource mediaSource, Object periodUid, int index, MediaPeriodInfo info) {
this.renderers = renderers;
this.rendererCapabilities = rendererCapabilities;
this.rendererPositionOffsetUs = rendererPositionOffsetUs;
this.trackSelector = trackSelector;
this.loadControl = loadControl;
this.mediaSource = mediaSource;
this.uid = Assertions.checkNotNull(periodUid);
this.index = index;
this.info = info;
sampleStreams = new SampleStream[renderers.length];
mayRetainStreamFlags = new boolean[renderers.length];
MediaPeriod mediaPeriod = mediaSource.createPeriod(info.id, loadControl.getAllocator());
if (info.endPositionUs != C.TIME_END_OF_SOURCE) {
ClippingMediaPeriod clippingMediaPeriod = new ClippingMediaPeriod(mediaPeriod, true);
clippingMediaPeriod.setClipping(0, info.endPositionUs);
mediaPeriod = clippingMediaPeriod;
}
this.mediaPeriod = mediaPeriod;
}
示例11: createPlayer
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的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);
}
示例12: onCreate
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的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);
}
}
示例13: initializePlayer
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的package包/类
private void initializePlayer(Uri mediaUri) {
if (mExoPlayer == null) {
// Create an instance of the ExoPlayer.
TrackSelector trackSelector = new DefaultTrackSelector();
LoadControl loadControl = new DefaultLoadControl();
mExoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl);
binding.exoStepFragmentPlayerView.setPlayer(mExoPlayer);
mExoPlayer.addListener(this);
String userAgent = Util.getUserAgent(getContext(), "RecipeStepVideo");
MediaSource mediaSource = new ExtractorMediaSource(mediaUri, new DefaultDataSourceFactory(
getContext(), userAgent), new DefaultExtractorsFactory(), null, null);
mExoPlayer.prepare(mediaSource);
mExoPlayer.setPlayWhenReady(true);
}
}
示例14: createFullPlayer
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的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: createFullPlayer
import com.google.android.exoplayer2.trackselection.TrackSelector; //导入依赖的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;
}