@Override
  public void onResume() {
    super.onResume();
    // configureSubtitleView();

    // The player will be prepared on receiving audio capabilities.
    audioCapabilitiesReceiver.register();
  }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.player_activity);
    View root = findViewById(R.id.root);
    root.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
              toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
              view.performClick();
            }
            return true;
          }
        });
    root.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK
                || keyCode == KeyEvent.KEYCODE_ESCAPE
                || keyCode == KeyEvent.KEYCODE_MENU) {
              return false;
            }
            return mediaController.dispatchKeyEvent(event);
          }
        });

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

    videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) 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);
    subtitleLayout = (SubtitleLayout) 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);

    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager) {
      CookieHandler.setDefault(defaultCookieManager);
    }

    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();
  }
 @Override
 public void onPause() {
   super.onPause();
   if (!true) {
     releasePlayer();
   } else {
     player.setBackgrounded(true);
   }
   audioCapabilitiesReceiver.unregister();
 }
예제 #4
0
 @Override
 public void onPause() {
   super.onPause();
   if (!enableBackgroundAudio) {
     releasePlayer();
   } else {
     player.setBackgrounded(true);
   }
   audioCapabilitiesReceiver.unregister();
   shutterView.setVisibility(View.VISIBLE);
 }
예제 #5
0
  private void setupExoPlayer() {
    audioCapabilitiesReceiver =
        new AudioCapabilitiesReceiver(getContext().getApplicationContext(), this);
    audioCapabilitiesReceiver.register();
    emExoPlayer = new EMExoPlayer(null);

    // Sets the internal listener
    listenerMux = new EMListenerMux(new MuxNotifier());
    emExoPlayer.addListener(listenerMux);
    emExoPlayer.setMetadataListener(null);
    emExoPlayer.setSurface(exoVideoSurfaceView.getHolder().getSurface());
    exoVideoSurfaceView.getHolder().addCallback(new EMExoVideoSurfaceCallback());
  }
예제 #6
0
  @Override
  protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();

    defaultControls = null;
    stopPlayback();
    overriddenPositionStopWatch.stop();

    if (emExoPlayer != null) {
      emExoPlayer.release();
    }

    if (audioCapabilitiesReceiver != null) {
      audioCapabilitiesReceiver.unregister();
      audioCapabilitiesReceiver = null;
    }
  }
 public void releaseAudio() {
   if (audioRegistered) {
     audioCapabilitiesReceiver.unregister();
     audioRegistered = false;
   }
 }
 public void grabAudio() {
   if (!audioRegistered) {
     audioCapabilitiesReceiver.register();
     audioRegistered = true;
   }
 }
예제 #9
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   audioCapabilitiesReceiver.unregister();
   releasePlayer();
 }