本文整理了Java中com.google.android.exoplayer2.util.Util.getUserAgent()
方法的一些代码示例,展示了Util.getUserAgent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.getUserAgent()
方法的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
方法名:getUserAgent
[英]Returns a user agent string based on the given application name and the library version.
[中]基于给定的应用程序名称和库版本返回用户代理字符串。
代码示例来源:origin: google/ExoPlayer
public PlayerManager(Context context) {
String adTag = context.getString(R.string.ad_tag_url);
adsLoader = new ImaAdsLoader(context, Uri.parse(adTag));
dataSourceFactory =
new DefaultDataSourceFactory(
context, Util.getUserAgent(context, context.getString(R.string.application_name)));
}
代码示例来源:origin: CarGuo/GSYVideoPlayer
private DataSource.Factory getHttpDataSourceFactory(Context context, boolean preview) {
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(context,
TAG), preview ? null : new DefaultBandwidthMeter());
if (mMapHeadData != null && mMapHeadData.size() > 0) {
for (Map.Entry<String, String> header : mMapHeadData.entrySet()) {
dataSourceFactory.getDefaultRequestProperties().set(header.getKey(), header.getValue());
}
}
return dataSourceFactory;
}
代码示例来源:origin: lipangit/JiaoZiVideoPlayer
Util.getUserAgent(context, context.getResources().getString(R.string.app_name)));
代码示例来源:origin: google/ExoPlayer
@Override
public final void onStart(HostActivity host, Surface surface) {
this.surface = surface;
// Build the player.
trackSelector = buildTrackSelector(host);
String userAgent = "ExoPlayerPlaybackTests";
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
player = buildExoPlayer(host, surface, trackSelector, drmSessionManager);
player.prepare(buildSource(host, Util.getUserAgent(host, userAgent)));
player.addAnalyticsListener(this);
player.addAnalyticsListener(new EventLogger(trackSelector, tag));
if (analyticsListener != null) {
player.addAnalyticsListener(analyticsListener);
}
player.setPlayWhenReady(true);
actionHandler = Clock.DEFAULT.createHandler(Looper.myLooper(), /* callback= */ null);
// Schedule any pending actions.
if (pendingSchedule != null) {
pendingSchedule.start(player, trackSelector, surface, actionHandler, /* callback= */ null);
pendingSchedule = null;
}
}
代码示例来源:origin: jiajunhui/PlayerBase
Util.getUserAgent(mAppContext, mAppContext.getPackageName()), mBandwidthMeter);
("http".equalsIgnoreCase(scheme)||"https".equalsIgnoreCase(scheme))){
dataSourceFactory = new DefaultHttpDataSourceFactory(
Util.getUserAgent(mAppContext, mAppContext.getPackageName()));
((DefaultHttpDataSourceFactory)dataSourceFactory).getDefaultRequestProperties().set(extra);
Format format = Format.createTextSampleFormat(null, timedTextSource.getMimeType(), timedTextSource.getFlag(), null);
MediaSource timedTextMediaSource = new SingleSampleMediaSource.Factory(new DefaultDataSourceFactory(mAppContext,
Util.getUserAgent(mAppContext, mAppContext.getPackageName())))
.createMediaSource(Uri.parse(timedTextSource.getPath()), format, C.TIME_UNSET);
代码示例来源:origin: google/ExoPlayer
@Override
public final void onStart(HostActivity host, Surface surface) {
this.surface = surface;
// Build the player.
trackSelector = buildTrackSelector(host);
String userAgent = "ExoPlayerPlaybackTests";
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
player = buildExoPlayer(host, surface, trackSelector, drmSessionManager);
player.prepare(buildSource(host, Util.getUserAgent(host, userAgent)));
player.addAnalyticsListener(this);
player.addAnalyticsListener(new EventLogger(trackSelector, tag));
if (analyticsListener != null) {
player.addAnalyticsListener(analyticsListener);
}
player.setPlayWhenReady(true);
actionHandler = Clock.DEFAULT.createHandler(Looper.myLooper(), /* callback= */ null);
// Schedule any pending actions.
if (pendingSchedule != null) {
pendingSchedule.start(player, trackSelector, surface, actionHandler, /* callback= */ null);
pendingSchedule = null;
}
}
代码示例来源:origin: yuliskov/SmartYouTubeTV
@Override
public void onCreate() {
super.onCreate();
String appName = "ExoPlayer";
userAgent = Util.getUserAgent(this, appName);
// A debug bridge for Android applications
if (BuildConfig.DEBUG) {
Stetho.initializeWithDefaults(this);
}
// needed for toast messages
OkHttpHelpers.setContext(this);
}
代码示例来源:origin: m-cakir/radio-player
private String getUserAgent(){
return Util.getUserAgent(this, getClass().getSimpleName());
}
}
代码示例来源:origin: huyongli/TigerVideo
private HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) {
return new DefaultHttpDataSourceFactory(Util.getUserAgent(mContext, TAG), bandwidthMeter, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true);
}
}
代码示例来源:origin: maiwenchang/ArtPlayer
private DataSource.Factory getHttpDataSourceFactory(Context context, boolean preview) {
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(context,
TAG), preview ? null : new DefaultBandwidthMeter());
if (mMapHeadData != null && mMapHeadData.size() > 0) {
for (Map.Entry<String, String> header : mMapHeadData.entrySet()) {
dataSourceFactory.getDefaultRequestProperties().set(header.getKey(), header.getValue());
}
}
return dataSourceFactory;
}
代码示例来源:origin: QuickBlox/ChatMessagesAdapter-android
public static MediaSource buildMediaSource(Uri uri, Context context) {
String userAgent = Util.getUserAgent(context, context.getResources().getString(R.string.app_name));
return new ExtractorMediaSource(uri,
new DefaultHttpDataSourceFactory(userAgent),
new DefaultExtractorsFactory(), null, null);
}
}
代码示例来源:origin: VRGsoftUA/VideoCrop
public void initMediaSource(Context context, String uri) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context, "ExoPlayer"));
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource videoSource = new ExtractorMediaSource(Uri.parse(uri),
dataSourceFactory, extractorsFactory, null, null);
player.prepare(videoSource);
player.addVideoListener(this);
}
代码示例来源:origin: HpWens/MeiWidgetView
private void initVideo(String videoUrl) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getActivity(),
Util.getUserAgent(getActivity(), "useExoPlayer"), null);
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
//http://sv.dingdangyixia.cn/sv/2fced8a5922843c19c038330cb66f505
//由于头条的视频地址 在一定的时间会变化 过期的地址无法访问 后期可以通过 python 抓起实时地址
MediaSource videoSource = new ExtractorMediaSource(Uri.parse("https://vd3.bdstatic.com/" +
"mda-idip3ibsutbfkae1/sc/mda-idip3ibsutbfkae1.mp4?auth_key=1528440598-0-0-f8eb95c6ad0f5c6b066feef02630cde0&bcevod_channel=searchbox_feed"),
dataSourceFactory, extractorsFactory, null, null);
mVideoPlayer.prepare(videoSource);
}
代码示例来源:origin: ChangWeiBa/AesExoPlayer
@Override
public void onCreate() {
super.onCreate();
instance = this;
userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
//在这里先使用Timber.plant注册一个Tree,然后调用静态的.d .v 去使用
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
//Android N 文件权限
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
}
}
代码示例来源:origin: Doctoror/PainlessMusicPlayer
@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"));
}
代码示例来源:origin: y20k/transistor
private void preparePlayer(int connectionType) {
// create MediaSource
MediaSource mediaSource;
// create BandwidthMeter for DataSource.Factory
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
// create DataSource.Factory - produces DataSource instances through which media data is loaded
DataSource.Factory dataSourceFactory;
if (connectionType == CONNECTION_TYPE_HLS) {
// TODO HLS does not work reliable
Toast.makeText(this, this.getString(R.string.toastmessage_stream_may_not_work), Toast.LENGTH_LONG).show();
dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, mUserAgent), bandwidthMeter);
mediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(mStation.getStreamUri());
} else {
dataSourceFactory = new IcyDataSourceFactory(this, Util.getUserAgent(this, mUserAgent), bandwidthMeter, true, playerCallback);
mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).setContinueLoadingCheckIntervalBytes(32).createMediaSource(mStation.getStreamUri());
}
// prepare player with source.
mPlayer.prepare(mediaSource);
}
代码示例来源:origin: MasayukiSuda/GPUVideo-android
private void setUpSimpleExoPlayer() {
TrackSelector trackSelector = new DefaultTrackSelector();
// Measures bandwidth during playback. Can be null if not required.
DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();
// Produces DataSource instances through which media data is loaded.
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "yourApplicationName"), defaultBandwidthMeter);
MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(STREAM_URL_MP4_VOD_LONG));
// SimpleExoPlayer
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
// Prepare the player with the source.
player.prepare(mediaSource);
player.setPlayWhenReady(true);
}
代码示例来源:origin: gearvrf/GearVRf-Demos
private void createDashFactories() {
Context context = VideoPlayerApp.getInstance().getApplicationContext();
String userAgent = Util.getUserAgent(context, "videoplayer");
mManifestDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent);
mDashChunkSourceFactory = new DefaultDashChunkSource.Factory(new DefaultHttpDataSourceFactory(userAgent, BANDWIDTH_METER));
}
代码示例来源:origin: cloudinary/cloudinary_android
private void loadVideo(final EffectData data) {
progressBar.setVisibility(View.VISIBLE);
imageView.setVisibility(View.GONE);
final DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "Cloudinary Sample App"), null);
final ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
Url baseUrl = MediaManager.get().url().resourceType("video").publicId(data.getPublicId()).transformation(data.getTransformation());
MediaManager.get().responsiveUrl(exoPlayerView, baseUrl, FIT, new ResponsiveUrl.Callback() {
@Override
public void onUrlReady(Url url) {
String urlString = url.generate();
currentUrl = urlString;
MediaSource videoSource = new ExtractorMediaSource(Uri.parse(urlString), dataSourceFactory, extractorsFactory, null, null);
exoPlayer.addListener(listener);
exoPlayer.prepare(videoSource);
}
});
}
代码示例来源:origin: nzkozar/ExoplayerExample
/**
* 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();
}
内容来源于网络,如有侵权,请联系作者删除!