Пример #1
0
  @AfterViews
  void init() {
    String videoLink = getIntent().getStringExtra("video_link");
    if (null == videoLink || "".equals(videoLink)) {
      mApplication.showMsg(MApplication.TOAST_ALERT, "抱歉,解析连接出现问题");
      return;
    }

    mHandler = new Handler();
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    sideVolume = (ImageView) sideSoundRoot.findViewById(R.id.value_img);
    sideBright = (ImageView) sideBrightRoot.findViewById(R.id.value_img);

    mGestureDetector = new GestureDetector(this, new SimpleGesture());

    initPlayer(videoLink);
  }
Пример #2
0
  @UiThread
  void changeVolume(float distance) {
    int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    int volume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);

    float totalY = 0;
    if (distance > 0) {
      totalYup = totalYup + distance;
      totalY = totalYup;
    } else if (distance < 0) {
      totalYdown = totalYdown + distance;
      totalY = totalYdown;
    }

    int changeValue = (int) (totalY / (mApplication.getmScreenHeight() / maxVolume));
    if (changeValue >= 1) {
      totalYup = 0;
      volume = volume + changeValue;
    }
    if (changeValue <= -1) {
      totalYdown = 0;
      volume = volume + changeValue;
    }
    if (volume > maxVolume) {
      volume = maxVolume;
    } else if (volume < 0) {
      volume = 0;
    }
    mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);

    // 更新ui
    ViewGroup.LayoutParams lp = sideVolume.getLayoutParams();
    lp.height =
        (int)
            (sideSoundRoot.findViewById(R.id.value_img_bg).getLayoutParams().height
                * volume
                * 1f
                / maxVolume);
    sideVolume.setLayoutParams(lp);
  }
Пример #3
0
 @Override
 public void onPlayerError(ExoPlaybackException e) {
   mApplication.showMsg(MApplication.TOAST_ALERT, "视频播放失败啦");
 }