com.google.android.exoplayer2.DefaultLoadControl Java Examples
The following examples show how to use
com.google.android.exoplayer2.DefaultLoadControl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoActivity.java From arcusandroid with Apache License 2.0 | 7 votes |
private void initializePlayer() { CameraPreviewGetter.instance().pauseUpdates(); PlayerView video = findViewById(R.id.video_view); video.setUseController(playbackModel.getType() == PlaybackModel.PlaybackType.CLIP); video.requestFocus(); TrackSelection.Factory trackSelectionFactory = new AdaptiveTrackSelection.Factory(DEFAULT_BANDWIDTH_METER); player = ExoPlayerFactory.newSimpleInstance( new DefaultRenderersFactory(this), new DefaultTrackSelector(trackSelectionFactory), new DefaultLoadControl() ); video.setPlayer(player); String userAgent = Util.getUserAgent(this, getPackageName()); DataSource.Factory dsf = new DefaultDataSourceFactory(this, userAgent); MediaSource mediaSource = new HlsMediaSource.Factory(dsf).createMediaSource(Uri.parse(playbackModel.getUrl())); player.prepare(mediaSource); player.addListener(eventListener); player.setPlayWhenReady(playWhenReady); player.seekTo(currentWindow, playbackPosition); }
Example #2
Source File: ExoMediaPlayer.java From ExoMedia with Apache License 2.0 | 6 votes |
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); DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = generateDrmSessionManager(); rendererProvider.setDrmSessionManager(drmSessionManager); 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); analyticsCollector = new AnalyticsCollector.Factory().createAnalyticsCollector(player, Clock.DEFAULT); player.addListener(analyticsCollector); setupDamSessionManagerAnalytics(drmSessionManager); }
Example #3
Source File: VideoPlayer.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
private void setExoViewSource(@NonNull VideoSlide videoSource, boolean autoplay) 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); exoPlayer.addListener(new ExoPlayerListener(window)); //noinspection ConstantConditions exoView.setPlayer(exoPlayer); DefaultDataSourceFactory defaultDataSourceFactory = new DefaultDataSourceFactory(getContext(), "GenericUserAgent", null); AttachmentDataSourceFactory attachmentDataSourceFactory = new AttachmentDataSourceFactory(getContext(), defaultDataSourceFactory, null); ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); MediaSource mediaSource = new ExtractorMediaSource(videoSource.getUri(), attachmentDataSourceFactory, extractorsFactory, null, null); exoPlayer.prepare(mediaSource); exoPlayer.setPlayWhenReady(autoplay); }
Example #4
Source File: AudioSlidePlayer.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
public void requestDuration() { try { LoadControl loadControl = new DefaultLoadControl.Builder().setBufferDurationsMs(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE).createDefaultLoadControl(); durationCalculator = ExoPlayerFactory.newSimpleInstance(context, new DefaultRenderersFactory(context), new DefaultTrackSelector(), loadControl); durationCalculator.setPlayWhenReady(false); durationCalculator.addListener(new Player.EventListener() { @Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if (playbackState == Player.STATE_READY) { Util.runOnMain(() -> { Log.d(TAG, "request duration " + durationCalculator.getDuration()); getListener().onReceivedDuration(Long.valueOf(durationCalculator.getDuration()).intValue()); durationCalculator.release(); durationCalculator.removeListener(this); durationCalculator = null; }); } } }); durationCalculator.prepare(createMediaSource(slide.getUri())); } catch (Exception e) { Log.w(TAG, e); getListener().onReceivedDuration(0); } }
Example #5
Source File: KExoMediaPlayer.java From K-Sonic with MIT License | 6 votes |
public KExoMediaPlayer(Context context) { this.context = context.getApplicationContext(); // =========@Init@========= 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); }
Example #6
Source File: MediaPlayback21.java From Melophile with Apache License 2.0 | 6 votes |
@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(); }
Example #7
Source File: ExoPlayerHelper.java From ExoPlayer-Wrapper with Apache License 2.0 | 6 votes |
private void init() { // Measures bandwidth during playback. Can be null if not required. DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter.Builder(mContext).build(); // Produces DataSource instances through which media data is loaded. mDataSourceFactory = new DefaultDataSourceFactory(mContext, Util.getUserAgent(mContext, mContext.getString(R.string.app_name)), bandwidthMeter); // LoadControl that controls when the MediaSource buffers more media, and how much media is buffered. // LoadControl is injected when the player is created. //removed deprecated DefaultLoadControl creation method DefaultLoadControl.Builder builder = new DefaultLoadControl.Builder(); builder.setAllocator(new DefaultAllocator(true, 2 * 1024 * 1024)); builder.setBufferDurationsMs(5000, 5000, 5000, 5000); builder.setPrioritizeTimeOverSizeThresholds(true); mLoadControl = builder.createDefaultLoadControl(); }
Example #8
Source File: MainActivity.java From ExoplayerExample with The Unlicense | 6 votes |
private void prepareExoPlayerFromRawResourceUri(Uri uri){ exoPlayer = ExoPlayerFactory.newSimpleInstance(this, new DefaultTrackSelector(null), new DefaultLoadControl()); exoPlayer.addListener(eventListener); DataSpec dataSpec = new DataSpec(uri); final RawResourceDataSource rawResourceDataSource = new RawResourceDataSource(this); try { rawResourceDataSource.open(dataSpec); } catch (RawResourceDataSource.RawResourceDataSourceException e) { e.printStackTrace(); } DataSource.Factory factory = new DataSource.Factory() { @Override public DataSource createDataSource() { return rawResourceDataSource; } }; MediaSource audioSource = new ExtractorMediaSource(rawResourceDataSource.getUri(), factory, new DefaultExtractorsFactory(), null, null); exoPlayer.prepare(audioSource); initMediaControls(); }
Example #9
Source File: MainActivity.java From ExoplayerExample with The Unlicense | 6 votes |
/** * Prepares exoplayer for audio playback from a remote URL audiofile. Should work with most * popular audiofile types (.mp3, .m4a,...) * @param uri Provide a Uri in a form of Uri.parse("http://blabla.bleble.com/blublu.mp3) */ private void prepareExoPlayerFromURL(Uri uri){ TrackSelector trackSelector = new DefaultTrackSelector(); LoadControl loadControl = new DefaultLoadControl(); exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl); DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "exoplayer2example"), null); ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory(); MediaSource audioSource = new ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null); exoPlayer.addListener(eventListener); exoPlayer.prepare(audioSource); initMediaControls(); }
Example #10
Source File: MainActivity.java From ExoplayerExample with The Unlicense | 6 votes |
/** * Prepares exoplayer for audio playback from a local file * @param uri */ private void prepareExoPlayerFromFileUri(Uri uri){ exoPlayer = ExoPlayerFactory.newSimpleInstance(this, new DefaultTrackSelector(null), new DefaultLoadControl()); exoPlayer.addListener(eventListener); DataSpec dataSpec = new DataSpec(uri); final FileDataSource fileDataSource = new FileDataSource(); try { fileDataSource.open(dataSpec); } catch (FileDataSource.FileDataSourceException e) { e.printStackTrace(); } DataSource.Factory factory = new DataSource.Factory() { @Override public DataSource createDataSource() { return fileDataSource; } }; MediaSource audioSource = new ExtractorMediaSource(fileDataSource.getUri(), factory, new DefaultExtractorsFactory(), null, null); exoPlayer.prepare(audioSource); initMediaControls(); }
Example #11
Source File: ExoMediaPlayer.java From DKVideoPlayer with Apache License 2.0 | 6 votes |
@Override public void initPlayer() { mInternalPlayer = new SimpleExoPlayer.Builder( mAppContext, mRenderersFactory == null ? mRenderersFactory = new DefaultRenderersFactory(mAppContext) : mRenderersFactory, mTrackSelector == null ? mTrackSelector = new DefaultTrackSelector(mAppContext) : mTrackSelector, mLoadControl == null ? mLoadControl = new DefaultLoadControl() : mLoadControl, DefaultBandwidthMeter.getSingletonInstance(mAppContext), Util.getLooper(), new AnalyticsCollector(Clock.DEFAULT), /* useLazyPreparation= */ true, Clock.DEFAULT) .build(); setOptions(); //æ’放器日志 if (VideoViewManager.getConfig().mIsEnableLog && mTrackSelector instanceof MappingTrackSelector) { mInternalPlayer.addAnalyticsListener(new EventLogger((MappingTrackSelector) mTrackSelector, "ExoPlayer")); } mInternalPlayer.addListener(this); mInternalPlayer.addVideoListener(this); }
Example #12
Source File: ReactExoplayerViewManager.java From react-native-video with MIT License | 6 votes |
@ReactProp(name = PROP_BUFFER_CONFIG) public void setBufferConfig(final ReactExoplayerView videoView, @Nullable ReadableMap bufferConfig) { int minBufferMs = DefaultLoadControl.DEFAULT_MIN_BUFFER_MS; int maxBufferMs = DefaultLoadControl.DEFAULT_MAX_BUFFER_MS; int bufferForPlaybackMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS; int bufferForPlaybackAfterRebufferMs = DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS; if (bufferConfig != null) { minBufferMs = bufferConfig.hasKey(PROP_BUFFER_CONFIG_MIN_BUFFER_MS) ? bufferConfig.getInt(PROP_BUFFER_CONFIG_MIN_BUFFER_MS) : minBufferMs; maxBufferMs = bufferConfig.hasKey(PROP_BUFFER_CONFIG_MAX_BUFFER_MS) ? bufferConfig.getInt(PROP_BUFFER_CONFIG_MAX_BUFFER_MS) : maxBufferMs; bufferForPlaybackMs = bufferConfig.hasKey(PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_MS) ? bufferConfig.getInt(PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_MS) : bufferForPlaybackMs; bufferForPlaybackAfterRebufferMs = bufferConfig.hasKey(PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS) ? bufferConfig.getInt(PROP_BUFFER_CONFIG_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS) : bufferForPlaybackAfterRebufferMs; videoView.setBufferConfig(minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs); } }
Example #13
Source File: ExoHostedTest.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
@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; }
Example #14
Source File: ExoMediaPlayer.java From PainlessMusicPlayer with Apache License 2.0 | 5 votes |
@Override public void init(@NonNull final Context context) { final TrackSelector trackSelector = new DefaultTrackSelector(); exoPlayer = ExoPlayerFactory.newSimpleInstance( new DefaultRenderersFactory(context), trackSelector, new DefaultLoadControl()); exoPlayer.addListener(mEventListener); exoPlayer.addAudioDebugListener(mAudioRendererEventListener); dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context, "Painless Music Player")); }
Example #15
Source File: ExoPlayerAdapter.java From leanback-showcase with Apache License 2.0 | 5 votes |
/** * Constructor. */ public ExoPlayerAdapter(Context context) { mContext = context; mPlayer = ExoPlayerFactory.newSimpleInstance(mContext, new DefaultTrackSelector(), new DefaultLoadControl()); mPlayer.addListener(this); }
Example #16
Source File: VideoPlayer.java From bcm-android with GNU General Public License v3.0 | 5 votes |
public VideoPlayer(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); inflate(context, R.layout.video_player_layout, this); BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter); TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); LoadControl loadControl = new DefaultLoadControl(); RenderersFactory renderersFactory = new DefaultRenderersFactory(getContext()); this.exoView = findViewById(R.id.video_view); this.exoPlayer = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl); this.exoPlayer.addListener(new ExoPlayerListener()); if (exoView != null) { exoView.setPlayer(exoPlayer); } this.audioView = findViewById(R.id.audio_btn); this.audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // VolumeChangeObserver.INSTANCE.registerReceiver(); // VolumeChangeObserver.INSTANCE.addCallback(observerCallback); audioVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); exoPlayer.setVolume(audioVolume); if (audioVolume == 0) { audioView.setImageResource(R.drawable.common_video_player_mute_icon); isMuted = true; } }
Example #17
Source File: YouTubePlayerV2Fragment.java From SkyTube with GNU General Public License v3.0 | 5 votes |
private SimpleExoPlayer createExoPlayer() { DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(); DefaultTrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); Context context = getContext(); DefaultRenderersFactory defaultRenderersFactory = new DefaultRenderersFactory(context); return ExoPlayerFactory.newSimpleInstance(getContext(), defaultRenderersFactory, trackSelector, new DefaultLoadControl(), null, bandwidthMeter); }
Example #18
Source File: ExoPlayerCreator.java From no-player with Apache License 2.0 | 5 votes |
@NonNull public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator, DefaultDrmSessionEventListener drmSessionEventListener, MediaCodecSelector mediaCodecSelector, TrackSelector trackSelector) { DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = drmSessionCreator.create(drmSessionEventListener); SubtitleDecoderFactory subtitleDecoderFactory = new NoPlayerSubtitleDecoderFactory(); RenderersFactory renderersFactory = new SimpleRenderersFactory( context, EXTENSION_RENDERER_MODE_OFF, DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS, mediaCodecSelector, subtitleDecoderFactory ); DefaultLoadControl loadControl = new DefaultLoadControl(); return ExoPlayerFactory.newSimpleInstance(context, renderersFactory, trackSelector, loadControl, drmSessionManager); }
Example #19
Source File: VideoDetailsFragment.java From Loop with Apache License 2.0 | 5 votes |
private void setUpExoPlayer(){ // Create a default TrackSelector TrackSelector trackSelector = createTrackSelector(); // Create a default LoadControl LoadControl loadControl = new DefaultLoadControl(); // Create the player exoPlayer = ExoPlayerFactory.newSimpleInstance(getContext(), trackSelector, loadControl); resumeLocalVideo(); exoPlayer.addListener(exoPlayerEventListener); }
Example #20
Source File: VodPlaybackFragment.java From xipl with Apache License 2.0 | 5 votes |
/** * Sets up the usage of the internal player used by the library. */ protected void configureInternalPlayer() { Bundle arguments = getArguments(); String url = arguments.getString(VodTvSectionFragment.AV_CONTENT_LINK_BUNDLE); // Configure the ExoPlayer instance that will be used to play the media DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getActivity(), Util.getUserAgent(getActivity(), getActivity().getApplicationInfo().loadLabel(getActivity().getPackageManager()).toString())); mSimpleExoPlayer = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(getActivity()), new DefaultTrackSelector(), new DefaultLoadControl()); ExtractorMediaSource.Factory factory = new ExtractorMediaSource.Factory(dataSourceFactory); Uri uri = Uri.parse(url); mSimpleExoPlayer.prepare(factory.createMediaSource(uri)); mSimpleExoPlayer.addListener(new Player.DefaultEventListener() { @Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { super.onPlayerStateChanged(playWhenReady, playbackState); if (playbackState == Player.STATE_READY && mPlayerGlue.getSeekProvider() == null) { mPlayerGlue.setSeekProvider(new ProviderPlaybackSeekDataProvider(mPlayerGlue.getDuration())); // Force content to fit to screen if wanted. if (getVodProperties().isVideoFitToScreen()) { DisplayMetrics displayMetrics = getActivity().getResources().getDisplayMetrics(); mPlayerGlue.getPlayerAdapter().getCallback().onVideoSizeChanged(mPlayerGlue.getPlayerAdapter(), displayMetrics.widthPixels, displayMetrics.heightPixels); } } } }); // Configure Leanback for playback. Use the updatePeriodMs used before in ExoPlayerAdapter LeanbackPlayerAdapter playerAdapter = new LeanbackPlayerAdapter(getActivity(), mSimpleExoPlayer, 16); mPlayerGlue = new PlaybackTransportControlGlue<>(getActivity(), playerAdapter); mPlayerGlue.setHost(new VideoSupportFragmentGlueHost(this)); mPlayerGlue.setTitle(arguments.getString(VodTvSectionFragment.AV_CONTENT_TITLE_BUNDLE)); mPlayerGlue.setSubtitle(arguments.getString(VodTvSectionFragment.AV_CONTENT_GROUP_BUNDLE)); setBackgroundType(BG_LIGHT); mPlayerGlue.playWhenPrepared(); }
Example #21
Source File: ExoPlayerAdapter.java From tv-samples with Apache License 2.0 | 5 votes |
/** * Constructor. */ public ExoPlayerAdapter(Context context) { mContext = context; mPlayer = ExoPlayerFactory.newSimpleInstance(mContext, new DefaultTrackSelector(), new DefaultLoadControl()); mPlayer.addListener(this); }
Example #22
Source File: Config.java From ARVI with Apache License 2.0 | 5 votes |
public Builder() { this.extensionMode = EXTENSION_RENDERER_MODE_OFF; this.meter = new BaseMeter<>(bandwidthMeter, bandwidthMeter); this.loadControl = new DefaultLoadControl(); this.mediaSourceBuilder = MediaSourceBuilder.DEFAULT; this.drmSessionManagers = new DrmSessionManager[0]; this.cache = null; this.dataSourceFactory = null; }
Example #23
Source File: ExoFFmpegPlayer.java From DanDanPlayForAndroid with MIT License | 5 votes |
public ExoFFmpegPlayer(Context context) { super(context, new SimpleRendersFactory(context), new DefaultTrackSelector(), new DefaultLoadControl(), null, new DefaultBandwidthMeter.Builder().build(), new AnalyticsCollector.Factory(), Clock.DEFAULT, Util.getLooper()); }
Example #24
Source File: MainActivity.java From ExoplayerExample with The Unlicense | 5 votes |
private void prepareExoPlayerFromByteArray(byte[] data){ exoPlayer = ExoPlayerFactory.newSimpleInstance(this, new DefaultTrackSelector(null), new DefaultLoadControl()); exoPlayer.addListener(eventListener); final MByteArrayDataSource byteArrayDataSource = new MByteArrayDataSource(data); Log.i(TAG,"ByteArrayDataSource constructed."); /* DataSpec dataSpec = new DataSpec(byteArrayDataSource.getUri()); try { byteArrayDataSource.open(dataSpec); } catch (IOException e) { e.printStackTrace(); } */ DataSource.Factory factory = new DataSource.Factory() { @Override public DataSource createDataSource() { return byteArrayDataSource; } }; Log.i(TAG,"DataSource.Factory constructed."); MediaSource audioSource = new ExtractorMediaSource(byteArrayDataSource.getUri(), factory, new DefaultExtractorsFactory(),null,null); Log.i(TAG,"Audio source constructed."); exoPlayer.prepare(audioSource); initMediaControls(); }
Example #25
Source File: ExoMedia.java From QSVideoPlayer with Apache License 2.0 | 5 votes |
@Override public boolean doPrepar(Context context, String url, Map<String, String> headers, Object... objects) { release(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER); DefaultTrackSelector trackSelector = new DefaultTrackSelector(mainThreadHandler, videoTrackSelectionFactory); simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(context, trackSelector, new DefaultLoadControl(), null, false); simpleExoPlayer.setPlayWhenReady(true); MediaSource mediaSource = buildMediaSource(context, Uri.parse(url)); simpleExoPlayer.addListener(ExoMedia.this); simpleExoPlayer.setVideoListener(ExoMedia.this); simpleExoPlayer.prepare(mediaSource, true, true); return true; }
Example #26
Source File: DashTest.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
@Override protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface, MappingTrackSelector trackSelector, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) { SimpleExoPlayer player = new DebugSimpleExoPlayer(host, trackSelector, new DefaultLoadControl(), drmSessionManager); player.setVideoSurface(surface); return player; }
Example #27
Source File: ExoFFmpegPlayer.java From DanDanPlayForAndroid with MIT License | 5 votes |
public ExoFFmpegPlayer(Context context, TrackSelector trackSelector) { super(context, new SimpleRendersFactory(context), trackSelector, new DefaultLoadControl(), null, new DefaultBandwidthMeter.Builder().build(), new AnalyticsCollector.Factory(), Clock.DEFAULT, Util.getLooper()); }
Example #28
Source File: VideoActivity.java From evercam-android with GNU Affero General Public License v3.0 | 4 votes |
private void preparePlayer() { if (player == null){ DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null; @SimpleExoPlayer.ExtensionRendererMode int extensionRendererMode = ((EvercamPlayApplication) getApplication()).useExtensionRenderers() ? (false ? SimpleExoPlayer.EXTENSION_RENDERER_MODE_PREFER : SimpleExoPlayer.EXTENSION_RENDERER_MODE_ON) : SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF; TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(), drmSessionManager, extensionRendererMode); player.addListener(this); eventLogger = new EventLogger(trackSelector); eventLogger.addListener(this); player.addListener(eventLogger); // player.setAudioDebugListener(eventLogger); player.setVideoDebugListener(eventLogger); player.setMetadataOutput(eventLogger); Uri hlsUrl = Uri.parse(evercamCamera.getHlsUrl()); MediaSource mediaSource = new HlsMediaSource(hlsUrl, mediaDataSourceFactory, mainHandler, eventLogger); boolean haveResumePosition = resumeWindow != C.INDEX_UNSET; if (haveResumePosition) { player.seekTo(resumeWindow, resumePosition); } player.prepare(mediaSource, !haveResumePosition, false); player.setPlayWhenReady(true); player.setVideoSurface(surface); }else{ releasePlayer(); preparePlayer(); } /*DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null; @SimpleExoPlayer.ExtensionRendererMode int extensionRendererMode = ((EvercamPlayApplication) getApplication()).useExtensionRenderers() ? (false ? SimpleExoPlayer.EXTENSION_RENDERER_MODE_PREFER : SimpleExoPlayer.EXTENSION_RENDERER_MODE_ON) : SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF; TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, new DefaultLoadControl(), drmSessionManager, extensionRendererMode); player.addListener(this); eventLogger = new EventLogger(trackSelector); eventLogger.addListener(this); player.addListener(eventLogger); // player.setAudioDebugListener(eventLogger); player.setVideoDebugListener(eventLogger); player.setMetadataOutput(eventLogger); Uri hlsUrl = Uri.parse(evercamCamera.getHlsUrl()); MediaSource mediaSource = new HlsMediaSource(hlsUrl, mediaDataSourceFactory, mainHandler, eventLogger); player.prepare(mediaSource); player.setPlayWhenReady(true); player.setVideoSurface(surface);*/ }
Example #29
Source File: QueuedExoPlayer.java From Jockey with Apache License 2.0 | 4 votes |
public QueuedExoPlayer(Context context) { mContext = context; mState = ExoPlayerState.IDLE; mQueue = Collections.emptyList(); mSourceFactory = new DefaultDataSourceFactory(mContext, USER_AGENT); mExtractorsFactory = new DefaultExtractorsFactory(); RenderersFactory renderersFactory = new DefaultRenderersFactory(mContext); TrackSelector trackSelector = new DefaultTrackSelector(new FixedTrackSelection.Factory()); LoadControl loadControl = new DefaultLoadControl(); SimpleExoPlayer baseInstance = ExoPlayerFactory.newSimpleInstance( renderersFactory, trackSelector, loadControl); mExoPlayer = new EqualizedExoPlayer(context, baseInstance); mExoPlayer.addListener(new Player.EventListener() { @Override public void onLoadingChanged(boolean isLoading) { Timber.i("onLoadingChanged (%b)", isLoading); } @Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { Timber.i("onPlayerStateChanged"); QueuedExoPlayer.this.onPlayerStateChanged(playbackState); } @Override public void onRepeatModeChanged(int repeatMode) { Timber.i("onRepeatModeChanged (%d)", repeatMode); } @Override public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) { Timber.i("onShuffleModeEnabledChanged (%b)", shuffleModeEnabled); } @Override public void onTimelineChanged(Timeline timeline, Object manifest) { Timber.i("onTimelineChanged"); dispatchDurationUpdateIfNeeded(); } @Override public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { Timber.i("onTracksChanged"); } @Override public void onPlayerError(ExoPlaybackException error) { Timber.i("onPlayerError"); QueuedExoPlayer.this.onPlayerError(error); } @Override public void onPositionDiscontinuity(int reason) { Timber.i("onPositionDiscontinuity"); QueuedExoPlayer.this.onPositionDiscontinuity(reason); } @Override public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) { Timber.i("onPlaybackParametersChanged"); } @Override public void onSeekProcessed() { Timber.i("okSeekProcessed"); } }); }
Example #30
Source File: BufferSizeAdaptationBuilder.java From Telegram with GNU General Public License v2.0 | 4 votes |
/** * Builds player components for buffer size based track adaptation. * * @return A pair of a {@link TrackSelection.Factory} and a {@link LoadControl}, which should be * used to construct the player. */ public Pair<TrackSelection.Factory, LoadControl> buildPlayerComponents() { Assertions.checkArgument(hysteresisBufferMs < maxBufferMs - minBufferMs); Assertions.checkState(!buildCalled); buildCalled = true; DefaultLoadControl.Builder loadControlBuilder = new DefaultLoadControl.Builder() .setTargetBufferBytes(/* targetBufferBytes = */ Integer.MAX_VALUE) .setBufferDurationsMs( /* minBufferMs= */ maxBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs); if (allocator != null) { loadControlBuilder.setAllocator(allocator); } TrackSelection.Factory trackSelectionFactory = new TrackSelection.Factory() { @Override public @NullableType TrackSelection[] createTrackSelections( @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) { return TrackSelectionUtil.createTrackSelectionsForDefinitions( definitions, definition -> new BufferSizeAdaptiveTrackSelection( definition.group, definition.tracks, bandwidthMeter, minBufferMs, maxBufferMs, hysteresisBufferMs, startUpBandwidthFraction, startUpMinBufferForQualityIncreaseMs, dynamicFormatFilter, clock)); } }; return Pair.create(trackSelectionFactory, loadControlBuilder.createDefaultLoadControl()); }