diff --git a/README.md b/README.md index 156c4316b..447fe8e85 100644 --- a/README.md +++ b/README.md @@ -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,调速后声音变调问题得到解决) diff --git a/UPDATE_VERSION.md b/UPDATE_VERSION.md index 94a651f0b..4b78e7b0b 100644 --- a/UPDATE_VERSION.md +++ b/UPDATE_VERSION.md @@ -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,调速后声音变调问题得到解决) diff --git a/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java b/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java index d8fe9c684..adc912384 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java +++ b/app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java @@ -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 list = new ArrayList<>(); diff --git a/app/src/main/java/com/example/gsyvideoplayer/PlayActivity.java b/app/src/main/java/com/example/gsyvideoplayer/PlayActivity.java index 54a6edf64..02fc4c62a 100644 --- a/app/src/main/java/com/example/gsyvideoplayer/PlayActivity.java +++ b/app/src/main/java/com/example/gsyvideoplayer/PlayActivity.java @@ -85,6 +85,7 @@ private void init() { //增加title videoPlayer.getTitleTextView().setVisibility(View.VISIBLE); videoPlayer.getTitleTextView().setText("测试视频"); + //videoPlayer.setShowPauseCover(false); //videoPlayer.setSpeed(2f); diff --git a/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java b/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java index 067e6ab69..68d350b49 100644 --- a/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java +++ b/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java @@ -127,6 +127,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. protected boolean mFirstTouch = false;//是否首次触摸 + /** * 当前UI */ @@ -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); @@ -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 @@ -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(); diff --git a/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java b/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java index 4c361af1d..3e3c84e80 100644 --- a/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java +++ b/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java @@ -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 @@ -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(); @@ -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) { @@ -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()); @@ -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; + } } diff --git a/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java b/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java index 29bc8b3dd..caac9d377 100644 --- a/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java +++ b/gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java @@ -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) {