/** * Instantiates a new Encrypted file data source factory. * * @param context the context * @param cipher the cipher * @param secretKeySpec the secret key spec * @param ivParameterSpec the iv parameter spec * @param listener the listener */ public EncryptedFileDataSourceFactory(Context context, Cipher cipher, SecretKeySpec secretKeySpec, IvParameterSpec ivParameterSpec, TransferListener<? super DataSource> listener) { mCipher = cipher; mSecretKeySpec = secretKeySpec; mIvParameterSpec = ivParameterSpec; mTransferListener = listener; String userAgent = Util.getUserAgent(context, context.getPackageName()); this.context = context.getApplicationContext(); this.baseDataSourceFactory = new DefaultDataSourceFactory(context, userAgent); }
@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; }
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); } } }
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); } }
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); } } }
@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(); }
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); }
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); } }
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); } } }
@Override public void run() { Looper.prepare(); LibvpxVideoRenderer videoRenderer = new LibvpxVideoRenderer(true, 0); DefaultTrackSelector trackSelector = new DefaultTrackSelector(); player = ExoPlayerFactory.newInstance(new Renderer[] {videoRenderer}, trackSelector); player.addListener(this); ExtractorMediaSource mediaSource = new ExtractorMediaSource( uri, new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test"), MatroskaExtractor.FACTORY, null, null); player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer, LibvpxVideoRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER, new VpxVideoSurfaceView(context))); player.prepare(mediaSource); player.setPlayWhenReady(true); Looper.loop(); }
@Override public void run() { Looper.prepare(); LibopusAudioRenderer audioRenderer = new LibopusAudioRenderer(); DefaultTrackSelector trackSelector = new DefaultTrackSelector(); player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector); player.addListener(this); ExtractorMediaSource mediaSource = new ExtractorMediaSource( uri, new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest"), MatroskaExtractor.FACTORY, null, null); player.prepare(mediaSource); player.setPlayWhenReady(true); Looper.loop(); }
@Override public void run() { Looper.prepare(); LibflacAudioRenderer audioRenderer = new LibflacAudioRenderer(); DefaultTrackSelector trackSelector = new DefaultTrackSelector(); player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector); player.addListener(this); ExtractorMediaSource mediaSource = new ExtractorMediaSource( uri, new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest"), MatroskaExtractor.FACTORY, null, null); player.prepare(mediaSource); player.setPlayWhenReady(true); Looper.loop(); }
private void prepare(boolean playWhenReady, boolean resetPosition) { mInvalid = false; if (mQueue == null) { return; } DataSource.Factory srcFactory = new DefaultDataSourceFactory(mContext, USER_AGENT); ExtractorsFactory extFactory = new DefaultExtractorsFactory(); int startingPosition = resetPosition ? 0 : getCurrentPosition(); if (mRepeatOne) { mExoPlayer.prepare(buildRepeatOneMediaSource(srcFactory, extFactory)); } else if (mRepeatAll) { mExoPlayer.prepare(buildRepeatAllMediaSource(srcFactory, extFactory)); } else { mExoPlayer.prepare(buildNoRepeatMediaSource(srcFactory, extFactory)); } mExoPlayer.seekTo(mQueueIndex, startingPosition); mExoPlayer.setPlayWhenReady(playWhenReady); }
@Override protected MediaSource buildSource(HostActivity host, String userAgent, TransferListener<? super DataSource> mediaTransferListener) { DataSource.Factory manifestDataSourceFactory = dataSourceFactory != null ? dataSourceFactory : new DefaultDataSourceFactory(host, userAgent); DataSource.Factory mediaDataSourceFactory = dataSourceFactory != null ? dataSourceFactory : new DefaultDataSourceFactory(host, userAgent, mediaTransferListener); Uri manifestUri = Uri.parse(manifestUrl); DefaultDashChunkSource.Factory chunkSourceFactory = new DefaultDashChunkSource.Factory( mediaDataSourceFactory); return new DashMediaSource.Factory(chunkSourceFactory, manifestDataSourceFactory) .setMinLoadableRetryCount(MIN_LOADABLE_RETRY_COUNT) .setLivePresentationDelayMs(0) .createMediaSource(manifestUri); }
@Override public void run() { Looper.prepare(); LibvpxVideoRenderer videoRenderer = new LibvpxVideoRenderer(true, 0); DefaultTrackSelector trackSelector = new DefaultTrackSelector(); player = ExoPlayerFactory.newInstance(new Renderer[] {videoRenderer}, trackSelector); player.addListener(this); MediaSource mediaSource = new ExtractorMediaSource.Factory( new DefaultDataSourceFactory(context, "ExoPlayerExtVp9Test")) .setExtractorsFactory(MatroskaExtractor.FACTORY) .createMediaSource(uri); player.sendMessages(new ExoPlayer.ExoPlayerMessage(videoRenderer, LibvpxVideoRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER, new VpxVideoSurfaceView(context))); player.prepare(mediaSource); player.setPlayWhenReady(true); Looper.loop(); }
@Override public void run() { Looper.prepare(); LibopusAudioRenderer audioRenderer = new LibopusAudioRenderer(); DefaultTrackSelector trackSelector = new DefaultTrackSelector(); player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector); player.addListener(this); MediaSource mediaSource = new ExtractorMediaSource.Factory( new DefaultDataSourceFactory(context, "ExoPlayerExtOpusTest")) .setExtractorsFactory(MatroskaExtractor.FACTORY) .createMediaSource(uri); player.prepare(mediaSource); player.setPlayWhenReady(true); Looper.loop(); }
@Override public void run() { Looper.prepare(); LibflacAudioRenderer audioRenderer = new LibflacAudioRenderer(); DefaultTrackSelector trackSelector = new DefaultTrackSelector(); player = ExoPlayerFactory.newInstance(new Renderer[] {audioRenderer}, trackSelector); player.addListener(this); MediaSource mediaSource = new ExtractorMediaSource.Factory( new DefaultDataSourceFactory(context, "ExoPlayerExtFlacTest")) .setExtractorsFactory(MatroskaExtractor.FACTORY) .createMediaSource(uri); player.prepare(mediaSource); player.setPlayWhenReady(true); Looper.loop(); }
@Override public MediaSource initMediaSource(Uri uri) { int streamType = VideoPlayUtils.inferContentType(uri); switch (streamType) { case C.TYPE_SS: return new SsMediaSource.Factory(new DefaultSsChunkSource.Factory(getDataSource()), new DefaultDataSourceFactory(context, null, getDataSource())) .setMinLoadableRetryCount(5) .createMediaSource(uri,mainHandler,sourceEventListener); case C.TYPE_DASH: return new DashMediaSource.Factory(new DefaultDashChunkSource.Factory(getDataSource()) ,new DefaultDataSourceFactory(context, null, getDataSource())) .setMinLoadableRetryCount(5) .createMediaSource(uri, mainHandler, sourceEventListener); case C.TYPE_OTHER: return new ExtractorMediaSource.Factory( getDataSource()) .setExtractorsFactory( new DefaultExtractorsFactory()) .setMinLoadableRetryCount(5) .setCustomCacheKey(uri.getPath()) .createMediaSource(uri,mainHandler,null); case C.TYPE_HLS: return new HlsMediaSource.Factory(new DefaultHlsDataSourceFactory( getDataSource())) .setMinLoadableRetryCount(5) .createMediaSource(uri, mainHandler, sourceEventListener); default: throw new IllegalStateException(":Unsupported type: " + streamType); } }
@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); } }
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); } }
@Override protected MediaSource buildSource(HostActivity host, String userAgent, TransferListener<? super DataSource> mediaTransferListener) { DataSource.Factory manifestDataSourceFactory = new DefaultDataSourceFactory(host, userAgent); DataSource.Factory mediaDataSourceFactory = new DefaultDataSourceFactory(host, userAgent, mediaTransferListener); Uri manifestUri = Uri.parse(parameters.manifestUrl); DefaultDashChunkSource.Factory chunkSourceFactory = new DefaultDashChunkSource.Factory( mediaDataSourceFactory); return new DashMediaSource(manifestUri, manifestDataSourceFactory, chunkSourceFactory, MIN_LOADABLE_RETRY_COUNT, 0 /* livePresentationDelayMs */, null, null); }
@Hide public DefaultDataSourceFactory createDefaultDataFactory() { try { return new DefaultDataSourceFactory(BA.applicationContext, Util.getUserAgent(BA.applicationContext, B4AApplication.getLabelName())); } catch (NameNotFoundException e) { throw new RuntimeException(e); } }
/** * 播放启动视频 */ private void startPlayer() { // 0. set player view playerView = (SimpleExoPlayerView) findViewById(R.id.playerView); playerView.setUseController(false); playerView.getKeepScreenOn(); playerView.setResizeMode(RESIZE_MODE_FILL); // 1. Create a default TrackSelector TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter()); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); // 2. Create a default LoadControl loadControl = new DefaultLoadControl(); // 3. Create the mPlayer mPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl); mPlayer.addListener(this); // 4. set player playerView.setPlayer(mPlayer); mPlayer.setPlayWhenReady(true); // 5. prepare to play File file = new File(Constants.FILE_VIDEO_FLODER, "jcode.mp4"); if (file.isFile() && file.exists()) { mUri = Uri.fromFile(file); } else { Toast.makeText(this,"文件未找到",Toast.LENGTH_SHORT).show(); return; } ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, "UserAgent"); videoSource = new ExtractorMediaSource(mUri, dataSourceFactory, extractorsFactory, null, null); // 6. ready to play mPlayer.prepare(videoSource); }
private MediaSource setUpMediaSource(Context context, Uri mediUri) { final String APPLICATION_BASE_USER_AGENT = "YaBaking"; final String userAgent = Util.getUserAgent(context, APPLICATION_BASE_USER_AGENT); return new ExtractorMediaSource( mediUri, new DefaultDataSourceFactory(context, userAgent), new DefaultExtractorsFactory(), null, null); }
public void setupMediaPlayer() { DataSource.Factory dsf = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "R/a/dio-Android-App")); ExtractorsFactory extractors = new DefaultExtractorsFactory(); MediaSource audioSource = new ExtractorMediaSource(Uri.parse(radio_url), dsf, extractors, null, null); if(sep != null) sep.prepare(audioSource); }
public PlayerController(Context context) { this.bandwidthMeter = new DefaultBandwidthMeter(); this.loadControl = new DefaultLoadControl(); this.extractorsFactory = new DefaultExtractorsFactory(); this.trackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter); this.dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context.getApplicationContext(), TAG_NAME), (TransferListener<? super DataSource>) bandwidthMeter); this.trackSelector = new DefaultTrackSelector(trackSelectionFactory); this.player = ExoPlayerFactory.newSimpleInstance(context, this.trackSelector, this.loadControl); this.playerView = new PlayerView(context,this.player); }
private ExoPlayerInstance() { this.context = ExpressApplication.getApplication(); DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter(); mainHandler = new Handler(); defaultExtractorsFactory = new DefaultExtractorsFactory(); mediaDataSourceFactory = new DefaultDataSourceFactory(context, defaultBandwidthMeter, new OkHttpDataSourceFactory(new OkHttpClient.Builder().build(), Util.getUserAgent(context, "Tumbviewer"), defaultBandwidthMeter, CacheControl.FORCE_NETWORK)); TrackSelection.Factory factory = new AdaptiveTrackSelection.Factory(defaultBandwidthMeter); trackSelector = new DefaultTrackSelector(factory); }
private MediaSource getMediaSource(String videoUrl) { DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); // Produces DataSource instances through which media data is loaded. // DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getContext(), Util.getUserAgent(getContext(), "Loop"), bandwidthMeter); DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MAVApplication.getInstance().getApplicationContext(), Util.getUserAgent(MAVApplication.getInstance().getApplicationContext(), "Loop"), bandwidthMeter); // Produces Extractor instances for parsing the media data. ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); // This is the MediaSource representing the media to be played. MediaSource mediaSource = new ExtractorMediaSource(Uri.parse(videoUrl), dataSourceFactory, extractorsFactory, null, null); // Loops the video indefinitely. // LoopingMediaSource loopingSource = new LoopingMediaSource(mediaSource); return mediaSource; }
private MediaSource getMediaSource(String videoUrl) { DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); // Produces DataSource instances through which media data is loaded. // DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "Loop"), bandwidthMeter); DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(MAVApplication.getInstance().getApplicationContext(), Util.getUserAgent(MAVApplication.getInstance().getApplicationContext(), "Loop"), bandwidthMeter); // Produces Extractor instances for parsing the media data. ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); // This is the MediaSource representing the media to be played. MediaSource mediaSource = new ExtractorMediaSource(Uri.parse(videoUrl), dataSourceFactory, extractorsFactory, null, null); // Loops the video indefinitely. // LoopingMediaSource loopingSource = new LoopingMediaSource(mediaSource); return mediaSource; }
public AttachmentDataSourceFactory(@NonNull Context context, @NonNull MasterSecret masterSecret, @NonNull DefaultDataSourceFactory defaultDataSourceFactory, @Nullable TransferListener<? super DataSource> listener) { this.context = context; this.masterSecret = masterSecret; this.defaultDataSourceFactory = defaultDataSourceFactory; this.listener = listener; }
private void initExoPlayer() { DefaultBandwidthMeter bwMeter = new DefaultBandwidthMeter(); AdaptiveTrackSelection.Factory trackFactory = new AdaptiveTrackSelection.Factory(bwMeter); DefaultTrackSelector trackSelector = new DefaultTrackSelector(trackFactory); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector); videoView.setPlayer(player); DataSource.Factory dsFactory = new DefaultDataSourceFactory(getBaseContext(), Util.getUserAgent(this, "Traxy"), bwMeter); ExtractorsFactory exFactory = new DefaultExtractorsFactory(); Uri mediaUri = Uri.parse(entry.getUrl()); MediaSource videoSource = new ExtractorMediaSource(mediaUri, dsFactory, exFactory, null, null); player.prepare(videoSource); }
private MediaSource createMediaSource(Context context, Uri uri) { DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context, context.getPackageName()), bandwidthMeter); DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); return new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setSupportActionBar(toolbar); window = getWindow(); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } channelList = new SortableJsonChannelList(this); // player DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter); TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, getString(R.string.app_name)), bandwidthMeter); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector); player.addListener(bufferingHandler); player.addListener(videoErrorHandler); videoView.setPlayer(player); // pager channelDetailAdapter = new ChannelDetailAdapter( getSupportFragmentManager(), channelList, onItemChangedListener); viewPager.setAdapter(channelDetailAdapter); viewPager.addOnPageChangeListener(onPageChangeListener); viewPager.setOnClickListener(view -> mContentView.performClick()); parseIntent(getIntent()); }