Exemplo n.º 1
0
 private void preparePlayer() {
   if (player == null) {
     player = new MediaPlayer(this);
     playerNeedsPrepare = true;
     mediaController.setMediaPlayer(player);
     mediaController.setEnabled(true);
   }
   if (playerNeedsPrepare) {
     player.prepareAsync();
     playerNeedsPrepare = false;
   }
   player.setSurface(surfaceView.getHolder().getSurface());
   player.start();
 }
Exemplo n.º 2
0
  private void playVideo() {
    doCleanUp();
    try {

      // Create a new media player and set the listeners
      player = new MediaPlayer(this);
      player.setDataSource(
          "http://htqjrpsv.cdnviet.com/htjzzsg/_definst_/vtv3.720p.stream/playlist.m3u8?t=b4781bdd2251d0e465e92824e9a11cf9&e=1428759643");
      player.setDisplay(holder);
      player.prepareAsync();
      player.setOnPreparedListener(this);
      player.setOnErrorListener(this);
      // player.setOnVideoSizeChangedListener(this);
      setVolumeControlStream(AudioManager.STREAM_MUSIC);
      mediaController.setMediaPlayer(player);
      mediaController.setEnabled(true);
      // player.setSurface(surfaceView.getHolder().getSurface());
      // player.start();
      mediaController.showLoading(0);

    } catch (Exception e) {
      Log.e(TAG, "error: " + e.getMessage(), e);
    }
  }