Java Code Examples for com.google.android.exoplayer2.source.ExtractorMediaSource#Factory
The following examples show how to use
com.google.android.exoplayer2.source.ExtractorMediaSource#Factory .
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: AdsMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Constructs a new source that inserts ads linearly with the content specified by {@code * contentMediaSource}. Ad media is loaded using {@link ExtractorMediaSource}. * * @param contentMediaSource The {@link MediaSource} providing the content to play. * @param dataSourceFactory Factory for data sources used to load ad media. * @param adsLoader The loader for ads. * @param adUiViewGroup A {@link ViewGroup} on top of the player that will show any ad UI. * @param eventHandler A handler for events. May be null if delivery of events is not required. * @param eventListener A listener of events. May be null if delivery of events is not required. * @deprecated To listen for ad load error events, add a listener via {@link * #addEventListener(Handler, MediaSourceEventListener)} and check for {@link * AdLoadException}s in {@link MediaSourceEventListener#onLoadError(int, MediaPeriodId, * LoadEventInfo, MediaLoadData, IOException, boolean)}. Individual ads loader implementations * should expose ad interaction events, if applicable. */ @Deprecated public AdsMediaSource( MediaSource contentMediaSource, DataSource.Factory dataSourceFactory, AdsLoader adsLoader, ViewGroup adUiViewGroup, @Nullable Handler eventHandler, @Nullable EventListener eventListener) { this( contentMediaSource, new ExtractorMediaSource.Factory(dataSourceFactory), adsLoader, adUiViewGroup, eventHandler, eventListener); }
Example 2
Source File: AdsMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Constructs a new source that inserts ads linearly with the content specified by {@code * contentMediaSource}. Ad media is loaded using {@link ExtractorMediaSource}. * * @param contentMediaSource The {@link MediaSource} providing the content to play. * @param dataSourceFactory Factory for data sources used to load ad media. * @param adsLoader The loader for ads. * @param adUiViewGroup A {@link ViewGroup} on top of the player that will show any ad UI. * @param eventHandler A handler for events. May be null if delivery of events is not required. * @param eventListener A listener of events. May be null if delivery of events is not required. * @deprecated To listen for ad load error events, add a listener via {@link * #addEventListener(Handler, MediaSourceEventListener)} and check for {@link * AdLoadException}s in {@link MediaSourceEventListener#onLoadError(int, MediaPeriodId, * LoadEventInfo, MediaLoadData, IOException, boolean)}. Individual ads loader implementations * should expose ad interaction events, if applicable. */ @Deprecated public AdsMediaSource( MediaSource contentMediaSource, DataSource.Factory dataSourceFactory, AdsLoader adsLoader, ViewGroup adUiViewGroup, @Nullable Handler eventHandler, @Nullable EventListener eventListener) { this( contentMediaSource, new ExtractorMediaSource.Factory(dataSourceFactory), adsLoader, adUiViewGroup, eventHandler, eventListener); }
Example 3
Source File: AdsMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Constructs a new source that inserts ads linearly with the content specified by {@code * contentMediaSource}. Ad media is loaded using {@link ExtractorMediaSource}. * * @param contentMediaSource The {@link MediaSource} providing the content to play. * @param dataSourceFactory Factory for data sources used to load ad media. * @param adsLoader The loader for ads. * @param adUiViewGroup A {@link ViewGroup} on top of the player that will show any ad UI. */ public AdsMediaSource( MediaSource contentMediaSource, DataSource.Factory dataSourceFactory, AdsLoader adsLoader, ViewGroup adUiViewGroup) { this( contentMediaSource, new ExtractorMediaSource.Factory(dataSourceFactory), adsLoader, adUiViewGroup, /* eventHandler= */ null, /* eventListener= */ null); }
Example 4
Source File: AdsMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Constructs a new source that inserts ads linearly with the content specified by {@code * contentMediaSource}. Ad media is loaded using {@link ExtractorMediaSource}. * * @param contentMediaSource The {@link MediaSource} providing the content to play. * @param dataSourceFactory Factory for data sources used to load ad media. * @param adsLoader The loader for ads. * @param adUiViewGroup A {@link ViewGroup} on top of the player that will show any ad UI. */ public AdsMediaSource( MediaSource contentMediaSource, DataSource.Factory dataSourceFactory, AdsLoader adsLoader, ViewGroup adUiViewGroup) { this( contentMediaSource, new ExtractorMediaSource.Factory(dataSourceFactory), adsLoader, adUiViewGroup, /* eventHandler= */ null, /* eventListener= */ null); }
Example 5
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 6
Source File: MediaSourceFactory.java From no-player with Apache License 2.0 | 5 votes |
private MediaSource createH264MediaSource(DefaultDataSourceFactory defaultDataSourceFactory, Uri uri, MediaSourceEventListener mediaSourceEventListener) { ExtractorMediaSource.Factory factory = new ExtractorMediaSource.Factory(defaultDataSourceFactory); ExtractorMediaSource extractorMediaSource = factory .setExtractorsFactory(new DefaultExtractorsFactory()) .createMediaSource(uri); extractorMediaSource.addEventListener(handler, mediaSourceEventListener); return extractorMediaSource; }
Example 7
Source File: YouTubePlayerV2Fragment.java From SkyTube with GNU General Public License v3.0 | 5 votes |
/** * Play video. * * @param videoUri The Uri of the video that is going to be played. */ private void playVideo(Uri videoUri) { DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(getContext(), "ST. Agent", new DefaultBandwidthMeter()); ExtractorMediaSource.Factory extMediaSourceFactory = new ExtractorMediaSource.Factory(dataSourceFactory); ExtractorMediaSource mediaSource = extMediaSourceFactory.createMediaSource(videoUri); player.prepare(mediaSource); if (playerInitialPosition > 0) player.seekTo(playerInitialPosition); }