提交 678e5a99 编写于 作者: S shuyu

1.1.8

上级 ff93aa80
......@@ -17,13 +17,13 @@
<dependency>
<groupId>com.shuyu</groupId>
<artifactId>gsyVideoPlayer</artifactId>
<version>1.1.7</version>
<version>1.1.8</version>
<type>pom</type>
</dependency>
```
```
compile 'com.shuyu:gsyVideoPlayer:1.1.7'
compile 'com.shuyu:gsyVideoPlayer:1.1.8'
```
## 效果,录屏下的屏幕旋转和实际有些出入
......@@ -43,6 +43,39 @@ compile 'com.shuyu:gsyVideoPlayer:1.1.7'
* <h4>3、详情模式</h4>
<img src="https://github.com/CarGuo/GSYVideoPlayer/blob/master/04.gif" width="240px" height="426px"/>
### 1.1.8 增加了对Cache如果文件如果出现播放异常就清除缓存文件的处理(预防),StandardGSYVideoPlayer增加了一些UI配置接口
```
/**
* 底部进度条-弹出的
*/
public void setBottomShowProgressBarDrawable(Drawable drawable, Drawable thumb)
/**
* 底部进度条-非弹出
*/
public void setBottomProgressBarDrawable(Drawable drawable)
/**
* 声音进度条
*/
public void setDialogVolumeProgressBar(Drawable drawable)
/**
* 中间进度条
*/
public void setDialogProgressBar(Drawable drawable)
/**
* 中间进度条字体颜色
*/
public void setDialogProgressColor(int highLightColor, int normalColor)
```
## 1.1.7 增加了第二种列表 ListVideoUtil可拖动小窗口支持
```
......
......@@ -72,6 +72,13 @@ public class PlayActivity extends AppCompatActivity {
}
});
videoPlayer.setBottomProgressBarDrawable(getResources().getDrawable(R.drawable.video_new_progress));
videoPlayer.setDialogVolumeProgressBar(getResources().getDrawable(R.drawable.video_new_volume_progress_bg));
videoPlayer.setDialogProgressBar(getResources().getDrawable(R.drawable.video_new_progress));
videoPlayer.setBottomShowProgressBarDrawable(getResources().getDrawable(R.drawable.video_new_seekbar_progress),
getResources().getDrawable(R.drawable.video_new_seekbar_thumb));
videoPlayer.setDialogProgressColor(getResources().getColor(R.color.colorAccent), -11);
//是否可以滑动调整
videoPlayer.setIsTouchWiget(true);
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#4c000000"/>
<size android:height="4.0dip"/>
<corners android:radius="1.0dip"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="#ffe0e0e0"/>
<size android:height="4.0dip"/>
<corners android:radius="1.0dip"/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="@color/colorAccent"/>
<size android:height="4.0dip"/>
<corners android:radius="1.0dip"/>
</shape>
</clip>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#cc999999"/>
<size android:height="3dp"/>
<corners android:radius="1.5dp"/>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="#ffe0e0e0"/>
<size android:height="3dp"/>
<corners android:radius="1.5dp"/>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="@color/colorAccent"/>
<size android:height="3dp"/>
<corners android:radius="1.5dp"/>
</shape>
</clip>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/video_seek_new_thumb_press" />
<item android:drawable="@drawable/video_seek_new_thumb_normal" />
</selector>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape>
<solid android:color="#ffffffff"/>
<corners android:radius="2.0dip"/>
</shape>
</item>
<item android:id="@android:id/progress">
<clip
android:clipOrientation="vertical"
android:gravity="bottom">
<shape>
<solid android:color="@color/colorAccent"/>
<corners android:radius="2.0dip"/>
</shape>
</clip>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorPrimary" />
<size
android:height="12dp"
android:width="12dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="oval"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorPrimaryDark" />
<size
android:height="12dp"
android:width="12dp" />
</shape>
\ No newline at end of file
......@@ -18,7 +18,7 @@ org.gradle.jvmargs=-Xmx1536m
BINTRAY_USER=
BINTRAY_KEY=
PROJ_GROUP=com.shuyu
PROJ_VERSION=1.1.7
PROJ_VERSION=1.1.8
PROJ_NAME=gsyVideo
PROJ_WEBSITEURL=hhttps://github.com/CarGuo/GSYVideoPlayer
PROJ_ISSUETRACKERURL=
......
......@@ -8,6 +8,7 @@ import android.media.MediaPlayer;
import android.os.Handler;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.TextureView;
......@@ -28,6 +29,7 @@ import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
import com.shuyu.gsyvideoplayer.utils.CommonUtil;
import com.shuyu.gsyvideoplayer.video.GSYBaseVideoPlayer;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
......@@ -127,6 +129,8 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
protected boolean mLooping = false;//// TODO: 2016/11/13 循环
protected boolean mCacheFile = false; //是否是缓存的文件
/**
* 当前UI
......@@ -191,9 +195,12 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
(System.currentTimeMillis() - CLICK_QUIT_FULLSCREEN_TIME) < FULL_SCREEN_NORMAL_DELAY)
return false;
mCurrentState = CURRENT_STATE_NORMAL;
if (cacheWithPlay && url.startsWith("http")) {
if (cacheWithPlay && url.startsWith("http") && !url.contains("127.0.0.1")) {
mOriginUrl = url;
HttpProxyCacheServer proxy = GSYVideoManager.getProxy(getContext().getApplicationContext());
url = proxy.getProxyUrl(url);
mCacheFile = (!url.startsWith("http"));
//Log.i(TAG, "mCacheFile " + mCacheFile + " " + url);
}
this.mUrl = url;
this.mObjects = objects;
......@@ -740,6 +747,16 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
public void onError(int what, int extra) {
if (what != 38 && what != -38) {
setStateAndUi(CURRENT_STATE_ERROR);
if (mCacheFile) {
Log.e(TAG, " mCacheFile Local Error " + mUrl);
//可能是因为缓存文件除了问题
CommonUtil.deleteFile(mUrl.replace("file://", ""));
mUrl = mOriginUrl;
} else if (mUrl.contains("127.0.0.1")) {
Log.e(TAG, " mCacheFile Download Error " + mUrl);
CommonUtil.deleteFile(mUrl.replace("file://", "") + ".downlad");
mUrl = mOriginUrl;
}
}
}
......
......@@ -12,6 +12,7 @@ import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.WindowManager;
import java.io.File;
import java.util.Formatter;
import java.util.Locale;
......@@ -183,5 +184,19 @@ public class CommonUtil {
return outMetrics.heightPixels;
}
public static void deleteFile(String filePath) {
File file = new File(filePath);
if (file.exists()) {
if (file.isFile()) {
file.delete();
} else {
String[] filePaths = file.list();
for (String path : filePaths) {
deleteFile(filePath + File.separator + path);
}
file.delete();
}
}
}
}
......@@ -64,8 +64,11 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
protected Context mContext;
protected String mOriginUrl; //原来的url
protected String mUrl;
protected Object[] mObjects;
protected ViewGroup mTextureViewContainer;
......
......@@ -5,6 +5,7 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
......@@ -73,6 +74,16 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
protected TextView mDialogTotalTime;
protected ImageView mDialogIcon;
protected Drawable mBottomProgressDrawable;
protected Drawable mBottomShowProgressDrawable;
protected Drawable mBottomShowProgressThumbDrawable;
protected Drawable mVolumeProgressDrawable;
protected Drawable mDialogProgressBarDrawable;
private int mDialogProgressHighLightColor = -11;
private int mDialogProgressNormalColor = -11;
public void setStandardVideoAllCallBack(StandardVideoAllCallBack standardVideoAllCallBack) {
this.mStandardVideoAllCallBack = standardVideoAllCallBack;
......@@ -104,6 +115,19 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
resolveThumbImage(mThumbImageView);
}
if (mBottomProgressDrawable != null) {
mBottomProgressBar.setProgressDrawable(mBottomProgressDrawable);
}
if (mBottomShowProgressDrawable != null) {
mProgressBar.setProgressDrawable(mBottomProgressDrawable);
}
if (mBottomShowProgressThumbDrawable != null) {
mProgressBar.setThumb(mBottomShowProgressThumbDrawable);
}
}
@Override
......@@ -463,6 +487,9 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
if (mProgressDialog == null) {
View localView = LayoutInflater.from(getContext()).inflate(R.layout.video_progress_dialog, null);
mDialogProgressBar = ((ProgressBar) localView.findViewById(R.id.duration_progressbar));
if (mDialogProgressBarDrawable != null) {
mDialogProgressBar.setProgressDrawable(mDialogProgressBarDrawable);
}
mDialogSeekTime = ((TextView) localView.findViewById(R.id.tv_current));
mDialogTotalTime = ((TextView) localView.findViewById(R.id.tv_duration));
mDialogIcon = ((ImageView) localView.findViewById(R.id.duration_image_tip));
......@@ -472,6 +499,12 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
mProgressDialog.getWindow().addFlags(32);
mProgressDialog.getWindow().addFlags(16);
mProgressDialog.getWindow().setLayout(-2, -2);
if(mDialogProgressNormalColor != -11) {
mDialogTotalTime.setTextColor(mDialogProgressNormalColor);
}
if (mDialogProgressHighLightColor != -11) {
mDialogSeekTime.setTextColor(mDialogProgressHighLightColor);
}
WindowManager.LayoutParams localLayoutParams = mProgressDialog.getWindow().getAttributes();
localLayoutParams.gravity = Gravity.CENTER;
//localLayoutParams.y = getResources().getDimensionPixelOffset(R.dimen.video_progress_dialog_margin_top);
......@@ -506,6 +539,9 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
if (mVolumeDialog == null) {
View localView = LayoutInflater.from(getContext()).inflate(R.layout.video_volume_dialog, null);
mDialogVolumeProgressBar = ((ProgressBar) localView.findViewById(R.id.volume_progressbar));
if (mVolumeProgressDrawable != null) {
mDialogVolumeProgressBar.setProgressDrawable(mVolumeProgressDrawable);
}
mVolumeDialog = new Dialog(getContext(), R.style.video_style_dialog_progress);
mVolumeDialog.setContentView(localView);
mVolumeDialog.getWindow().addFlags(8);
......@@ -642,4 +678,49 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
clearFullscreenLayout();
}
/**
* 底部进度条-弹出的
*/
public void setBottomShowProgressBarDrawable(Drawable drawable, Drawable thumb) {
mBottomShowProgressDrawable = drawable;
mBottomShowProgressThumbDrawable = thumb;
if (mProgressBar != null) {
mProgressBar.setProgressDrawable(drawable);
mProgressBar.setThumb(thumb);
}
}
/**
* 底部进度条-非弹出
*/
public void setBottomProgressBarDrawable(Drawable drawable) {
mBottomProgressDrawable = drawable;
if (mBottomProgressBar != null) {
mBottomProgressBar.setProgressDrawable(drawable);
}
}
/**
* 声音进度条
*/
public void setDialogVolumeProgressBar(Drawable drawable) {
mVolumeProgressDrawable = drawable;
}
/**
* 中间进度条
*/
public void setDialogProgressBar(Drawable drawable) {
mDialogProgressBarDrawable = drawable;
}
/**
* 中间进度条字体颜色
*/
public void setDialogProgressColor(int highLightColor, int normalColor) {
mDialogProgressHighLightColor = highLightColor;
mDialogProgressNormalColor = normalColor;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册