コード例 #1
0
 private void preparePlayer(boolean playWhenReady) {
   if (player == null) {
     player = new DemoPlayer(getRendererBuilder());
     player.addListener(this);
     player.setCaptionListener(this);
     player.setMetadataListener(this);
     player.seekTo(playerPosition);
     playerNeedsPrepare = true;
     mediaController.setMediaPlayer(player.getPlayerControl());
     mediaController.setEnabled(true);
     eventLogger = new EventLogger();
     eventLogger.startSession();
     player.addListener(eventLogger);
     player.setInfoListener(eventLogger);
     player.setInternalErrorListener(eventLogger);
     debugViewHelper = new DebugTextViewHelper(player, debugTextView);
     debugViewHelper.start();
   }
   if (playerNeedsPrepare) {
     player.prepare();
     playerNeedsPrepare = false;
     updateButtonVisibilities();
   }
   player.setSurface(surfaceView.getHolder().getSurface());
   player.setPlayWhenReady(playWhenReady);
 }
コード例 #2
0
 private void releasePlayer() {
   if (player != null) {
     debugViewHelper.stop();
     debugViewHelper = null;
     playerPosition = player.getCurrentPosition();
     player.release();
     player = null;
     eventLogger.endSession();
     eventLogger = null;
   }
 }