本文整理汇总了Java中com.google.android.exoplayer2.source.ExtractorMediaSource类的典型用法代码示例。如果您正苦于以下问题:Java ExtractorMediaSource类的具体用法?Java ExtractorMediaSource怎么用?Java ExtractorMediaSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtractorMediaSource类属于com.google.android.exoplayer2.source包,在下文中一共展示了ExtractorMediaSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
}
示例2: reLoadSourcePlay
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的package包/类
/**
* 重载资源
*
* @param url
*/
private void reLoadSourcePlay(String url) {
Timber.e("重载资源file1---:" + url);
//重载资源
videoSource.releaseSource();
seekBar.setMax(0);
seekBar.setProgress(0);
allPlayerTime.setText("00:00");
ExtractorMediaSource extractorMediaSource =
new ExtractorMediaSource(Uri.parse(url), aitripFactory,
extractorsFactory, null, null);
player.prepare(extractorMediaSource);
//设置文字
// allPlayerTime.setText(TimeUtils.secToTime((int) (player.getDuration() / 1000)));
//设置总时长
// seekBar.setMax((int) (player.getDuration() / 100));
continuePlay();//开始播放
}
示例3: preparePlayer
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的package包/类
public void preparePlayer() {
MediaSource videoSource = new ExtractorMediaSource(syncplayuri,
dataSourceFactory, extractorsFactory, null, null);
mMediaPlayer.prepare(videoSource);
mSyncPlayClient.setPlayerState(new syncPlayClientInterface.playerDetails() {
@Override
public long getPosition() {
return mMediaPlayer.getCurrentPosition() / 1000L;
}
@Override
public Boolean isPaused() {
return !mMediaPlayer.getPlayWhenReady();
}
});
}
示例4: buildMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
}
示例5: buildMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
}
示例6: buildMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
}
示例7: initializePlayer
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
示例8: getMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
}
示例9: startPlayer
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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();
}
示例10: setExoViewSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
示例11: initializePlayer
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
示例12: newMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
示例13: buildMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
}
示例14: buildMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
}
示例15: buildMediaSource
import com.google.android.exoplayer2.source.ExtractorMediaSource; //导入依赖的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);
}
}
}