本文整理汇总了Java中com.google.android.exoplayer2.extractor.ExtractorsFactory类的典型用法代码示例。如果您正苦于以下问题:Java ExtractorsFactory类的具体用法?Java ExtractorsFactory怎么用?Java ExtractorsFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtractorsFactory类属于com.google.android.exoplayer2.extractor包,在下文中一共展示了ExtractorsFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startPlayer
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的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();
}
示例2: setExoViewSource
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的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);
}
示例3: initializePlayer
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的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);
}
}
示例4: doInBackground
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
@Override
protected MediaSource[] doInBackground(MediaFile... media) {
try {
browser = Browser.getInstance(Config.mountDirectory);
DataSource.Factory dataSourceFactory = new NfsDataSourceFactory(browser.getContext());
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource videoSource = new ExtractorMediaSource(Uri.parse("nfs://host/" + media[0].getPath()), dataSourceFactory, extractorsFactory, null, null);
if (media[0].getSubtitlePath() != null) {
Format subtitleFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP, null, Format.NO_VALUE, Format.NO_VALUE, "en", null);
MediaSource subtitleSource = new SingleSampleMediaSource(Uri.parse("nfs://host/" + media[0].getSubtitlePath()), dataSourceFactory, subtitleFormat, Long.MAX_VALUE, 0);
return new MediaSource[]{videoSource, subtitleSource};
} else
return new MediaSource[]{videoSource};
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
示例5: prepare
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
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);
}
示例6: ExtractorMediaSource
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
/**
* @param uri The {@link Uri} of the media stream.
* @param dataSourceFactory A factory for {@link DataSource}s to read the media.
* @param extractorsFactory A factory for {@link Extractor}s to process the media stream. If the
* possible formats are known, pass a factory that instantiates extractors for those formats.
* Otherwise, pass a {@link DefaultExtractorsFactory} to use default extractors.
* @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
* @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.
* @param customCacheKey A custom key that uniquely identifies the original stream. Used for cache
* indexing. May be null.
* @param continueLoadingCheckIntervalBytes The number of bytes that should be loaded between each
* invocation of {@link MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}.
* @deprecated Use {@link Factory} instead.
*/
@Deprecated
public ExtractorMediaSource(
Uri uri,
DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory,
int minLoadableRetryCount,
Handler eventHandler,
EventListener eventListener,
String customCacheKey,
int continueLoadingCheckIntervalBytes) {
this(
uri,
dataSourceFactory,
extractorsFactory,
minLoadableRetryCount,
eventHandler,
eventListener == null ? null : new EventListenerWrapper(eventListener),
customCacheKey,
continueLoadingCheckIntervalBytes);
}
示例7: startPlayer
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
/**
* 播放启动视频
*/
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);
}
示例8: setupMediaPlayer
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
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);
}
示例9: getMediaSource
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
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;
}
示例10: getMediaSource
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
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;
}
示例11: initExoPlayer
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
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);
}
示例12: ExtractorMediaSource
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
/**
* @param uri The {@link Uri} of the media stream.
* @param dataSourceFactory A factory for {@link DataSource}s to read the media.
* @param extractorsFactory A factory for {@link Extractor}s to process the media stream. If the
* possible formats are known, pass a factory that instantiates extractors for those formats.
* Otherwise, pass a {@link DefaultExtractorsFactory} to use default extractors.
* @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
* @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.
* @param customCacheKey A custom key that uniquely identifies the original stream. Used for cache
* indexing. May be null.
*/
public ExtractorMediaSource(Uri uri, DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory, int minLoadableRetryCount, Handler eventHandler,
EventListener eventListener, String customCacheKey) {
this.uri = uri;
this.dataSourceFactory = dataSourceFactory;
this.extractorsFactory = extractorsFactory;
this.minLoadableRetryCount = minLoadableRetryCount;
this.eventHandler = eventHandler;
this.eventListener = eventListener;
this.customCacheKey = customCacheKey;
period = new Timeline.Period();
}
示例13: play
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
public void play(){
if (song != null) {
try {
if (pausePos != null) {
player.seekTo(pausePos);
} else {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
Util.getUserAgent(getApplicationContext(), "BeatPulse"));
// Produces Extractor instances for parsing the media data.
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
// This is the MediaSource representing the media to be played.
MediaSource songSource = new ExtractorMediaSource(song.getFileUri(),
dataSourceFactory, extractorsFactory, null, null);
player.prepare(songSource);
}
player.setPlayWhenReady(true);
} catch (Exception exc) {
//Catches the exception raised when preparing the same FFmpegMediaPlayer multiple times.
Log.d(TAG, "Exception occurred while starting to play " + song.getName(), exc);
}
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
realm.copyToRealmOrUpdate(song);
realm.commitTransaction();
if (showNotification) {
showNotification();
}
Intent broadcastIntent = new Intent();
broadcastIntent.setAction("MEDIA_PLAYER_STARTED");
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(broadcastIntent);
}
}
示例14: ExtractorMediaSource
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
/**
* @param uri The {@link Uri} of the media stream.
* @param dataSourceFactory A factory for {@link DataSource}s to read the media.
* @param extractorsFactory A factory for {@link Extractor}s to process the media stream. If the
* possible formats are known, pass a factory that instantiates extractors for those formats.
* Otherwise, pass a {@link DefaultExtractorsFactory} to use default extractors.
* @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
* @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.
*/
public ExtractorMediaSource(Uri uri, DataSource.Factory dataSourceFactory,
ExtractorsFactory extractorsFactory, int minLoadableRetryCount, Handler eventHandler,
EventListener eventListener) {
this.uri = uri;
this.dataSourceFactory = dataSourceFactory;
this.extractorsFactory = extractorsFactory;
this.minLoadableRetryCount = minLoadableRetryCount;
this.eventHandler = eventHandler;
this.eventListener = eventListener;
period = new Timeline.Period();
}
示例15: provideMediaSourceFactory
import com.google.android.exoplayer2.extractor.ExtractorsFactory; //导入依赖的package包/类
@Provides
static MediaSourceFactory provideMediaSourceFactory(final DataSource.Factory dataSourceFactory,
final ExtractorsFactory extractorsFactory) {
return uri -> new ExtractorMediaSource(Uri.parse(uri),
dataSourceFactory,
extractorsFactory,
null, null);
}