本文整理匯總了Java中com.google.android.exoplayer2.upstream.DefaultBandwidthMeter類的典型用法代碼示例。如果您正苦於以下問題:Java DefaultBandwidthMeter類的具體用法?Java DefaultBandwidthMeter怎麽用?Java DefaultBandwidthMeter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DefaultBandwidthMeter類屬於com.google.android.exoplayer2.upstream包,在下文中一共展示了DefaultBandwidthMeter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createFullPlayer
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
/***
* 創建實例播放實例,並不開始緩衝
**/
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
BufferingLoadControl loadControl = new BufferingLoadControl();
if (null == modelType) {
setDefaultLoadModel();
} else {
loadControl.setListener(new LoadListener() {
@Override
public void onProgress(long pro) {
getPlayerViewListener().showNetSpeed(String.valueOf(pro) + "%");
}
});
}
DefaultRenderersFactory rf = new DefaultRenderersFactory(activity, drmSessionManager, DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON);
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(rf, trackSelector, loadControl);
player.setPlaybackParameters(playbackParameters);
getPlayerViewListener().setPlayer(player);
return player;
}
示例2: onBind
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
@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;
}
示例3: onStart
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
@Override
public final void onStart(HostActivity host, Surface surface) {
// Build the player.
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
trackSelector = buildTrackSelector(host, bandwidthMeter);
String userAgent = "ExoPlayerPlaybackTests";
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
player = buildExoPlayer(host, surface, trackSelector, drmSessionManager);
player.prepare(buildSource(host, Util.getUserAgent(host, userAgent), bandwidthMeter));
player.addListener(this);
player.setAudioDebugListener(this);
player.setVideoDebugListener(this);
player.setPlayWhenReady(true);
actionHandler = new Handler();
// Schedule any pending actions.
if (pendingSchedule != null) {
pendingSchedule.start(player, trackSelector, actionHandler);
pendingSchedule = null;
}
}
示例4: setExoViewSource
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的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);
}
示例5: setupExoPlayer
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
private void setupExoPlayer() {
TrackSelection.Factory adaptiveTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
exoPlayer = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(this),
new DefaultTrackSelector(adaptiveTrackSelectionFactory),
new DefaultLoadControl());
pvVideoPreview.setPlayer(exoPlayer);
exoPlayer.setPlayWhenReady(true);
Uri uri = Uri.parse("asset:///sample_video.mp4");
MediaSource mediaSource = createMediaSource(this, uri);
LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource);
exoPlayer.prepare(loopingMediaSource, true, false);
}
示例6: initExoPlayer
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
private void initExoPlayer(MediaSource sampleSource) {
if (exoPlayer == null) {
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
// 2. Create the player
exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
}
exoPlayer.prepare(sampleSource);
exoPlayer.setVideoSurfaceView(svPlayer);
exoPlayer.setPlayWhenReady(true);
initMediaControls();
}
示例7: initializePlayer
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
private void initializePlayer() {
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
mTrackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
mPlayer = ExoPlayerFactory.newSimpleInstance(getActivity(), mTrackSelector);
mPlayerAdapter = new LeanbackPlayerAdapter(getActivity(), mPlayer, UPDATE_DELAY);
mPlaylistActionListener = new PlaylistActionListener(mPlaylist);
mPlayerGlue = new VideoPlayerGlue(getActivity(), mPlayerAdapter, mPlaylistActionListener);
mPlayerGlue.setHost(new VideoFragmentGlueHost(this));
mPlayerGlue.playWhenPrepared();
play(mVideo);
ArrayObjectAdapter mRowsAdapter = initializeRelatedVideosRow();
setAdapter(mRowsAdapter);
}
示例8: createDataSource
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
@Override
public DataSource createDataSource() {
if (null != mCipher) {
return new MyDefaultDataSource(context, mCipher, mSecretKeySpec, mIvParameterSpec, mTransferListener, baseDataSourceFactory.createDataSource());
} else if (key != null) {
return new Encrypted1FileDataSource(key, new DefaultBandwidthMeter());
} else {
return new DefaultDataSource(context, new DefaultBandwidthMeter(), baseDataSourceFactory.createDataSource());
}
}
示例9: createPlayer
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
private static SimpleExoPlayer createPlayer(Context context) {
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
return ExoPlayerFactory.newSimpleInstance(context.getApplicationContext(), trackSelector);
}
示例10: onCreate
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
@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);
}
}
示例11: startPlayer
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的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);
}
示例12: PlayerController
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
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);
}
示例13: ExoPlayerInstance
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
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);
}
示例14: createFullPlayer
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory
= new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(playerView.getContext()),
trackSelector, loadControl);
player.setPlayWhenReady(true);
player.prepare(mediaSourceBuilder.getMediaSource(false));
player.addListener(eventListener);
return player;
}
示例15: createFullPlayer
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; //導入依賴的package包/類
private SimpleExoPlayer createFullPlayer() {
TrackSelection.Factory videoTrackSelectionFactory
= new AdaptiveTrackSelection.Factory(new DefaultBandwidthMeter());
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(playerView.getContext()),
trackSelector, loadControl);
player.setPlayWhenReady(true);
player.prepare(mediaSourceBuilder.getMediaSource(false));
player.addListener(this);
return player;
}