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


Java DefaultLoadControl類代碼示例

本文整理匯總了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();
}
 
開發者ID:SergeyVinyar,項目名稱:AndroidAudioExample,代碼行數:43,代碼來源:PlayerService.java

示例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;
}
 
開發者ID:mo3rfan,項目名稱:syncplayer,代碼行數:26,代碼來源:MediaService.java

示例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);
}
 
開發者ID:googlecodelabs,項目名稱:exoplayer-intro,代碼行數:19,代碼來源:PlayerActivity.java

示例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);
    }
}
 
開發者ID:harrynp,項目名稱:BakingApp,代碼行數:17,代碼來源:StepDetailFragment.java

示例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();
}
 
開發者ID:vpaliyX,項目名稱:Melophile,代碼行數:18,代碼來源:MediaPlayback21.java

示例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);
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:21,代碼來源:VideoPlayer.java

示例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);
}
 
開發者ID:akexorcist,項目名稱:Android-O-Feature,代碼行數:17,代碼來源:PictureInPictureActivity.java

示例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);
}
 
開發者ID:novoda,項目名稱:no-player,代碼行數:17,代碼來源:ExoPlayerCreator.java

示例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);
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:20,代碼來源:KExoMediaPlayer.java

示例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);
    }
 
開發者ID:zhanglibin123488,項目名稱:videoPickPlayer,代碼行數:24,代碼來源:CustomExoPlayerView.java

示例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);
}
 
開發者ID:brianwernick,項目名稱:ExoMedia,代碼行數:22,代碼來源:ExoMediaPlayer.java

示例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;
    }
}
 
開發者ID:12d,項目名稱:react-native-videoplayer,代碼行數:29,代碼來源:ReactExoplayerView.java

示例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);

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

示例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);
    }
}
 
開發者ID:twisstosin,項目名稱:UdacityBakingAndroid,代碼行數:16,代碼來源:StepFragment.java

示例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;
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:11,代碼來源:ExoHostedTest.java


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