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


Java DefaultExtractorsFactory類代碼示例

本文整理匯總了Java中com.google.android.exoplayer2.extractor.DefaultExtractorsFactory的典型用法代碼示例。如果您正苦於以下問題:Java DefaultExtractorsFactory類的具體用法?Java DefaultExtractorsFactory怎麽用?Java DefaultExtractorsFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: onCreate

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的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: buildMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
開發者ID:12d,項目名稱:react-native-videoplayer,代碼行數:21,代碼來源:ReactExoplayerView.java

示例3: onBind

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的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

示例4: buildMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:21,代碼來源:PlayerActivity.java

示例5: buildMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
private MediaSource buildMediaSource(Context context, Uri uri) {
    int type = getUrlType(uri.toString());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, new DefaultDataSourceFactory(context, null,
                    new DefaultHttpDataSourceFactory(USER_AGENT, null)),
                    new DefaultSsChunkSource.Factory(new DefaultDataSourceFactory(context, BANDWIDTH_METER,
                            new DefaultHttpDataSourceFactory(USER_AGENT, BANDWIDTH_METER))), mainThreadHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, new DefaultDataSourceFactory(context, null,
                    new DefaultHttpDataSourceFactory(USER_AGENT, null)),
                    new DefaultDashChunkSource.Factory(new DefaultDataSourceFactory(context, BANDWIDTH_METER,
                            new DefaultHttpDataSourceFactory(USER_AGENT, BANDWIDTH_METER))), mainThreadHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, new DefaultDataSourceFactory(context, BANDWIDTH_METER,
                    new DefaultHttpDataSourceFactory(USER_AGENT, BANDWIDTH_METER)), mainThreadHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, new DefaultDataSourceFactory(context, BANDWIDTH_METER,
                    new DefaultHttpDataSourceFactory(USER_AGENT, BANDWIDTH_METER)), new DefaultExtractorsFactory(),
                    mainThreadHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
開發者ID:tohodog,項目名稱:QSVideoPlayer,代碼行數:26,代碼來源:ExoMedia.java

示例6: buildMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
	DataSource.Factory mediaDataSourceFactory = buildDataSourceFactory(true);
	int type = TextUtils.isEmpty(overrideExtension) ? Util.inferContentType(uri)
			: Util.inferContentType("." + overrideExtension);
	switch (type) {
		case C.TYPE_SS:
			return new SsMediaSource(uri, buildDataSourceFactory(false),
					new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
		case C.TYPE_DASH:
			return new DashMediaSource(uri, buildDataSourceFactory(false),
					new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, null);
		case C.TYPE_HLS:
			return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, null);
		case C.TYPE_OTHER:
			return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
					mainHandler, null);
		default: {
			throw new IllegalStateException("Unsupported type: " + type);
		}
	}
}
 
開發者ID:NiciDieNase,項目名稱:chaosflix-leanback,代碼行數:22,代碼來源:PlayerActivity.java

示例7: initializePlayer

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的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

示例8: getMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
public MediaSource getMediaSource(boolean preview) {
    switch (streamType) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, new DefaultDataSourceFactory(context, null,
                    getHttpDataSourceFactory(preview)),
                    new DefaultSsChunkSource.Factory(getDataSourceFactory(preview)),
                    mainHandler, null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri,
                    new DefaultDataSourceFactory(context, null,
                            getHttpDataSourceFactory(preview)),
                    new DefaultDashChunkSource.Factory(getDataSourceFactory(preview)),
                    mainHandler, null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, getDataSourceFactory(preview), mainHandler, null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, getDataSourceFactory(preview),
                    new DefaultExtractorsFactory(), mainHandler, null);
        default: {
            throw new IllegalStateException("Unsupported type: " + streamType);
        }
    }
}
 
開發者ID:rubensousa,項目名稱:PreviewSeekBar,代碼行數:24,代碼來源:ExoPlayerMediaSourceBuilder.java

示例9: startPlayer

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的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

示例10: setExoViewSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的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

