@Override public void onPrepared(MediaPlayer mp) { if (isPrepare) { if (playType == PLAY_TYPE_LOD || playType == PLAY_TYPE_ONDEMAND) { // TODO 数据库操作 记忆续播 MPConPlayManager cPm = MPConPlayUtils.findConnectionPlay(currentPosition, parentName, getChildName()); if (cPm != null && cPm.getEpisodePos() == currentPosition && cPm.getPlayIndex() != 0) { mp.seekTo(cPm.getPlayIndex()); } mHandler.sendEmptyMessage(SHOW_CONTROL_ANIMATION); } mp.start(); isPrepare = false; if (mDialog != null && mDialog.isShowing()) { mDialog.dismiss(); } // 判断是否是本地播放或在线点播 if (playType == PLAY_TYPE_LOD || playType == PLAY_TYPE_ONDEMAND) { if (mp.isPlaying() && !mSeekBar.isPressed()) { mHandler.sendEmptyMessage(UPDATA_PLAY_TIME); } } mProgressBar.setVisibility(View.INVISIBLE); mPlayer.setScreenOnWhilePlaying(true); } }
@Override public void onCompletion(MediaPlayer mp) { if (isError) return; if (playType == PLAY_TYPE_ONDEMAND || playType == PLAY_TYPE_LOD) { mHandler.removeMessages(UPDATA_PLAY_TIME); currentPosition += 1; if (posCallback != null) posCallback.CallBack(currentPosition); if (currentPosition >= getUrlListSize()) { currentPosition = getUrlListSize() - 1; ((Activity) mContext).finish(); MPConPlayUtils.deletePlayData(getParentName(), getChildName()); return; } MPConPlayUtils.deletePlayData(getParentName(), getChildName()); changeChannel(currentPosition); } }
/** 记录退出后播放位置 */ private void rePlayPosition() { // TODO 待解决 if (mPlayer != null) { if (playType == PLAY_TYPE_LOD || playType == PLAY_TYPE_ONDEMAND) { MPConPlayUtils.updateLastTime( getParentName(), getChildName(), currentPosition, mPlayer.getCurrentPosition()); } } }