Пример #1
0
  private void toggleControlsVisibility() {

    if (mediaController.isShowing()) {
      mediaController.hide();

    } else {
      showControls();
    }
  }
Пример #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!LibsChecker.checkVitamioLibs(this)) return;
    Intent intent = getIntent();
    contentUri = intent.getData();
    contentId = intent.getStringExtra(CONTENT_ID_EXTRA);

    setContentView(R.layout.player_activity);
    FrameLayout root = (FrameLayout) findViewById(R.id.root);
    setSystemUiVisibility(root);

    // shutterView = findViewById(R.id.shutter);

    surfaceView = (SurfaceView) findViewById(R.id.surface_view);

    holder = surfaceView.getHolder();
    holder.addCallback(this);
    holder.setFormat(PixelFormat.RGBA_8888);

    root.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
            System.out.println("root.setOnTouchListener");
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
              showControls();
              // toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
              view.performClick();
            }
            return false;
          }
        });

    /*root.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            System.out.println("root.setOnClickListener");
            toggleControlsVisibility();
        }
    });*/

    mediaController = new VideoControllerView(this);
    mediaController.setAnchorView(root);
    mediaController.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            mediaController.hide();
          }
        });
  }
Пример #3
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();
 }
Пример #4
0
 public void onPrepared(MediaPlayer mediaplayer) {
   Log.d(TAG, "onPrepared called");
   mIsVideoReadyToBePlayed = true;
   if (mIsVideoReadyToBePlayed) {
     mediaController.hide();
     initSizeSurfaceView();
     startVideoPlayback();
   }
 }
Пример #5
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);
    }
  }
Пример #6
0
 public boolean onError(MediaPlayer mp, int what, int extra) {
   mediaController.showError(0);
   mp.reset();
   return false;
 }
Пример #7
0
 private void showControls() {
   mediaController.showControl(0);
 }