Java 类com.google.android.exoplayer.demo.DemoUtil 实例源码

项目:android-exoplayer    文件:SmoothStreamingTestMediaDrmCallback.java   
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws Exception {
  String url = request.getDefaultUrl();
  if (TextUtils.isEmpty(url)) {
    url = PLAYREADY_TEST_DEFAULT_URI;
  }
  return DemoUtil.executePost(url, request.getData(), KEY_REQUEST_PROPERTIES);
}
项目:android-exoplayer    文件:DashRendererBuilder.java   
public static Pair<DrmSessionManager, Boolean> getDrmSessionManagerData(DemoPlayer player,
    MediaDrmCallback drmCallback) throws UnsupportedSchemeException {
  StreamingDrmSessionManager streamingDrmSessionManager = new StreamingDrmSessionManager(
      DemoUtil.WIDEVINE_UUID, player.getPlaybackLooper(), drmCallback, null,
      player.getMainHandler(), player);
  return Pair.create((DrmSessionManager) streamingDrmSessionManager,
      getWidevineSecurityLevel(streamingDrmSessionManager) == SECURITY_LEVEL_1);
}
项目:android-exoplayer    文件:WidevineTestMediaDrmCallback.java   
@Override
public byte[] executeKeyRequest(UUID uuid, KeyRequest request) throws IOException {
  String url = request.getDefaultUrl();
  if (TextUtils.isEmpty(url)) {
    url = defaultUri;
  }
  return DemoUtil.executePost(url, request.getData(), null);
}
项目:android-exoplayer    文件:FullPlayerActivity.java   
private RendererBuilder getRendererBuilder() {
  String userAgent = DemoUtil.getUserAgent(this);
  switch (contentType) {
    case DemoUtil.TYPE_SS:
      return new SmoothStreamingRendererBuilder(userAgent, contentUri.toString(), contentId,
          new SmoothStreamingTestMediaDrmCallback(), debugTextView);
    case DemoUtil.TYPE_DASH:
      return new DashRendererBuilder(userAgent, contentUri.toString(), contentId,
          new WidevineTestMediaDrmCallback(contentId), debugTextView);
    default:
      return new DefaultRendererBuilder(this, contentUri, debugTextView);
  }
}
项目:android-exoplayer    文件:SimplePlayerActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  Intent intent = getIntent();
  contentUri = intent.getData();
  contentType = intent.getIntExtra(DemoUtil.CONTENT_TYPE_EXTRA, DemoUtil.TYPE_OTHER);
  contentId = intent.getStringExtra(DemoUtil.CONTENT_ID_EXTRA);

  mainHandler = new Handler(getMainLooper());
  builder = getRendererBuilder();

  setContentView(R.layout.player_activity_simple);
  View root = findViewById(R.id.root);
  root.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
      if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
        toggleControlsVisibility();
      }
      return true;
    }
  });

  mediaController = new MediaController(this);
  mediaController.setAnchorView(root);
  shutterView = findViewById(R.id.shutter);
  surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view);
  surfaceView.getHolder().addCallback(this);

  DemoUtil.setDefaultCookieManager();
}
项目:android-exoplayer    文件:SimplePlayerActivity.java   
private RendererBuilder getRendererBuilder() {
  String userAgent = DemoUtil.getUserAgent(this);
  switch (contentType) {
    case DemoUtil.TYPE_SS:
      return new SmoothStreamingRendererBuilder(this, userAgent, contentUri.toString(),
          contentId);
    case DemoUtil.TYPE_DASH:
      return new DashRendererBuilder(this, userAgent, contentUri.toString(), contentId);
    default:
      return new DefaultRendererBuilder(this, contentUri);
  }
}
项目:Exoplayer_VLC    文件:RawHttpRendererBuilder.java   
@Override
public void buildRenderers(DemoPlayer player, DemoPlayer.RendererBuilderCallback callback) {

    // Build the video and audio renderers.
    Log.d(TAG, "buildRenderers(): uri=" + uri.toString());

    Handler mainHandler = player.getMainHandler();

    RawExtractor extractor = null;
    if( playerType == DemoUtil.TYPE_RAW_HTTP_TS) {
        BufferPool bufferPool = new BufferPool(this.BUFFER_POOL_LENGTH);
        extractor = new TsExtractor(false, 0, bufferPool);
    }

    DataSource videoDataSource = new RawHttpDataSource(userAgent, RawHttpDataSource.REJECT_PAYWALL_TYPES);
    DataSource rawSource = new RawBufferedSource(videoDataSource);
    SampleSource sampleSource = new RawSampleSource(rawSource, this.uri, this.context, extractor);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, null, true, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, null, mainHandler, player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

    // Build the debug renderer.
    TrackRenderer debugRenderer = debugTextView != null
            ? new DebugTrackRenderer(debugTextView, videoRenderer)
            : null;

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
    renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer; // audioRenderer;
    renderers[DemoPlayer.TYPE_DEBUG] = debugRenderer;
    callback.onRenderers(null, null, renderers);
}
项目:android-exoplayer    文件:SmoothStreamingTestMediaDrmCallback.java   
@Override
public byte[] executeProvisionRequest(UUID uuid, ProvisionRequest request) throws IOException {
  String url = request.getDefaultUrl() + "&signedRequest=" + new String(request.getData());
  return DemoUtil.executePost(url, null, null);
}
项目:android-exoplayer    文件:WidevineTestMediaDrmCallback.java   
@Override
public byte[] executeProvisionRequest(UUID uuid, ProvisionRequest request)
    throws ClientProtocolException, IOException {
  String url = request.getDefaultUrl() + "&signedRequest=" + new String(request.getData());
  return DemoUtil.executePost(url, null, null);
}
项目:android-exoplayer    文件:FullPlayerActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  Intent intent = getIntent();
  contentUri = intent.getData();
  contentType = intent.getIntExtra(DemoUtil.CONTENT_TYPE_EXTRA, DemoUtil.TYPE_OTHER);
  contentId = intent.getStringExtra(DemoUtil.CONTENT_ID_EXTRA);

  setContentView(R.layout.player_activity_full);
  View root = findViewById(R.id.root);
  root.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
      if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
        toggleControlsVisibility();
      }
      return true;
    }
  });

  shutterView = findViewById(R.id.shutter);
  debugRootView = findViewById(R.id.controls_root);

  surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view);
  surfaceView.getHolder().addCallback(this);
  debugTextView = (TextView) findViewById(R.id.debug_text_view);

  playerStateTextView = (TextView) findViewById(R.id.player_state_view);
  subtitleView = (SubtitleView) findViewById(R.id.subtitles);

  mediaController = new MediaController(this);
  mediaController.setAnchorView(root);
  retryButton = (Button) findViewById(R.id.retry_button);
  retryButton.setOnClickListener(this);
  videoButton = (Button) findViewById(R.id.video_controls);
  audioButton = (Button) findViewById(R.id.audio_controls);
  textButton = (Button) findViewById(R.id.text_controls);

  DemoUtil.setDefaultCookieManager();
}