예제 #1
0
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
   // 切换到横屏
   if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
     mMediaController.changeLand(true);
   } else {
     mMediaController.changePortrait(true);
   }
 }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    // init UI
    mMediaController = new MediaController(this);
    mMediaController.setCallBack(mCallBack);
    mMediaController.setTitle("变形金刚2");

    mVideoView = (VideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(mMediaController);
    // prefer mVideoPath
    //
    // mVideoView.setVideoPath("http://mss.pinet.co/index.php/api/retrieve/3da4edce-b445-42c8-88a7-3b8a1997d61c/playlist.m3u8");
    mVideoView.setVideoPath(url);

    mVideoView.start();

    mVideoView.setOnPreparedListener(
        new IMediaPlayer.OnPreparedListener() {
          @Override
          public void onPrepared(IMediaPlayer mp) {}
        });

    mVideoView.setOnInfoListener(
        new IMediaPlayer.OnInfoListener() {
          @Override
          public boolean onInfo(IMediaPlayer mp, int what, int extra) {

            Log.e(TAG, "onInfo: extra=" + extra);
            Log.e(TAG, "onInfo: what=" + what);
            return false;
          }
        });

    //        mVideoView.setShowAction();;

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {

                Log.e(TAG, "run:getBufferPercentage= " + mVideoView.getBufferPercentage());
                Log.e(TAG, "run: getCurrentPosition=" + mVideoView.getCurrentPosition());
                Log.e(TAG, "run:getDuration= " + mVideoView.getDuration());
              }
            },
            2000);
    createAd();
  }
예제 #3
0
 @Override
 public void onBackPressed() {
   if (ScreenOrientationUtils.isLandscape(this)) {
     mMediaController.changePortrait(false);
   } else {
     super.onBackPressed();
   }
 }