本文整理匯總了Java中com.google.android.exoplayer2.DefaultLoadControl類的典型用法代碼示例。如果您正苦於以下問題:Java DefaultLoadControl類的具體用法?Java DefaultLoadControl怎麽用?Java DefaultLoadControl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DefaultLoadControl類屬於com.google.android.exoplayer2包,在下文中一共展示了DefaultLoadControl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_DEFAULT_CHANNEL_ID, getString(R.string.notification_channel_name), NotificationManagerCompat.IMPORTANCE_DEFAULT);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(notificationChannel);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build();
audioFocusRequest = new AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
.setOnAudioFocusChangeListener(audioFocusChangeListener)
.setAcceptsDelayedFocusGain(false)
.setWillPauseWhenDucked(true)
.setAudioAttributes(audioAttributes)
.build();
}
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mediaSession = new MediaSessionCompat(this, "PlayerService");
mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
mediaSession.setCallback(mediaSessionCallback);
Context appContext = getApplicationContext();
Intent activityIntent = new Intent(appContext, MainActivity.class);
mediaSession.setSessionActivity(PendingIntent.getActivity(appContext, 0, activityIntent, 0));
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null, appContext, MediaButtonReceiver.class);
mediaSession.setMediaButtonReceiver(PendingIntent.getBroadcast(appContext, 0, mediaButtonIntent, 0));
exoPlayer = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this), new DefaultTrackSelector(), new DefaultLoadControl());
exoPlayer.addListener(exoPlayerListener);
DataSource.Factory httpDataSourceFactory = new OkHttpDataSourceFactory(new OkHttpClient(), Util.getUserAgent(this, getString(R.string.app_name)), null);
Cache cache = new SimpleCache(new File(this.getCacheDir().getAbsolutePath() + "/exoplayer"), new LeastRecentlyUsedCacheEvictor(1024 * 1024 * 100)); // 100 Mb max
this.dataSourceFactory = new CacheDataSourceFactory(cache, httpDataSourceFactory, CacheDataSource.FLAG_BLOCK_ON_CACHE | CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR);
this.extractorsFactory = new DefaultExtractorsFactory();
}
示例2: onBind
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的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.DefaultLoadControl; //導入依賴的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);
}
示例4: initializePlayer
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的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);
}
}
示例5: startPlayer
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的package包/類
@Override
public void startPlayer() {
if(exoPlayer==null){
exoPlayer =
ExoPlayerFactory.newSimpleInstance(
context, new DefaultTrackSelector(), new DefaultLoadControl());
exoPlayer.addListener(this);
}
exoPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(
context, Util.getUserAgent(context, "uamp"), null);
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource mediaSource = new ExtractorMediaSource(
Uri.parse(currentUrl), dataSourceFactory, extractorsFactory, null, null);
exoPlayer.prepare(mediaSource);
configPlayer();
}
示例6: setExoViewSource
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的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.DefaultLoadControl; //導入依賴的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: create
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的package包/類
@NonNull
public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator,
DefaultDrmSessionManager.EventListener drmSessionEventListener,
MediaCodecSelector mediaCodecSelector) {
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = drmSessionCreator.create(drmSessionEventListener);
RenderersFactory renderersFactory = new SimpleRenderersFactory(
context,
drmSessionManager,
EXTENSION_RENDERER_MODE_OFF,
DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS,
mediaCodecSelector
);
DefaultLoadControl loadControl = new DefaultLoadControl();
return ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl);
}
示例9: KExoMediaPlayer
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的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: loadVideo
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的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);
}
示例11: ExoMediaPlayer
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的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.DefaultLoadControl; //導入依賴的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;
}
}
示例13: onCreate
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的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: initializePlayer
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的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);
}
}
示例15: buildExoPlayer
import com.google.android.exoplayer2.DefaultLoadControl; //導入依賴的package包/類
@SuppressWarnings("unused")
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
MappingTrackSelector trackSelector,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(host, trackSelector,
new DefaultLoadControl(), drmSessionManager, SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF,
0);
player.setVideoSurface(surface);
return player;
}