提交 30ac84ff 编写于 作者: S shuyu

1.1.9

上级 840055a8
...@@ -17,13 +17,13 @@ ...@@ -17,13 +17,13 @@
<dependency> <dependency>
<groupId>com.shuyu</groupId> <groupId>com.shuyu</groupId>
<artifactId>gsyVideoPlayer</artifactId> <artifactId>gsyVideoPlayer</artifactId>
<version>1.1.8</version> <version>1.1.9</version>
<type>pom</type> <type>pom</type>
</dependency> </dependency>
``` ```
``` ```
compile 'com.shuyu:gsyVideoPlayer:1.1.8' compile 'com.shuyu:gsyVideoPlayer:1.1.9'
``` ```
## 效果,录屏下的屏幕旋转和实际有些出入 ## 效果,录屏下的屏幕旋转和实际有些出入
...@@ -43,6 +43,9 @@ compile 'com.shuyu:gsyVideoPlayer:1.1.8' ...@@ -43,6 +43,9 @@ compile 'com.shuyu:gsyVideoPlayer:1.1.8'
* <h4>3、详情模式</h4> * <h4>3、详情模式</h4>
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/04.gif" width="240px" height="426px"/> <img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/04.gif" width="240px" height="426px"/>
### 1.1.9 修正了回调接口VideoAllCallBack的回调结果,添加了注释,可以根据需要继承后覆写。
有全屏到非全屏,有小窗口到非小窗口,结束播放错误触摸等等的接口回调,增加了Debuger,可以使能或者关闭调试输出。
### 1.1.8 增加了如果Cache文件出现播放异常,就清除缓存文件的处理(预防),StandardGSYVideoPlayer增加了一些UI配置接口 ### 1.1.8 增加了如果Cache文件出现播放异常,就清除缓存文件的处理(预防),StandardGSYVideoPlayer增加了一些UI配置接口
......
...@@ -49,6 +49,7 @@ public class ListVideo2Activity extends AppCompatActivity { ...@@ -49,6 +49,7 @@ public class ListVideo2Activity extends AppCompatActivity {
listVideoUtil = new ListVideoUtil(this); listVideoUtil = new ListVideoUtil(this);
listVideoUtil.setFullViewContainer(videoFullContainer); listVideoUtil.setFullViewContainer(videoFullContainer);
listVideoUtil.setHideStatusBar(true); listVideoUtil.setHideStatusBar(true);
//listVideoUtil.setHideActionBar(true);
listVideoAdapter = new ListVideoAdapter(this, listVideoUtil); listVideoAdapter = new ListVideoAdapter(this, listVideoUtil);
listVideoAdapter.setRootView(activityListVideo); listVideoAdapter.setRootView(activityListVideo);
videoList.setAdapter(listVideoAdapter); videoList.setAdapter(listVideoAdapter);
......
...@@ -6,6 +6,7 @@ import android.view.View; ...@@ -6,6 +6,7 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import com.example.gsyvideoplayer.utils.JumpUtils; import com.example.gsyvideoplayer.utils.JumpUtils;
import com.shuyu.gsyvideoplayer.utils.Debuger;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
...@@ -20,6 +21,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -20,6 +21,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
Debuger.enable();
ButterKnife.bind(this); ButterKnife.bind(this);
} }
......
...@@ -11,6 +11,7 @@ import com.example.gsyvideoplayer.R; ...@@ -11,6 +11,7 @@ import com.example.gsyvideoplayer.R;
import com.example.gsyvideoplayer.model.VideoModel; import com.example.gsyvideoplayer.model.VideoModel;
import com.shuyu.gsyvideoplayer.GSYVideoManager; import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.GSYVideoPlayer; import com.shuyu.gsyvideoplayer.GSYVideoPlayer;
import com.shuyu.gsyvideoplayer.listener.StandardVideoAllCallBack;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer; import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import java.util.ArrayList; import java.util.ArrayList;
......
package com.example.gsyvideoplayer.adapter; package com.example.gsyvideoplayer.adapter;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.transition.TransitionManager;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView;
import com.example.gsyvideoplayer.R; import com.example.gsyvideoplayer.R;
import com.example.gsyvideoplayer.model.VideoModel; import com.example.gsyvideoplayer.model.VideoModel;
import com.shuyu.gsyvideoplayer.listener.StandardVideoAllCallBack;
import com.shuyu.gsyvideoplayer.utils.ListVideoUtil; import com.shuyu.gsyvideoplayer.utils.ListVideoUtil;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils; import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.example.gsyvideoplayer.utils.CommonUtil.setViewHeight;
/** /**
* Created by shuyu on 2016/11/11. * Created by shuyu on 2016/11/11.
*/ */
...@@ -104,7 +92,102 @@ public class ListVideoAdapter extends BaseAdapter { ...@@ -104,7 +92,102 @@ public class ListVideoAdapter extends BaseAdapter {
} }
}); });
listVideoUtil.setVideoAllCallBack(new StandardVideoAllCallBack() {
@Override
public void onClickStartThumb(String url, Object... objects) {
}
@Override
public void onClickBlank(String url, Object... objects) {
}
@Override
public void onClickBlankFullscreen(String url, Object... objects) {
}
@Override
public void onClickStartIcon(String url, Object... objects) {
}
@Override
public void onClickStartError(String url, Object... objects) {
}
@Override
public void onClickStop(String url, Object... objects) {
}
@Override
public void onClickStopFullscreen(String url, Object... objects) {
}
@Override
public void onClickResume(String url, Object... objects) {
}
@Override
public void onClickResumeFullscreen(String url, Object... objects) {
}
@Override
public void onClickSeekbar(String url, Object... objects) {
}
@Override
public void onClickSeekbarFullscreen(String url, Object... objects) {
}
@Override
public void onAutoComplete(String url, Object... objects) {
}
@Override
public void onEnterFullscreen(String url, Object... objects) {
}
@Override
public void onQuitFullscreen(String url, Object... objects) {
}
@Override
public void onQuitSmallWidget(String url, Object... objects) {
}
@Override
public void onEnterSmallWidget(String url, Object... objects) {
}
@Override
public void onTouchScreenSeekVolume(String url, Object... objects) {
}
@Override
public void onTouchScreenSeekPosition(String url, Object... objects) {
}
@Override
public void onTouchScreenSeekLight(String url, Object... objects) {
}
});
return convertView; return convertView;
} }
......
...@@ -18,7 +18,7 @@ org.gradle.jvmargs=-Xmx1536m ...@@ -18,7 +18,7 @@ org.gradle.jvmargs=-Xmx1536m
BINTRAY_USER= BINTRAY_USER=
BINTRAY_KEY= BINTRAY_KEY=
PROJ_GROUP=com.shuyu PROJ_GROUP=com.shuyu
PROJ_VERSION=1.1.8 PROJ_VERSION=1.1.9
PROJ_NAME=gsyVideo PROJ_NAME=gsyVideo
PROJ_WEBSITEURL=hhttps://github.com/CarGuo/GSYVideoPlayer PROJ_WEBSITEURL=hhttps://github.com/CarGuo/GSYVideoPlayer
PROJ_ISSUETRACKERURL= PROJ_ISSUETRACKERURL=
......
...@@ -8,7 +8,6 @@ import android.media.MediaPlayer; ...@@ -8,7 +8,6 @@ import android.media.MediaPlayer;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.Surface; import android.view.Surface;
import android.view.TextureView; import android.view.TextureView;
...@@ -24,12 +23,10 @@ import android.widget.TextView; ...@@ -24,12 +23,10 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.danikula.videocache.HttpProxyCacheServer; import com.danikula.videocache.HttpProxyCacheServer;
import com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener;
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
import com.shuyu.gsyvideoplayer.utils.CommonUtil; import com.shuyu.gsyvideoplayer.utils.CommonUtil;
import com.shuyu.gsyvideoplayer.utils.Debuger;
import com.shuyu.gsyvideoplayer.video.GSYBaseVideoPlayer; import com.shuyu.gsyvideoplayer.video.GSYBaseVideoPlayer;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Timer; import java.util.Timer;
...@@ -81,7 +78,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -81,7 +78,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
protected Map<String, String> mMapHeadData = new HashMap<>(); protected Map<String, String> mMapHeadData = new HashMap<>();
protected ProgressTimerTask mProgressTimerTask; protected ProgressTimerTask mProgressTimerTask;
protected AudioManager mAudioManager; //音频焦点的监听 protected AudioManager mAudioManager; //音频焦点的监听
protected VideoAllCallBack mVideoAllCallBack;
protected Handler mHandler = new Handler(); protected Handler mHandler = new Handler();
...@@ -105,7 +101,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -105,7 +101,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
protected int mThreshold = 80; //手势偏差值 protected int mThreshold = 80; //手势偏差值
protected int mSeekToInAdvance = -1; //// TODO: 2016/11/13 过广告 protected int mSeekToInAdvance = -1; //// TODO: 2016/11/13 过广告
protected int mRotate = 0; //针对某些视频的旋转信息做了旋转处理 protected int mRotate = 0; //针对某些视频的旋转信息做了旋转处理
...@@ -227,16 +223,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -227,16 +223,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
return false; return false;
} }
/**
* 设置播放过程中的回调
*
* @param mVideoAllCallBack
*/
protected void setVideoAllCallBack(VideoAllCallBack mVideoAllCallBack) {
this.mVideoAllCallBack = mVideoAllCallBack;
}
/** /**
* 设置播放显示状态 * 设置播放显示状态
* *
...@@ -292,16 +278,20 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -292,16 +278,20 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
setStateAndUi(CURRENT_STATE_PAUSE); setStateAndUi(CURRENT_STATE_PAUSE);
if (mVideoAllCallBack != null && isCurrentMediaListener()) { if (mVideoAllCallBack != null && isCurrentMediaListener()) {
if (mIfCurrentIsFullscreen) { if (mIfCurrentIsFullscreen) {
Debuger.printfLog("onClickStopFullscreen");
mVideoAllCallBack.onClickStopFullscreen(mUrl, mObjects); mVideoAllCallBack.onClickStopFullscreen(mUrl, mObjects);
} else { } else {
Debuger.printfLog("onClickStop");
mVideoAllCallBack.onClickStop(mUrl, mObjects); mVideoAllCallBack.onClickStop(mUrl, mObjects);
} }
} }
} else if (mCurrentState == CURRENT_STATE_PAUSE) { } else if (mCurrentState == CURRENT_STATE_PAUSE) {
if (mVideoAllCallBack != null && isCurrentMediaListener()) { if (mVideoAllCallBack != null && isCurrentMediaListener()) {
if (mIfCurrentIsFullscreen) { if (mIfCurrentIsFullscreen) {
Debuger.printfLog("onClickResumeFullscreen");
mVideoAllCallBack.onClickResumeFullscreen(mUrl, mObjects); mVideoAllCallBack.onClickResumeFullscreen(mUrl, mObjects);
} else { } else {
Debuger.printfLog("onClickResume");
mVideoAllCallBack.onClickResume(mUrl, mObjects); mVideoAllCallBack.onClickResume(mUrl, mObjects);
} }
} }
...@@ -312,6 +302,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -312,6 +302,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
} }
} else if (i == R.id.surface_container && mCurrentState == CURRENT_STATE_ERROR) { } else if (i == R.id.surface_container && mCurrentState == CURRENT_STATE_ERROR) {
if (mVideoAllCallBack != null) { if (mVideoAllCallBack != null) {
Debuger.printfLog("onClickStartError");
mVideoAllCallBack.onClickStartError(mUrl, mObjects); mVideoAllCallBack.onClickStartError(mUrl, mObjects);
} }
prepareVideo(); prepareVideo();
...@@ -326,8 +317,10 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -326,8 +317,10 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
*/ */
private void startButtonLogic() { private void startButtonLogic() {
if (mVideoAllCallBack != null && mCurrentState == CURRENT_STATE_NORMAL) { if (mVideoAllCallBack != null && mCurrentState == CURRENT_STATE_NORMAL) {
Debuger.printfLog("onClickStartIcon");
mVideoAllCallBack.onClickStartIcon(mUrl, mObjects); mVideoAllCallBack.onClickStartIcon(mUrl, mObjects);
} else if (mVideoAllCallBack != null) { } else if (mVideoAllCallBack != null) {
Debuger.printfLog("onClickStartError");
mVideoAllCallBack.onClickStartError(mUrl, mObjects); mVideoAllCallBack.onClickStartError(mUrl, mObjects);
} }
prepareVideo(); prepareVideo();
...@@ -451,15 +444,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -451,15 +444,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
}); });
} }
public void setSmallCloseShow() {
mSmallClose.setVisibility(VISIBLE);
}
public void setSmallCloseHide() {
mSmallClose.setVisibility(GONE);
}
/** /**
* 设置界面选择 * 设置界面选择
*/ */
...@@ -533,9 +517,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -533,9 +517,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
if (absDeltaX >= mThreshold) { if (absDeltaX >= mThreshold) {
mChangePosition = true; mChangePosition = true;
mDownPosition = getCurrentPositionWhenPlaying(); mDownPosition = getCurrentPositionWhenPlaying();
if (mVideoAllCallBack != null && isCurrentMediaListener()) {
mVideoAllCallBack.onTouchScreenSeekPosition(mUrl, mObjects);
}
} else { } else {
if (mFirstTouch) { if (mFirstTouch) {
mBrightness = mDownX < mScreenWidth * 0.5f; mBrightness = mDownX < mScreenWidth * 0.5f;
...@@ -544,9 +525,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -544,9 +525,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
if (!mBrightness) { if (!mBrightness) {
mChangeVolume = true; mChangeVolume = true;
mGestureDownVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); mGestureDownVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
if (mVideoAllCallBack != null && isCurrentMediaListener()) {
mVideoAllCallBack.onTouchScreenSeekVolume(mUrl, mObjects);
}
} }
} }
} }
...@@ -559,7 +537,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -559,7 +537,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
mSeekTimePosition = totalTimeDuration; mSeekTimePosition = totalTimeDuration;
String seekTime = CommonUtil.stringForTime(mSeekTimePosition); String seekTime = CommonUtil.stringForTime(mSeekTimePosition);
String totalTime = CommonUtil.stringForTime(totalTimeDuration); String totalTime = CommonUtil.stringForTime(totalTimeDuration);
showProgressDialog(deltaX, seekTime, mSeekTimePosition, totalTime, totalTimeDuration); showProgressDialog(deltaX, seekTime, mSeekTimePosition, totalTime, totalTimeDuration);
} else if (mChangeVolume) { } else if (mChangeVolume) {
deltaY = -deltaY; deltaY = -deltaY;
...@@ -585,15 +562,22 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -585,15 +562,22 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
int duration = getDuration(); int duration = getDuration();
int progress = mSeekTimePosition * 100 / (duration == 0 ? 1 : duration); int progress = mSeekTimePosition * 100 / (duration == 0 ? 1 : duration);
mProgressBar.setProgress(progress); mProgressBar.setProgress(progress);
} if (mVideoAllCallBack != null && isCurrentMediaListener()) {
startProgressTimer(); Debuger.printfLog("onTouchScreenSeekPosition");
if (mVideoAllCallBack != null && isCurrentMediaListener()) { mVideoAllCallBack.onTouchScreenSeekPosition(mUrl, mObjects);
if (mIfCurrentIsFullscreen) { }
mVideoAllCallBack.onClickSeekbarFullscreen(mUrl, mObjects); } else if (mBrightness) {
} else { if (mVideoAllCallBack != null && isCurrentMediaListener()) {
mVideoAllCallBack.onClickSeekbar(mUrl, mObjects); Debuger.printfLog("onTouchScreenSeekLight");
mVideoAllCallBack.onTouchScreenSeekLight(mUrl, mObjects);
}
} else if (mChangeVolume) {
if (mVideoAllCallBack != null && isCurrentMediaListener()) {
Debuger.printfLog("onTouchScreenSeekVolume");
mVideoAllCallBack.onTouchScreenSeekVolume(mUrl, mObjects);
} }
} }
startProgressTimer();
break; break;
} }
} else if (id == R.id.progress) { } else if (id == R.id.progress) {
...@@ -667,6 +651,15 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -667,6 +651,15 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
*/ */
@Override @Override
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
if (mVideoAllCallBack != null && isCurrentMediaListener()) {
if (isIfCurrentIsFullscreen()) {
Debuger.printfLog("onClickSeekbarFullscreen");
mVideoAllCallBack.onClickSeekbarFullscreen(mUrl, mObjects);
} else {
Debuger.printfLog("onClickSeekbar");
mVideoAllCallBack.onClickSeekbar(mUrl, mObjects);
}
}
if (GSYVideoManager.instance().getMediaPlayer() != null && GSYVideoManager.instance().getMediaPlayer().isPlaying()) { if (GSYVideoManager.instance().getMediaPlayer() != null && GSYVideoManager.instance().getMediaPlayer().isPlaying()) {
int time = seekBar.getProgress() * getDuration() / 100; int time = seekBar.getProgress() * getDuration() / 100;
GSYVideoManager.instance().getMediaPlayer().seekTo(time); GSYVideoManager.instance().getMediaPlayer().seekTo(time);
...@@ -688,11 +681,8 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -688,11 +681,8 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
@Override @Override
public void onAutoCompletion() { public void onAutoCompletion() {
if (mVideoAllCallBack != null && isCurrentMediaListener()) { if (mVideoAllCallBack != null && isCurrentMediaListener()) {
if (mIfCurrentIsFullscreen) { Debuger.printfLog("onAutoComplete");
mVideoAllCallBack.onAutoCompleteFullscreen(mUrl, mObjects); mVideoAllCallBack.onAutoComplete(mUrl, mObjects);
} else {
mVideoAllCallBack.onAutoComplete(mUrl, mObjects);
}
} }
setStateAndUi(CURRENT_STATE_AUTO_COMPLETE); setStateAndUi(CURRENT_STATE_AUTO_COMPLETE);
if (mTextureViewContainer.getChildCount() > 0) { if (mTextureViewContainer.getChildCount() > 0) {
...@@ -719,7 +709,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -719,7 +709,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
if (IF_FULLSCREEN_FROM_NORMAL) {//如果在进入全屏后播放完就初始化自己非全屏的控件 if (IF_FULLSCREEN_FROM_NORMAL) {//如果在进入全屏后播放完就初始化自己非全屏的控件
IF_FULLSCREEN_FROM_NORMAL = false; IF_FULLSCREEN_FROM_NORMAL = false;
GSYVideoManager.instance().lastListener().onCompletion(); GSYVideoManager.instance().lastListener().onCompletion();//回到上面的onAutoCompletion
} }
GSYVideoManager.instance().setListener(null); GSYVideoManager.instance().setListener(null);
GSYVideoManager.instance().setLastListener(null); GSYVideoManager.instance().setLastListener(null);
...@@ -748,12 +738,12 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -748,12 +738,12 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
if (what != 38 && what != -38) { if (what != 38 && what != -38) {
setStateAndUi(CURRENT_STATE_ERROR); setStateAndUi(CURRENT_STATE_ERROR);
if (mCacheFile) { if (mCacheFile) {
Log.e(TAG, " mCacheFile Local Error " + mUrl); Debuger.printfError(" mCacheFile Local Error " + mUrl);
//可能是因为缓存文件除了问题 //可能是因为缓存文件除了问题
CommonUtil.deleteFile(mUrl.replace("file://", "")); CommonUtil.deleteFile(mUrl.replace("file://", ""));
mUrl = mOriginUrl; mUrl = mOriginUrl;
} else if (mUrl.contains("127.0.0.1")) { } else if (mUrl.contains("127.0.0.1")) {
Log.e(TAG, " mCacheFile Download Error " + mUrl); Debuger.printfError(" mCacheFile Download Error " + mUrl);
CommonUtil.deleteFile(mUrl.replace("file://", "") + ".downlad"); CommonUtil.deleteFile(mUrl.replace("file://", "") + ".downlad");
mUrl = mOriginUrl; mUrl = mOriginUrl;
} }
...@@ -870,6 +860,9 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -870,6 +860,9 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
mTotalTimeTextView.setText(CommonUtil.stringForTime(0)); mTotalTimeTextView.setText(CommonUtil.stringForTime(0));
} }
/**
* 页面销毁了记得调用是否所有的video
*/
public static void releaseAllVideos() { public static void releaseAllVideos() {
if (IF_RELEASE_WHEN_ON_PAUSE) { if (IF_RELEASE_WHEN_ON_PAUSE) {
if (GSYVideoManager.instance().listener() != null) { if (GSYVideoManager.instance().listener() != null) {
...@@ -991,7 +984,21 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View. ...@@ -991,7 +984,21 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
} }
/** /**
* 退出全屏 * 显示小窗口的关闭按键
*/
public void setSmallCloseShow() {
mSmallClose.setVisibility(VISIBLE);
}
/**
* 隐藏小窗口的关闭按键
*/
public void setSmallCloseHide() {
mSmallClose.setVisibility(GONE);
}
/**
* 退出全屏,主要用于返回键
* *
* @return 返回是否全屏 * @return 返回是否全屏
*/ */
......
...@@ -2,10 +2,13 @@ package com.shuyu.gsyvideoplayer.listener; ...@@ -2,10 +2,13 @@ package com.shuyu.gsyvideoplayer.listener;
public interface StandardVideoAllCallBack extends VideoAllCallBack { public interface StandardVideoAllCallBack extends VideoAllCallBack {
//点击了空白区域开始播放
void onClickStartThumb(String url, Object... objects); void onClickStartThumb(String url, Object... objects);
//点击了播放中的空白区域
void onClickBlank(String url, Object... objects); void onClickBlank(String url, Object... objects);
//点击了全屏播放中的空白区域
void onClickBlankFullscreen(String url, Object... objects); void onClickBlankFullscreen(String url, Object... objects);
} }
...@@ -6,32 +6,52 @@ package com.shuyu.gsyvideoplayer.listener; ...@@ -6,32 +6,52 @@ package com.shuyu.gsyvideoplayer.listener;
*/ */
public interface VideoAllCallBack { public interface VideoAllCallBack {
//点击了开始按键播放
void onClickStartIcon(String url, Object... objects); void onClickStartIcon(String url, Object... objects);
//点击了错误状态下的开始按键
void onClickStartError(String url, Object... objects); void onClickStartError(String url, Object... objects);
//点击了播放状态下的开始按键--->停止
void onClickStop(String url, Object... objects); void onClickStop(String url, Object... objects);
//点击了全屏播放状态下的开始按键--->停止
void onClickStopFullscreen(String url, Object... objects); void onClickStopFullscreen(String url, Object... objects);
//点击了暂停状态下的开始按键--->播放
void onClickResume(String url, Object... objects); void onClickResume(String url, Object... objects);
//点击了全屏暂停状态下的开始按键--->播放
void onClickResumeFullscreen(String url, Object... objects); void onClickResumeFullscreen(String url, Object... objects);
//点击了空白弹出seekbar
void onClickSeekbar(String url, Object... objects); void onClickSeekbar(String url, Object... objects);
//点击了全屏的seekbar
void onClickSeekbarFullscreen(String url, Object... objects); void onClickSeekbarFullscreen(String url, Object... objects);
//播放完了
void onAutoComplete(String url, Object... objects); void onAutoComplete(String url, Object... objects);
void onAutoCompleteFullscreen(String url, Object... objects); //进去全屏
void onEnterFullscreen(String url, Object... objects); void onEnterFullscreen(String url, Object... objects);
//退出全屏
void onQuitFullscreen(String url, Object... objects); void onQuitFullscreen(String url, Object... objects);
//进入小窗口
void onQuitSmallWidget(String url, Object... objects);
//退出小窗口
void onEnterSmallWidget(String url, Object... objects);
//触摸调整声音
void onTouchScreenSeekVolume(String url, Object... objects); void onTouchScreenSeekVolume(String url, Object... objects);
//触摸调整进度
void onTouchScreenSeekPosition(String url, Object... objects); void onTouchScreenSeekPosition(String url, Object... objects);
//触摸调整亮度
void onTouchScreenSeekLight(String url, Object... objects);
} }
package com.shuyu.gsyvideoplayer.utils;
import android.app.Activity;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
/**
* Created by shuyu on 2016/11/23.
*/
public class Debuger {
static final String LOG_TAG = "GSYVideoPlayer";
static boolean DEBUG_TAG = false;
public static void enable() {
DEBUG_TAG = true;
}
public static void disable() {
DEBUG_TAG = false;
}
public static boolean getDebugMode() {
return DEBUG_TAG;
}
public static void printfLog(String tag, String log) {
if (DEBUG_TAG && log != null) {
if (!TextUtils.isEmpty(log))
Log.i(tag, log);
}
}
public static void printfLog(String log) {
printfLog(LOG_TAG, log);
}
public static void printfWarning(String tag, String log) {
if (DEBUG_TAG && log != null) {
if (!TextUtils.isEmpty(log))
Log.w(tag, log);
}
}
public static void printfWarning(String log) {
printfWarning(LOG_TAG, log);
}
public static void printfError(String log) {
if (DEBUG_TAG) {
if (!TextUtils.isEmpty(log))
Log.e(LOG_TAG, log);
}
}
public static void printfError(String Tag, String log) {
if (DEBUG_TAG) {
if (!TextUtils.isEmpty(log))
Log.e(Tag, log);
}
}
public static void printfError(String log, Exception e) {
if (DEBUG_TAG) {
if (!TextUtils.isEmpty(log))
Log.e(LOG_TAG, log);
e.printStackTrace();
}
}
public static void Toast(Activity activity, String log) {
if (DEBUG_TAG) {
if (!TextUtils.isEmpty(log))
Toast.makeText(activity, log, Toast.LENGTH_SHORT).show();
}
}
}
...@@ -14,6 +14,8 @@ import android.widget.FrameLayout; ...@@ -14,6 +14,8 @@ import android.widget.FrameLayout;
import com.shuyu.gsyvideoplayer.GSYVideoPlayer; import com.shuyu.gsyvideoplayer.GSYVideoPlayer;
import com.shuyu.gsyvideoplayer.R; import com.shuyu.gsyvideoplayer.R;
import com.shuyu.gsyvideoplayer.listener.StandardVideoAllCallBack;
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
import com.shuyu.gsyvideoplayer.video.GSYBaseVideoPlayer; import com.shuyu.gsyvideoplayer.video.GSYBaseVideoPlayer;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer; import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
...@@ -22,6 +24,8 @@ import static com.shuyu.gsyvideoplayer.utils.CommonUtil.getStatusBarHeight; ...@@ -22,6 +24,8 @@ import static com.shuyu.gsyvideoplayer.utils.CommonUtil.getStatusBarHeight;
/** /**
* Created by shuyu on 2016/11/12. * Created by shuyu on 2016/11/12.
* 列表工具类
* 其中记得设置进来的fullViewContainer必须是在Activity布局下的最外层布局
*/ */
public class ListVideoUtil { public class ListVideoUtil {
...@@ -32,6 +36,8 @@ public class ListVideoUtil { ...@@ -32,6 +36,8 @@ public class ListVideoUtil {
private ViewGroup listParent;//记录列表中item的父布局 private ViewGroup listParent;//记录列表中item的父布局
private ViewGroup.LayoutParams listParams; private ViewGroup.LayoutParams listParams;
private OrientationUtils orientationUtils; private OrientationUtils orientationUtils;
private StandardVideoAllCallBack videoAllCallBack;
private String url;
private Context context; private Context context;
private int playPosition = -1; // 播放的位置 private int playPosition = -1; // 播放的位置
...@@ -42,6 +48,7 @@ public class ListVideoUtil { ...@@ -42,6 +48,7 @@ public class ListVideoUtil {
private boolean hideStatusBar; //是否隐藏有状态bar private boolean hideStatusBar; //是否隐藏有状态bar
private boolean hideActionBar; //是否隐藏有状态ActionBar private boolean hideActionBar; //是否隐藏有状态ActionBar
private int[] listItemRect;//当前item框的屏幕位置 private int[] listItemRect;//当前item框的屏幕位置
private int[] listItemSize;//当前item的大小 private int[] listItemSize;//当前item的大小
...@@ -105,6 +112,8 @@ public class ListVideoUtil { ...@@ -105,6 +112,8 @@ public class ListVideoUtil {
smallVideoToNormal(); smallVideoToNormal();
} }
this.url = url;
gsyVideoPlayer.release(); gsyVideoPlayer.release();
gsyVideoPlayer.setUp(url, true, ""); gsyVideoPlayer.setUp(url, true, "");
...@@ -243,6 +252,11 @@ public class ListVideoUtil { ...@@ -243,6 +252,11 @@ public class ListVideoUtil {
listParent.addView(gsyVideoPlayer, listParams); listParent.addView(gsyVideoPlayer, listParams);
gsyVideoPlayer.getFullscreenButton().setImageResource(R.drawable.video_enlarge); gsyVideoPlayer.getFullscreenButton().setImageResource(R.drawable.video_enlarge);
gsyVideoPlayer.getBackButton().setVisibility(View.GONE); gsyVideoPlayer.getBackButton().setVisibility(View.GONE);
gsyVideoPlayer.setIfCurrentIsFullscreen(false);
if (videoAllCallBack != null) {
Debuger.printfLog("onQuitFullscreen");
videoAllCallBack.onQuitFullscreen(url);
}
} }
}, delay); }, delay);
} }
...@@ -293,6 +307,11 @@ public class ListVideoUtil { ...@@ -293,6 +307,11 @@ public class ListVideoUtil {
} }
}, time); }, time);
} }
gsyVideoPlayer.setIfCurrentIsFullscreen(true);
if (videoAllCallBack != null) {
Debuger.printfLog("onEnterFullscreen");
videoAllCallBack.onEnterFullscreen(this.url);
}
} }
/** /**
...@@ -454,6 +473,16 @@ public class ListVideoUtil { ...@@ -454,6 +473,16 @@ public class ListVideoUtil {
this.showFullAnimation = showFullAnimation; this.showFullAnimation = showFullAnimation;
} }
/**
* 视频接口回调
*
* @param videoAllCallBack 回调
*/
public void setVideoAllCallBack(StandardVideoAllCallBack videoAllCallBack) {
this.videoAllCallBack = videoAllCallBack;
gsyVideoPlayer.setStandardVideoAllCallBack(videoAllCallBack);
}
public int getPlayPosition() { public int getPlayPosition() {
return playPosition; return playPosition;
} }
......
...@@ -21,7 +21,9 @@ import com.shuyu.gsyvideoplayer.GSYVideoPlayer; ...@@ -21,7 +21,9 @@ import com.shuyu.gsyvideoplayer.GSYVideoPlayer;
import com.shuyu.gsyvideoplayer.R; import com.shuyu.gsyvideoplayer.R;
import com.shuyu.gsyvideoplayer.SmallVideoTouch; import com.shuyu.gsyvideoplayer.SmallVideoTouch;
import com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener; import com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener;
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
import com.shuyu.gsyvideoplayer.utils.CommonUtil; import com.shuyu.gsyvideoplayer.utils.CommonUtil;
import com.shuyu.gsyvideoplayer.utils.Debuger;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils; import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
...@@ -38,10 +40,10 @@ import static com.shuyu.gsyvideoplayer.utils.CommonUtil.showSupportActionBar; ...@@ -38,10 +40,10 @@ import static com.shuyu.gsyvideoplayer.utils.CommonUtil.showSupportActionBar;
public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMediaPlayerListener { public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMediaPlayerListener {
protected static final int FULLSCREEN_ID = 85597;
public static final int SMALL_ID = 84778; public static final int SMALL_ID = 84778;
protected static final int FULLSCREEN_ID = 85597;
protected static long CLICK_QUIT_FULLSCREEN_TIME = 0; protected static long CLICK_QUIT_FULLSCREEN_TIME = 0;
protected boolean mActionBar = false;//是否需要在利用window实现全屏幕的时候隐藏actionbar protected boolean mActionBar = false;//是否需要在利用window实现全屏幕的时候隐藏actionbar
...@@ -68,17 +70,18 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia ...@@ -68,17 +70,18 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
protected String mUrl; protected String mUrl;
protected Object[] mObjects; protected Object[] mObjects;
protected ViewGroup mTextureViewContainer; protected ViewGroup mTextureViewContainer;
protected View mSmallClose;
protected VideoAllCallBack mVideoAllCallBack;
private OrientationUtils mOrientationUtils; private OrientationUtils mOrientationUtils;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
protected View mSmallClose;
public GSYBaseVideoPlayer(Context context) { public GSYBaseVideoPlayer(Context context) {
super(context); super(context);
...@@ -140,6 +143,11 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia ...@@ -140,6 +143,11 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
gsyVideoPlayer.setIfCurrentIsFullscreen(true); gsyVideoPlayer.setIfCurrentIsFullscreen(true);
mOrientationUtils = new OrientationUtils((Activity) context, gsyVideoPlayer); mOrientationUtils = new OrientationUtils((Activity) context, gsyVideoPlayer);
mOrientationUtils.setEnable(mRotateViewAuto); mOrientationUtils.setEnable(mRotateViewAuto);
if (mVideoAllCallBack != null) {
Debuger.printfError("onEnterFullscreen");
mVideoAllCallBack.onEnterFullscreen(mUrl, mObjects);
}
mIfCurrentIsFullscreen = true;
} }
/** /**
...@@ -159,6 +167,11 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia ...@@ -159,6 +167,11 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
setStateAndUi(mCurrentState); setStateAndUi(mCurrentState);
addTextureView(); addTextureView();
CLICK_QUIT_FULLSCREEN_TIME = System.currentTimeMillis(); CLICK_QUIT_FULLSCREEN_TIME = System.currentTimeMillis();
if (mVideoAllCallBack != null) {
Debuger.printfError("onQuitFullscreen");
mVideoAllCallBack.onQuitFullscreen(mUrl, mObjects);
}
mIfCurrentIsFullscreen = false;
} }
/** /**
...@@ -195,6 +208,9 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia ...@@ -195,6 +208,9 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
Constructor<GSYBaseVideoPlayer> constructor = (Constructor<GSYBaseVideoPlayer>) GSYBaseVideoPlayer.this.getClass().getConstructor(Context.class); Constructor<GSYBaseVideoPlayer> constructor = (Constructor<GSYBaseVideoPlayer>) GSYBaseVideoPlayer.this.getClass().getConstructor(Context.class);
final GSYBaseVideoPlayer gsyVideoPlayer = constructor.newInstance(getContext()); final GSYBaseVideoPlayer gsyVideoPlayer = constructor.newInstance(getContext());
gsyVideoPlayer.setId(FULLSCREEN_ID); gsyVideoPlayer.setId(FULLSCREEN_ID);
gsyVideoPlayer.setIfCurrentIsFullscreen(true);
gsyVideoPlayer.setVideoAllCallBack(mVideoAllCallBack);
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
final int w = wm.getDefaultDisplay().getWidth(); final int w = wm.getDefaultDisplay().getWidth();
final int h = wm.getDefaultDisplay().getHeight(); final int h = wm.getDefaultDisplay().getHeight();
...@@ -254,7 +270,6 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia ...@@ -254,7 +270,6 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
* 退出window层播放全屏效果 * 退出window层播放全屏效果
*/ */
public void clearFullscreenLayout() { public void clearFullscreenLayout() {
int delay = mOrientationUtils.backToProtVideo(); int delay = mOrientationUtils.backToProtVideo();
mOrientationUtils.setEnable(false); mOrientationUtils.setEnable(false);
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
...@@ -349,6 +364,11 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia ...@@ -349,6 +364,11 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
GSYVideoManager.instance().setLastListener(this); GSYVideoManager.instance().setLastListener(this);
GSYVideoManager.instance().setListener(gsyVideoPlayer); GSYVideoManager.instance().setListener(gsyVideoPlayer);
if (mVideoAllCallBack != null) {
Debuger.printfError("onEnterSmallWidget");
mVideoAllCallBack.onEnterSmallWidget(mUrl, mObjects);
}
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
...@@ -373,6 +393,10 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia ...@@ -373,6 +393,10 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
setStateAndUi(mCurrentState); setStateAndUi(mCurrentState);
addTextureView(); addTextureView();
CLICK_QUIT_FULLSCREEN_TIME = System.currentTimeMillis(); CLICK_QUIT_FULLSCREEN_TIME = System.currentTimeMillis();
if (mVideoAllCallBack != null) {
Debuger.printfLog("onQuitSmallWidget");
mVideoAllCallBack.onQuitSmallWidget(mUrl, mObjects);
}
} }
...@@ -461,4 +485,15 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia ...@@ -461,4 +485,15 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
public void setShowFullAnimation(boolean showFullAnimation) { public void setShowFullAnimation(boolean showFullAnimation) {
this.mShowFullAnimation = showFullAnimation; this.mShowFullAnimation = showFullAnimation;
} }
/**
* 设置播放过程中的回调
*
* @param mVideoAllCallBack
*/
public void setVideoAllCallBack(VideoAllCallBack mVideoAllCallBack) {
this.mVideoAllCallBack = mVideoAllCallBack;
}
} }
...@@ -27,6 +27,7 @@ import com.shuyu.gsyvideoplayer.GSYVideoPlayer; ...@@ -27,6 +27,7 @@ import com.shuyu.gsyvideoplayer.GSYVideoPlayer;
import com.shuyu.gsyvideoplayer.R; import com.shuyu.gsyvideoplayer.R;
import com.shuyu.gsyvideoplayer.listener.StandardVideoAllCallBack; import com.shuyu.gsyvideoplayer.listener.StandardVideoAllCallBack;
import com.shuyu.gsyvideoplayer.utils.CommonUtil; import com.shuyu.gsyvideoplayer.utils.CommonUtil;
import com.shuyu.gsyvideoplayer.utils.Debuger;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
...@@ -239,8 +240,10 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer { ...@@ -239,8 +240,10 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
} else if (i == R.id.surface_container) { } else if (i == R.id.surface_container) {
if (mStandardVideoAllCallBack != null && isCurrentMediaListener()) { if (mStandardVideoAllCallBack != null && isCurrentMediaListener()) {
if (mIfCurrentIsFullscreen) { if (mIfCurrentIsFullscreen) {
Debuger.printfLog("onClickBlankFullscreen");
mStandardVideoAllCallBack.onClickBlankFullscreen(mUrl, mObjects); mStandardVideoAllCallBack.onClickBlankFullscreen(mUrl, mObjects);
} else { } else {
Debuger.printfLog("onClickBlank");
mStandardVideoAllCallBack.onClickBlank(mUrl, mObjects); mStandardVideoAllCallBack.onClickBlank(mUrl, mObjects);
} }
} }
...@@ -274,6 +277,7 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer { ...@@ -274,6 +277,7 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
@Override @Override
public void startPlayLogic() { public void startPlayLogic() {
if (mStandardVideoAllCallBack != null) { if (mStandardVideoAllCallBack != null) {
Debuger.printfLog("onClickStartThumb");
mStandardVideoAllCallBack.onClickStartThumb(mUrl, mObjects); mStandardVideoAllCallBack.onClickStartThumb(mUrl, mObjects);
} }
prepareVideo(); prepareVideo();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册