本文整理汇总了Java中com.google.android.exoplayer.util.Util.getUserAgent方法的典型用法代码示例。如果您正苦于以下问题:Java Util.getUserAgent方法的具体用法?Java Util.getUserAgent怎么用?Java Util.getUserAgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.exoplayer.util.Util
的用法示例。
在下文中一共展示了Util.getUserAgent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private VideoPlayer.RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(getActivity(), "ExoVideoPlayer");
Uri contentUri = Uri.parse(mSelectedVideo.videoUrl);
int contentType = Util.inferContentType(contentUri.getLastPathSegment());
switch (contentType) {
case Util.TYPE_OTHER: {
return new ExtractorRendererBuilder(getActivity(), userAgent, contentUri);
}
case Util.TYPE_DASH: {
// Implement your own DRM callback here.
MediaDrmCallback drmCallback = new WidevineTestMediaDrmCallback(null, null);
return new DashRendererBuilder(getActivity(), userAgent, contentUri.toString(),
drmCallback);
}
case Util.TYPE_HLS: {
return new HlsRendererBuilder(getActivity(), userAgent, contentUri.toString());
}
default: {
throw new IllegalStateException("Unsupported type: " + contentType);
}
}
}
示例2: getRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private RendererBuilder getRendererBuilder() {
Uri contentUri = Uri.parse(mDataSource);
String userAgent = Util.getUserAgent(mAppContext, "IjkExoMediaPlayer");
int contentType = inferContentType(contentUri);
switch (contentType) {
case Util.TYPE_SS:
return new SmoothStreamingRendererBuilder(mAppContext, userAgent, contentUri.toString(),
new SmoothStreamingTestMediaDrmCallback());
/* case Util.TYPE_DASH:
return new DashRendererBuilder(mAppContext , userAgent, contentUri.toString(),
new WidevineTestMediaDrmCallback(contentId, provider));*/
case Util.TYPE_HLS:
return new HlsRendererBuilder(mAppContext, userAgent, contentUri.toString());
case Util.TYPE_OTHER:
default:
return new ExtractorRendererBuilder(mAppContext, userAgent, contentUri);
}
}
示例3: getRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
switch (contentType) {
case TYPE_SS:
return new SmoothStreamingRendererBuilder(this, userAgent, contentUri.toString(),
new SmoothStreamingTestMediaDrmCallback());
case TYPE_DASH:
return new DashRendererBuilder(this, userAgent, contentUri.toString(),
new WidevineTestMediaDrmCallback(contentId));
case TYPE_HLS:
return new HlsRendererBuilder(this, userAgent, contentUri.toString());
case TYPE_OTHER:
return new ExtractorRendererBuilder(this, userAgent, contentUri);
default:
throw new IllegalStateException("Unsupported type: " + contentType);
}
}
示例4: CustomExoPlayer
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
public CustomExoPlayer(Context context) {
this.context = context;
this.mainHandler = new Handler(Looper.getMainLooper());
this.userAgent = Util.getUserAgent(context, "ExoPlayerDemo");
// 1. Instantiate the player.
player = ExoPlayer.Factory.newInstance(2);
// // 2. Construct renderers.
// MediaCodecVideoTrackRenderer videoRenderer = ...
// MediaCodecAudioTrackRenderer audioRenderer = ...
// // 3. Inject the renderers through prepare.
// player.prepare(videoRenderer, audioRenderer);
// // 4. Pass the surface to the video renderer.
// player.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
// // 5. Start playback.
// player.setPlayWhenReady(true);
}
示例5: getRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private RendererBuilder getRendererBuilder(Context context, Sample sample) {
String userAgent = Util.getUserAgent(context, context.getApplicationInfo().name);
switch (sample.getType()) {
case SMOOTH_STREAMING:
return new SmoothStreamingRendererBuilder(context, userAgent, sample.getUri(),
new SmoothStreamingTestMediaDrmCallback());
case DASH:
return new DashRendererBuilder(context, userAgent, sample.getUri(),
new WidevineTestMediaDrmCallback(sample.getContentId()), sample.getAudioCapabilities());
case HLS:
return new HlsRendererBuilder(context, userAgent, sample.getUri(),
sample.getAudioCapabilities());
case OTHER:
case LOCAL:
return new ExtractorRendererBuilder(context, userAgent, Uri.parse(sample.getUri()));
default:
throw new IllegalStateException("Unsupported type: " + sample.getType().toString());
}
}
示例6: run
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public void run() {
Looper.prepare();
player = ExoPlayer.Factory.newInstance(1);
player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
uri, new DefaultUriDataSource(context, Util.getUserAgent(context, "ExoPlayerExtVP9Test")),
new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
new WebmExtractor());
LibvpxVideoTrackRenderer videoRenderer = new LibvpxVideoTrackRenderer(sampleSource, true);
player.sendMessage(videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
new VpxVideoSurfaceView(context));
player.prepare(videoRenderer);
player.setPlayWhenReady(true);
Looper.loop();
}
示例7: getRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(getActivity(), "ExoPlayerDemo");
Uri uri = Uri.parse(mStreamUrl);
int contentType = inferContentType(uri, null);
switch (contentType) {
// case TYPE_SS:
// return new SmoothStreamingRendererBuilder(this, null, contentUri.toString(),
// new SmoothStreamingTestMediaDrmCallback());
// case TYPE_DASH:
// return new DashRendererBuilder(this, userAgent, contentUri.toString(),
// new WidevineTestMediaDrmCallback(contentId, provider));
case TYPE_HLS:
return new HlsRendererBuilder(getContext(), userAgent, mStreamUrl);
case TYPE_OTHER:
return new ExtractorRendererBuilder(getContext(), userAgent, uri);
default:
throw new IllegalStateException("Unsupported type: " + contentType);
}
}
示例8: getRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private VideoPlayer.RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(getActivity(), "ExoVideoPlayer");
Uri contentUri = Uri.parse(mSelectedVideo.videoUrl);
int contentType = Util.inferContentType(contentUri.getLastPathSegment());
switch (contentType) {
case Util.TYPE_OTHER: {
return new ExtractorRendererBuilder(getActivity(), userAgent, contentUri);
}
default: {
throw new IllegalStateException("Unsupported type: " + contentType);
}
}
}
示例9: getHpLibRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private RendererBuilder getHpLibRendererBuilder() {
String userAgent = Util.getUserAgent(activity, "HpLib");
switch (video_type.get(currentTrackIndex)) {
case "hls":
return new HlsRendererBuilder(activity, userAgent, video_url.get(currentTrackIndex));
case "others":
return new ExtractorRendererBuilder(activity, userAgent,
Uri.parse(video_url.get(currentTrackIndex)));
default:
throw new IllegalStateException("Unsupported type: " + video_url.get(currentTrackIndex));
}
}
示例10: onStart
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public void onStart(Intent paramIntent, int paramInt) {
//stop the streaming
Intent i = new Intent(StreamingService.this, PodcastingService.class);
stopService(i);
if (paramIntent != null) {
this.audio = paramIntent.getStringExtra("audio");
this.title = paramIntent.getStringExtra("title");
this.text = paramIntent.getStringExtra("text");
this.logo_url = paramIntent.getStringExtra("logo_url");
this.logo = paramIntent.getByteArrayExtra("logo");
this.mNM = ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE));
try {
// String with the url of the radio you want to play
Uri radioUri = Uri.parse(audio);
// Settings for exoPlayer
Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
String userAgent = Util.getUserAgent(this, "ComRadioPlayer");
DataSource dataSource = new DefaultUriDataSource(this, null, userAgent);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(radioUri, dataSource, allocator, BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT);
audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
// Prepare ExoPlayer
exoPlayer.prepare(audioRenderer);
exoPlayer.setPlayWhenReady(true);
showNotification(text, title);
} catch (Exception e) {
Log.d("Streaming", "onStart", e);
}
}
}
示例11: startBasicPlayback
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private void startBasicPlayback() {
player = ExoPlayer.Factory.newInstance(4);
player.addListener(this);
mediaController.setMediaPlayer(new PlayerControl(player));
mediaController.setEnabled(true);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
contentUri,
new DefaultUriDataSource(this, Util.getUserAgent(this, "ExoPlayerExtWebMDemo")),
new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
new WebmExtractor(), new FlacExtractor(), new OggExtractor());
TrackRenderer videoRenderer =
new LibvpxVideoTrackRenderer(sampleSource, true, handler, this, 50);
if (useOpenGL) {
player.sendMessage(videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_OUTPUT_BUFFER_RENDERER,
vpxVideoSurfaceView);
surfaceView.setVisibility(View.GONE);
} else {
player.sendMessage(
videoRenderer, LibvpxVideoTrackRenderer.MSG_SET_SURFACE,
surfaceView.getHolder().getSurface());
vpxVideoSurfaceView.setVisibility(View.GONE);
}
TrackRenderer opusAudioTrackRenderer = new LibopusAudioTrackRenderer(sampleSource);
TrackRenderer flacAudioTrackRenderer = new LibflacAudioTrackRenderer(sampleSource);
TrackRenderer mediaCodecAudioTrackRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
MediaCodecSelector.DEFAULT);
player.prepare(videoRenderer, opusAudioTrackRenderer, flacAudioTrackRenderer,
mediaCodecAudioTrackRenderer);
player.setPlayWhenReady(true);
}
示例12: getRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
switch (contentType) {
case Util.TYPE_HLS:
return new HlsRendererBuilder(this, userAgent, contentUri.toString());
default:
throw new IllegalStateException("Unsupported type: " + contentType);
}
}
示例13: run
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public void run() {
Looper.prepare();
player = ExoPlayer.Factory.newInstance(1);
player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
uri,
new DefaultUriDataSource(context, Util.getUserAgent(context, "ExoPlayerExtOpusTest")),
new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
new WebmExtractor());
LibopusAudioTrackRenderer audioRenderer = new LibopusAudioTrackRenderer(sampleSource);
player.prepare(audioRenderer);
player.setPlayWhenReady(true);
Looper.loop();
}
示例14: run
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
@Override
public void run() {
Looper.prepare();
player = ExoPlayer.Factory.newInstance(1);
player.addListener(this);
ExtractorSampleSource sampleSource = new ExtractorSampleSource(
uri,
new DefaultUriDataSource(context, Util.getUserAgent(context, "ExoPlayerExtFlacTest")),
new DefaultAllocator(BUFFER_SEGMENT_SIZE), BUFFER_SEGMENT_SIZE * BUFFER_SEGMENT_COUNT,
new WebmExtractor());
LibflacAudioTrackRenderer audioRenderer = new LibflacAudioTrackRenderer(sampleSource);
player.prepare(audioRenderer);
player.setPlayWhenReady(true);
Looper.loop();
}
示例15: getRendererBuilder
import com.google.android.exoplayer.util.Util; //导入方法依赖的package包/类
private DemoPlayer.RendererBuilder getRendererBuilder() {
String userAgent = Util.getUserAgent(this, "ExoPlayerDemo");
switch (contentType) {
case Util.TYPE_DASH:
return new DashRendererBuilder(this, userAgent, contentUri.toString());
default:
throw new IllegalStateException("Unsupported type: " + contentType);
}
}