Skip to content

Commit

Permalink
增加了暂停图片的开关 (2017-04-28)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Apr 28, 2017
1 parent 15f9a3b commit 5806005
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 10 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,18 @@ dependencies {
* 修改了循环播放的UI问题
* 修改了本地文件或者已缓存文件,显示进度问题
* GSYVideoType增加SCREEN_TYPE_FULL类型,通过按照比例裁减放大视频,达到全屏
* 增加setShowPauseCover接口

```
/**
* 是否需要加载显示暂停的cover图片
* 打开状态下,暂停退到后台,再回到前台不会显示黑屏,但可以对某些机型有概率出现OOM
* 关闭情况下,暂停退到后台,再回到前台显示黑屏
*
* @param showPauseCover 默认true
*/
public void setShowPauseCover(boolean showPauseCover)
```

### 1.6.4(2017-04-20)
* update ijk to 0.7.9 (增加了soundTouch,调速后声音变调问题得到解决)
Expand Down
12 changes: 12 additions & 0 deletions UPDATE_VERSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
* 修改了循环播放的UI问题
* 修改了本地文件或者已缓存文件,显示进度问题
* GSYVideoType增加SCREEN_TYPE_FULL类型,通过按照比例裁减放大视频,达到全屏
* 增加setShowPauseCover接口

```
/**
* 是否需要加载显示暂停的cover图片
* 打开状态下,暂停退到后台,再回到前台不会显示黑屏,但可以对某些机型有概率出现OOM
* 关闭情况下,暂停退到后台,再回到前台显示黑屏
*
* @param showPauseCover 默认true
*/
public void setShowPauseCover(boolean showPauseCover)
```

### 1.6.4(2017-04-20)
* update ijk to 0.7.9 (增加了soundTouch,调速后声音变调问题得到解决)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ protected void onCreate(Bundle savedInstanceState) {
//String url = "http://pl-ali.youku.com/playlist/m3u8?type=mp4&ts=1490185963&keyframe=0&vid=XMjYxOTQ1Mzg2MA==&ep=ciadGkiFU8cF4SvajD8bYyuwJiYHXJZ3rHbN%2FrYDAcZuH%2BrC6DPcqJ21TPs%3D&sid=04901859548541247bba8&token=0524&ctype=12&ev=1&oip=976319194";
//String url = "http://hls.ciguang.tv/hdtv/video.m3u8";
//String url = "https://res.exexm.com/cw_145225549855002";
detailPlayer.setUp(url, false, null, "测试视频");
detailPlayer.setLooping(true);
detailPlayer.setUp(url, true, null, "测试视频");
//detailPlayer.setLooping(true);
//detailPlayer.setShowPauseCover(false);
/*VideoOptionModel videoOptionModel =
new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 5);
List<VideoOptionModel> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private void init() {
//增加title
videoPlayer.getTitleTextView().setVisibility(View.VISIBLE);
videoPlayer.getTitleTextView().setText("测试视频");
//videoPlayer.setShowPauseCover(false);

//videoPlayer.setSpeed(2f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.

protected boolean mFirstTouch = false;//是否首次触摸


/**
* 当前UI
*/
Expand Down Expand Up @@ -707,7 +708,7 @@ public boolean onTouch(View v, MotionEvent event) {
protected void showPauseCover() {
try {
if (mCurrentState == CURRENT_STATE_PAUSE && mFullPauseBitmap != null
&& !mFullPauseBitmap.isRecycled()) {
&& !mFullPauseBitmap.isRecycled() && mShowPauseCover) {
mCoverImageView.setRotation(mTextureView.getRotation());
mCoverImageView.setImageBitmap(mFullPauseBitmap);
mCoverImageView.setVisibility(VISIBLE);
Expand All @@ -723,7 +724,7 @@ protected void showPauseCover() {
protected void releasePauseCover() {
try {
if (mCurrentState != CURRENT_STATE_PAUSE && mFullPauseBitmap != null
&& !mFullPauseBitmap.isRecycled()) {
&& !mFullPauseBitmap.isRecycled() && mShowPauseCover) {
mCoverImageView.setImageResource(R.drawable.empty_drawable);
mCoverImageView.setVisibility(GONE);
//如果在这里销毁,可能会draw a recycler bitmap error
Expand All @@ -740,7 +741,7 @@ protected void releasePauseCover() {
protected void releasePauseCoverAndBitmap() {
try {
if (mCurrentState != CURRENT_STATE_PAUSE && mFullPauseBitmap != null
&& !mFullPauseBitmap.isRecycled()) {
&& !mFullPauseBitmap.isRecycled() && mShowPauseCover) {
mCoverImageView.setImageResource(R.drawable.empty_drawable);
mCoverImageView.setVisibility(GONE);
mFullPauseBitmap.recycle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia

protected boolean mIsTouchWigetFull = true; //是否支持全屏滑动触摸有效

protected boolean mShowPauseCover = true;//是否显示暂停图片

protected Context mContext;

protected String mOriginUrl; //原来的url
Expand Down Expand Up @@ -363,6 +365,7 @@ public void run() {
gsyVideoPlayer.mShrinkImageRes = mShrinkImageRes;
gsyVideoPlayer.mEnlargeImageRes = mEnlargeImageRes;
gsyVideoPlayer.mRotate = mRotate;
gsyVideoPlayer.mShowPauseCover = mShowPauseCover;
gsyVideoPlayer.setUp(mOriginUrl, mCache, mCachePath, mMapHeadData, mObjects);
gsyVideoPlayer.setStateAndUi(mCurrentState);
gsyVideoPlayer.addTextureView();
Expand Down Expand Up @@ -461,7 +464,7 @@ public void run() {
*/
private void pauseFullCoverLogic() {
if (mCurrentState == GSYVideoPlayer.CURRENT_STATE_PAUSE && mTextureView != null
&& (mFullPauseBitmap == null || mFullPauseBitmap.isRecycled())) {
&& (mFullPauseBitmap == null || mFullPauseBitmap.isRecycled()) && mShowPauseCover) {
try {
mFullPauseBitmap = mTextureView.getBitmap(mTextureView.getSizeW(), mTextureView.getSizeH());
} catch (Exception e) {
Expand All @@ -477,12 +480,12 @@ private void pauseFullCoverLogic() {
private void pauseFullBackCoverLogic(GSYBaseVideoPlayer gsyVideoPlayer) {
//如果是暂停状态
if (gsyVideoPlayer.mCurrentState == GSYVideoPlayer.CURRENT_STATE_PAUSE
&& gsyVideoPlayer.mTextureView != null) {
&& gsyVideoPlayer.mTextureView != null && mShowPauseCover) {
//全屏的位图还在,说明没播放,直接用原来的
if (gsyVideoPlayer.mFullPauseBitmap != null
&& !gsyVideoPlayer.mFullPauseBitmap.isRecycled()) {
&& !gsyVideoPlayer.mFullPauseBitmap.isRecycled() && mShowPauseCover) {
mFullPauseBitmap = gsyVideoPlayer.mFullPauseBitmap;
} else {
} else if (mShowPauseCover) {
//不在了说明已经播放过,还是暂停的话,我们拿回来就好
try {
mFullPauseBitmap = mTextureView.getBitmap(mTextureView.getSizeW(), mTextureView.getSizeH());
Expand Down Expand Up @@ -805,4 +808,18 @@ public void setShrinkImageRes(int mShrinkImageRes) {
}


public boolean isShowPauseCover() {
return mShowPauseCover;
}

/**
* 是否需要加载显示暂停的cover图片
* 打开状态下,暂停退到后台,再回到前台不会显示黑屏,但可以对某些机型有概率出现OOM
* 关闭情况下,暂停退到后台,再回到前台显示黑屏
*
* @param showPauseCover 默认true
*/
public void setShowPauseCover(boolean showPauseCover) {
this.mShowPauseCover = showPauseCover;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ protected void updateStartImage() {


private void updatePauseCover() {
if (mFullPauseBitmap == null || mFullPauseBitmap.isRecycled()) {
if ((mFullPauseBitmap == null || mFullPauseBitmap.isRecycled()) && mShowPauseCover) {
try {
mFullPauseBitmap = mTextureView.getBitmap(mTextureView.getSizeW(), mTextureView.getSizeH());
} catch (Exception e) {
Expand Down

0 comments on commit 5806005

Please sign in to comment.