| | |
| | | private String videoName; |
| | | private String videoUrl; |
| | | private boolean collected;//是否收藏 |
| | | private String mResourceName; |
| | | |
| | | private Timer timer; |
| | | |
| | |
| | | |
| | | //正在播放的位置 |
| | | private int mPlayingPosition; |
| | | |
| | | private int mShowType;//1-长条 2-小方格 |
| | | |
| | | private AQuery aq; |
| | | |
| | |
| | | * |
| | | * @param episodeList |
| | | * @param videoName |
| | | * @param videoUrl |
| | | * @param playingPosition |
| | | * @return |
| | | */ |
| | | public VideoPlayerController setVideoInfo(List<VideoEpisode> episodeList, String videoName, String videoUrl, int playingPosition) { |
| | | this.videoName = videoName; |
| | | this.videoUrl = videoUrl; |
| | | public VideoPlayerController setVideoInfo(List<VideoEpisode> episodeList, int playingPosition, int showType, String resourceName) { |
| | | VideoEpisode currentVideoEpisode = episodeList.get(playingPosition); |
| | | this.videoName = currentVideoEpisode.getName(); |
| | | this.videoUrl = currentVideoEpisode.getVideoUrl(); |
| | | this.episodeList = episodeList; |
| | | this.mPlayingPosition = playingPosition; |
| | | this.mShowType = showType; |
| | | this.mResourceName = resourceName; |
| | | return this; |
| | | } |
| | | |
| | |
| | | VideoPlayerController.this.continuePlay(); |
| | | //不需要提醒 |
| | | needNotifyMobileData = false; |
| | | setPlayImage(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | }).build(mActivity); |
| | | if (!networkNotiftDialog.isShowing()) |
| | | networkNotiftDialog.show(); |
| | | } else { |
| | | continuePlay(); |
| | | } |
| | | break; |
| | | case ConnectivityManager.TYPE_WIFI: |
| | |
| | | pausePlay(); |
| | | } |
| | | |
| | | //设置播放按钮的状态按钮的 |
| | | setPlayImage(); |
| | | } |
| | | |
| | | private void setPlayImage() { |
| | | if (iv_play != null) |
| | | iv_play.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (mediaPlayer == null) { |
| | | return; |
| | | } |
| | | VideoResourceUtil.setPlayImage(iv_play, mediaPlayer.isPlaying(), isLand); |
| | | if (mediaPlayer.isPlaying()) { |
| | | aq.id(R.id.iv_play_center).visibility(View.GONE); |
| | | } else { |
| | | if (!isLand) { |
| | | aq.id(R.id.iv_play_center).visibility(View.VISIBLE); |
| | | } |
| | | } |
| | | } |
| | | }, 100); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置电量变化 |
| | |
| | | public void onProgressChanged(SeekBar seekBar, int precent, boolean b) { |
| | | if (isTouch) { |
| | | //计算 拖拉后的 时间长度: |
| | | int positionLong = mediaPlayer.getDuration() * seekBar.getProgress() / 1000; |
| | | int process = mediaPlayer.getDuration(); |
| | | float f = seekBar.getProgress() / 1000.0f; |
| | | int positionLong = (int) (process * f); |
| | | Log.i(TAG, "position:" + positionLong); |
| | | mediaPlayer.seekTo(positionLong); |
| | | } |
| | | |
| | |
| | | setLayout(); |
| | | tv_title.setText(videoName); |
| | | tv_link.setText(videoUrl); |
| | | tv_resource.setText("来源:" + mResourceName); |
| | | setCollect(this.collected); |
| | | |
| | | showLoading(); |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | //当前集 |
| | | episodeDialog = new VideoEpisodeDialog.Builder().setEpisodes(episodeList, mPlayingPosition, 1).setDialogClick(new VideoEpisodeDialog.IDialogClick() { |
| | | episodeDialog = new VideoEpisodeDialog.Builder().setEpisodes(episodeList, mPlayingPosition, mShowType).setDialogClick(new VideoEpisodeDialog.IDialogClick() { |
| | | @Override |
| | | public void selectEpisode(int p, VideoEpisode ve) { |
| | | if (videoPlayerListener != null) |
| | |
| | | if (mediaPlayer != null) { |
| | | if (mediaPlayer.isPlaying()) { |
| | | mediaPlayer.pause(); |
| | | VideoResourceUtil.setPlayImage(iv_play, true, isLand); |
| | | } else { |
| | | mediaPlayer.start(); |
| | | VideoResourceUtil.setPlayImage(iv_play, false, isLand); |
| | | } |
| | | setPlayerState(); |
| | | } |
| | | } |
| | | }); |
| | |
| | | } |
| | | |
| | | private void setLayout() { |
| | | Log.i(TAG, "setLayout"); |
| | | if (isLand) { |
| | | findViewById(R.id.fl_state).setVisibility(View.VISIBLE); |
| | | // if (iv_collection.getVisibility() == View.GONE) |
| | |
| | | if (mediaPlayer != null && mediaPlayer.isPlaying()) { |
| | | int currentPosition = getSeconds(mediaPlayer.getCurrentPosition()); |
| | | tv_progress.setText(TimeUtil.getTimeDesc(currentPosition)); |
| | | seekBar.setProgress(Math.round(mediaPlayer.getCurrentPosition() * 1000 / mediaPlayer.getDuration())); |
| | | setPlayerState(); |
| | | seekBar.setProgress(Math.round(mediaPlayer.getCurrentPosition() * 1000.0f / mediaPlayer.getDuration())); |
| | | Log.i(TAG, Math.abs(mediaPlayer.getDuration() - mediaPlayer.getCurrentPosition()) + ""); |
| | | if (Math.abs(mediaPlayer.getDuration() - mediaPlayer.getCurrentPosition()) < 1000) {//播放完成 |
| | | tv_progress.removeCallbacks(playerProcessRunnable); |
| | | iv_next.performClick(); |
| | | return; |
| | | } |
| | | } |
| | | tv_progress.postDelayed(playerProcessRunnable, 1000); |
| | | } |
| | |
| | | |
| | | private void setPlayerState() { |
| | | if (mediaPlayer != null) { |
| | | if (mediaPlayer.isPlaying()) { |
| | | VideoResourceUtil.setPlayImage(iv_play, false, isLand); |
| | | aq.id(R.id.iv_play_center).visibility(View.GONE); |
| | | } else { |
| | | VideoResourceUtil.setPlayImage(iv_play, true, isLand); |
| | | if (!isLand) { |
| | | aq.id(R.id.iv_play_center).visibility(View.VISIBLE); |
| | | } |
| | | } |
| | | setPlayImage(); |
| | | } |
| | | } |
| | | |
| | |
| | | aq.id(R.id.fl_loading).visibility(View.GONE); |
| | | } |
| | | |
| | | public void onResume() { |
| | | setLayout(); |
| | | } |
| | | |
| | | public void onPause() { |
| | | setLayout(); |
| | | } |
| | | |
| | | /** |
| | | * 释放资源 |
| | | */ |