示例11: initializePlayer

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
private void initializePlayer() {
    if (player == null) {
        trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
        player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
        player.addListener(this);
        DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(context,
                Util.getUserAgent(context, "testApp"), bandwidthMeter);

        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        ExtractorMediaSource videoSource = new ExtractorMediaSource(Uri.parse(videoUrl),
                dataSourceFactory, extractorsFactory, null, null);
        simpleExoPlayerView.setPlayer(player);
        player.setPlayWhenReady(true);

        boolean haveResumePosition = resumeWindow != C.INDEX_UNSET;
        if (haveResumePosition) {
            Log.d(TAG, "Have Resume position true!" + resumePosition);
            player.seekTo(resumeWindow, resumePosition);
        }

        player.prepare(videoSource, !haveResumePosition, false);

    }
}
 
開發者ID:riggaroo,項目名稱:android-arch-components-lifecycle,代碼行數:25,代碼來源:VideoPlayerComponent.java

示例12: newMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
protected MediaSource newMediaSource(Context context, String url, int type, Handler handler) {
    boolean hls = false;
    boolean localFile = url.startsWith("file://");
    if (!localFile) {
        try {
            hls = type == MediaId.TYPE_VIDEO || Uri.parse(url).getPath().endsWith(".m3u8");
        } catch (Exception ignore) {
        }
    }
    // expecting MP3 here ... otherwise HLS
    if ((localFile || type == MediaId.TYPE_AUDIO) && !hls) {
        return new ExtractorMediaSource(Uri.parse(url),
                buildDataSourceFactory(context, true, !localFile),
                new DefaultExtractorsFactory(),
                handler,
                this);
    } else {
        return new HlsMediaSource(Uri.parse(url),
                buildDataSourceFactory(context, true, true),
                handler,
                this);
    }
}
 
開發者ID:lifechurch,項目名稱:nuclei-android,代碼行數:24,代碼來源:ExoPlayerPlayback.java

示例13: buildMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {

        int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
                : uri.getLastPathSegment());
        switch (type) {
            case C.TYPE_SS:
                return new SsMediaSource(uri, buildDataSourceFactory(false),
                        new DefaultSsChunkSource.Factory(mMediaDataSourceFactory), mMainHandler, mEventLogger);
            case C.TYPE_DASH:
                return new DashMediaSource(uri, buildDataSourceFactory(false),
                        new DefaultDashChunkSource.Factory(mMediaDataSourceFactory), mMainHandler, mEventLogger);
            case C.TYPE_HLS:
                return new HlsMediaSource(uri, mMediaDataSourceFactory, mMainHandler, mEventLogger);
            case C.TYPE_OTHER:
                return new ExtractorMediaSource(uri, mMediaDataSourceFactory, new DefaultExtractorsFactory(),
                        mMainHandler, mEventLogger);
            default: {
                throw new IllegalStateException("Unsupported type: " + type);
            }
        }
    }
 
開發者ID:huyongli,項目名稱:TigerVideo,代碼行數:22,代碼來源:VideoExoPlayer.java

示例14: buildMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
    int type = Util.inferContentType(!TextUtils.isEmpty(overrideExtension) ? "." + overrideExtension
            : uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, new DefaultDataSourceFactory(context, userAgent),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, new DefaultDataSourceFactory(context, userAgent),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), mainHandler, eventLogger);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, mainHandler, eventLogger);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    mainHandler, eventLogger);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
開發者ID:jcodeing,項目名稱:K-Sonic,代碼行數:21,代碼來源:KExoMediaPlayer.java

示例15: buildMediaSource

import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; //導入依賴的package包/類
private MediaSource buildMediaSource(Uri uri) {
    int type = Util.inferContentType(uri.getLastPathSegment());
    switch (type) {
        case C.TYPE_SS:
            return new SsMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultSsChunkSource.Factory(mediaDataSourceFactory), new Handler(), null);
        case C.TYPE_DASH:
            return new DashMediaSource(uri, buildDataSourceFactory(false),
                    new DefaultDashChunkSource.Factory(mediaDataSourceFactory), new Handler(), null);
        case C.TYPE_HLS:
            return new HlsMediaSource(uri, mediaDataSourceFactory, new Handler(), null);
        case C.TYPE_OTHER:
            return new ExtractorMediaSource(uri, mediaDataSourceFactory, new DefaultExtractorsFactory(),
                    new Handler(), null);
        default: {
            throw new IllegalStateException("Unsupported type: " + type);
        }
    }
}
 
開發者ID:warnerbros,項目名稱:cpe-manifest-android-experience,代碼行數:20,代碼來源:ECVideoViewFragment.java


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