Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ac13
GSYVideoPlayer
提交
9e9c6b44
G
GSYVideoPlayer
项目概览
ac13
/
GSYVideoPlayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
GSYVideoPlayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9e9c6b44
编写于
8月 05, 2017
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整了代码结构 (2017-08-05)
上级
5e73f499
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
474 addition
and
391 deletion
+474
-391
app/src/main/java/com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
...com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
+3
-2
app/src/main/java/com/example/gsyvideoplayer/holder/RecyclerItemNormalHolder.java
...ample/gsyvideoplayer/holder/RecyclerItemNormalHolder.java
+3
-0
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
...va/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
+2
-1
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
...om/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
+254
-343
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java
.../shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java
+200
-43
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
...ava/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
+12
-2
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
浏览文件 @
9e9c6b44
...
...
@@ -87,7 +87,7 @@ public class ListNormalAdapter extends BaseAdapter {
//final String url = "http://111.198.24.133:83/yyy_login_server/pic/YB059284/97778276040859/1.mp4";
//默认缓存路径
holder
.
gsyVideoPlayer
.
setUp
(
url
,
true
,
null
,
"这是title"
);
holder
.
gsyVideoPlayer
.
setUp
(
url
,
true
,
null
,
"这是title"
);
//holder.gsyVideoPlayer.setNeedShowWifiTip(false);
...
...
@@ -141,6 +141,7 @@ public class ListNormalAdapter extends BaseAdapter {
holder
.
gsyVideoPlayer
.
setLockLand
(
true
);
holder
.
gsyVideoPlayer
.
setPlayTag
(
TAG
);
holder
.
gsyVideoPlayer
.
setShowFullAnimation
(
true
);
holder
.
gsyVideoPlayer
.
setIsTouchWiget
(
false
);
//循环
//holder.gsyVideoPlayer.setLooping(true);
holder
.
gsyVideoPlayer
.
setNeedLockFull
(
true
);
...
...
@@ -149,7 +150,7 @@ public class ListNormalAdapter extends BaseAdapter {
holder
.
gsyVideoPlayer
.
setPlayPosition
(
position
);
holder
.
gsyVideoPlayer
.
setStandardVideoAllCallBack
(
new
SampleListener
(){
holder
.
gsyVideoPlayer
.
setStandardVideoAllCallBack
(
new
SampleListener
()
{
@Override
public
void
onPrepared
(
String
url
,
Object
...
objects
)
{
super
.
onPrepared
(
url
,
objects
);
...
...
app/src/main/java/com/example/gsyvideoplayer/holder/RecyclerItemNormalHolder.java
浏览文件 @
9e9c6b44
...
...
@@ -50,6 +50,9 @@ public class RecyclerItemNormalHolder extends RecyclerItemBaseHolder {
ViewGroup
viewGroup
=
(
ViewGroup
)
imageView
.
getParent
();
viewGroup
.
removeView
(
imageView
);
}
gsyVideoPlayer
.
setIsTouchWiget
(
false
);
gsyVideoPlayer
.
setThumbImageView
(
imageView
);
final
String
url
=
"http://baobab.wdjcdn.com/14564977406580.mp4"
;
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
浏览文件 @
9e9c6b44
...
...
@@ -494,6 +494,8 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
cloneParams
(
this
,
gsyVideoPlayer
);
gsyVideoPlayer
.
setIsTouchWiget
(
false
);
//小窗口不能点击
gsyVideoPlayer
.
addTextureView
();
//隐藏掉所有的弹出状态哟
gsyVideoPlayer
.
onClickUiToggle
();
...
...
@@ -502,7 +504,6 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
GSYVideoManager
.
instance
().
setLastListener
(
this
);
GSYVideoManager
.
instance
().
setListener
(
gsyVideoPlayer
);
if
(
mVideoAllCallBack
!=
null
)
{
Debuger
.
printfError
(
"onEnterSmallWidget"
);
mVideoAllCallBack
.
onEnterSmallWidget
(
mOriginUrl
,
mTitle
,
gsyVideoPlayer
);
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
浏览文件 @
9e9c6b44
此差异已折叠。
点击以展开。
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java
浏览文件 @
9e9c6b44
...
...
@@ -25,7 +25,9 @@ import com.shuyu.gsyvideoplayer.R;
import
com.shuyu.gsyvideoplayer.listener.LockClickListener
;
import
com.shuyu.gsyvideoplayer.utils.CommonUtil
;
import
com.shuyu.gsyvideoplayer.utils.Debuger
;
import
com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
;
import
java.io.File
;
import
java.util.Timer
;
import
java.util.TimerTask
;
...
...
@@ -160,6 +162,14 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
//点击锁屏的回调
protected
LockClickListener
mLockClickListener
;
//触摸显示后隐藏的时间
protected
int
mDismissControlTime
=
2500
;
protected
Timer
mDismissControlViewTimer
;
protected
DismissControlViewTimerTask
mDismissControlViewTimerTask
;
public
GSYVideoControlView
(
@NonNull
Context
context
)
{
super
(
context
);
...
...
@@ -237,7 +247,7 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
if
(
mBackButton
!=
null
)
mBackButton
.
setOnClickListener
(
this
);
if
(
mLockScreen
!=
null
)
{
if
(
mLockScreen
!=
null
)
{
mLockScreen
.
setVisibility
(
GONE
);
mLockScreen
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
...
...
@@ -323,6 +333,7 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
}
break
;
}
resolveUIState
(
state
);
}
@Override
...
...
@@ -379,34 +390,6 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
int
id
=
v
.
getId
();
float
x
=
event
.
getX
();
float
y
=
event
.
getY
();
if
(
id
==
R
.
id
.
surface_container
)
{
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
break
;
case
MotionEvent
.
ACTION_MOVE
:
break
;
case
MotionEvent
.
ACTION_UP
:
startDismissControlViewTimer
();
if
(
mChangePosition
)
{
int
duration
=
getDuration
();
int
progress
=
mSeekTimePosition
*
100
/
(
duration
==
0
?
1
:
duration
);
mBottomProgressBar
.
setProgress
(
progress
);
}
if
(!
mChangePosition
&&
!
mChangeVolume
&&
!
mBrightness
)
{
onClickUiToggle
();
}
break
;
}
}
else
if
(
id
==
R
.
id
.
progress
)
{
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
cancelDismissControlViewTimer
();
break
;
case
MotionEvent
.
ACTION_UP
:
startDismissControlViewTimer
();
break
;
}
}
if
(
mIfCurrentIsFullscreen
&&
mLockCurScreen
&&
mNeedLockFull
)
{
return
true
;
...
...
@@ -492,6 +475,18 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
break
;
case
MotionEvent
.
ACTION_UP
:
startDismissControlViewTimer
();
if
(
mChangePosition
)
{
int
duration
=
getDuration
();
int
progress
=
mSeekTimePosition
*
100
/
(
duration
==
0
?
1
:
duration
);
mBottomProgressBar
.
setProgress
(
progress
);
}
if
(!
mChangePosition
&&
!
mChangeVolume
&&
!
mBrightness
)
{
onClickUiToggle
();
}
mTouchingProgressBar
=
false
;
dismissProgressDialog
();
dismissVolumeDialog
();
...
...
@@ -528,6 +523,7 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
}
else
if
(
id
==
R
.
id
.
progress
)
{
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
cancelDismissControlViewTimer
();
case
MotionEvent
.
ACTION_MOVE
:
cancelProgressTimer
();
ViewParent
vpdown
=
getParent
();
...
...
@@ -537,6 +533,7 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
}
break
;
case
MotionEvent
.
ACTION_UP
:
startDismissControlViewTimer
();
startProgressTimer
();
ViewParent
vpup
=
getParent
();
while
(
vpup
!=
null
)
{
...
...
@@ -559,6 +556,42 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
mThumbImageViewLayout
.
setOnTouchListener
(
onTouchListener
);
}
/**
* 处理控制显示
* @param state
*/
protected
void
resolveUIState
(
int
state
)
{
switch
(
mCurrentState
)
{
case
CURRENT_STATE_NORMAL:
changeUiToNormal
();
cancelDismissControlViewTimer
();
break
;
case
CURRENT_STATE_PREPAREING:
changeUiToPrepareingShow
();
startDismissControlViewTimer
();
break
;
case
CURRENT_STATE_PLAYING:
changeUiToPlayingShow
();
startDismissControlViewTimer
();
break
;
case
CURRENT_STATE_PAUSE:
changeUiToPauseShow
();
cancelDismissControlViewTimer
();
break
;
case
CURRENT_STATE_ERROR:
changeUiToError
();
break
;
case
CURRENT_STATE_AUTO_COMPLETE:
changeUiToCompleteShow
();
cancelDismissControlViewTimer
();
break
;
case
CURRENT_STATE_PLAYING_BUFFERING_START:
changeUiToPlayingBufferingShow
();
break
;
}
}
/**
* 播放按键点击
*/
...
...
@@ -648,6 +681,30 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
}
}
private
class
DismissControlViewTimerTask
extends
TimerTask
{
@Override
public
void
run
()
{
if
(
mCurrentState
!=
CURRENT_STATE_NORMAL
&&
mCurrentState
!=
CURRENT_STATE_ERROR
&&
mCurrentState
!=
CURRENT_STATE_AUTO_COMPLETE
)
{
if
(
getActivityContext
()
!=
null
)
{
((
Activity
)
getActivityContext
()).
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
hideAllWidget
();
mLockScreen
.
setVisibility
(
GONE
);
if
(
mHideKey
&&
mIfCurrentIsFullscreen
&&
mShowVKey
)
{
hideNavKey
(
mContext
);
}
}
});
}
}
}
}
protected
void
setTextAndProgress
(
int
secProgress
)
{
int
position
=
getCurrentPositionWhenPlaying
();
int
duration
=
getDuration
();
...
...
@@ -707,6 +764,83 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
mBottomProgressBar
.
setProgress
(
0
);
}
protected
void
startDismissControlViewTimer
()
{
cancelDismissControlViewTimer
();
mDismissControlViewTimer
=
new
Timer
();
mDismissControlViewTimerTask
=
new
DismissControlViewTimerTask
();
mDismissControlViewTimer
.
schedule
(
mDismissControlViewTimerTask
,
mDismissControlTime
);
}
protected
void
cancelDismissControlViewTimer
()
{
if
(
mDismissControlViewTimer
!=
null
)
{
mDismissControlViewTimer
.
cancel
();
mDismissControlViewTimer
=
null
;
}
if
(
mDismissControlViewTimerTask
!=
null
)
{
mDismissControlViewTimerTask
.
cancel
();
mDismissControlViewTimerTask
=
null
;
}
}
protected
void
resolveThumbImage
(
View
thumb
)
{
mThumbImageViewLayout
.
addView
(
thumb
);
ViewGroup
.
LayoutParams
layoutParams
=
thumb
.
getLayoutParams
();
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
layoutParams
.
width
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
thumb
.
setLayoutParams
(
layoutParams
);
}
protected
void
setViewShowState
(
View
view
,
int
visibility
)
{
if
(
view
!=
null
)
{
view
.
setVisibility
(
visibility
);
}
}
/**
* 设置播放URL
*
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param title title
* @return
*/
@Override
public
boolean
setUp
(
String
url
,
boolean
cacheWithPlay
,
String
title
)
{
return
setUp
(
url
,
cacheWithPlay
,
(
File
)
null
,
title
);
}
/**
* 设置播放URL
*
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param title title
* @return
*/
@Override
public
boolean
setUp
(
String
url
,
boolean
cacheWithPlay
,
File
cachePath
,
String
title
)
{
if
(
super
.
setUp
(
url
,
cacheWithPlay
,
cachePath
,
title
))
{
if
(
title
!=
null
&&
mTitleTextView
!=
null
)
{
mTitleTextView
.
setText
(
title
);
}
if
(
mIfCurrentIsFullscreen
)
{
mFullscreenButton
.
setImageResource
(
getShrinkImageRes
());
}
else
{
mFullscreenButton
.
setImageResource
(
getEnlargeImageRes
());
mBackButton
.
setVisibility
(
View
.
GONE
);
}
return
true
;
}
return
false
;
}
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
int
progress
,
boolean
fromUser
)
{
}
...
...
@@ -770,7 +904,7 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
*
* @param percent
*/
pr
ivate
void
onBrightnessSlide
(
float
percent
)
{
pr
otected
void
onBrightnessSlide
(
float
percent
)
{
mBrightnessData
=
((
Activity
)
(
mContext
)).
getWindow
().
getAttributes
().
screenBrightness
;
if
(
mBrightnessData
<=
0.00f
)
{
mBrightnessData
=
0.50f
;
...
...
@@ -788,16 +922,6 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
((
Activity
)
(
mContext
)).
getWindow
().
setAttributes
(
lpa
);
}
private
void
resolveThumbImage
(
View
thumb
)
{
mThumbImageViewLayout
.
addView
(
thumb
);
ViewGroup
.
LayoutParams
layoutParams
=
thumb
.
getLayoutParams
();
layoutParams
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
layoutParams
.
width
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
thumb
.
setLayoutParams
(
layoutParams
);
}
protected
abstract
void
showWifiDialog
();
protected
abstract
void
showProgressDialog
(
float
deltaX
,
...
...
@@ -816,11 +940,30 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
protected
abstract
void
onClickUiToggle
();
protected
abstract
void
startDismissControlViewTimer
();
protected
abstract
void
hideAllWidget
();
protected
abstract
void
c
ancelDismissControlViewTimer
();
protected
abstract
void
c
hangeUiToNormal
();
protected
abstract
void
hideAllWidget
();
protected
abstract
void
changeUiToPrepareingShow
();
protected
abstract
void
changeUiToPlayingShow
();
protected
abstract
void
changeUiToPauseShow
();
protected
abstract
void
changeUiToError
();
protected
abstract
void
changeUiToCompleteShow
();
protected
abstract
void
changeUiToPlayingBufferingShow
();
/**
* 初始化为正常状态
*/
public
void
initUIState
()
{
setStateAndUi
(
CURRENT_STATE_NORMAL
);
}
/**
* 封面布局
...
...
@@ -1002,4 +1145,18 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
this
.
mLockClickListener
=
lockClickListener
;
}
/**
* 设置触摸显示控制ui的消失时间
*
* @param dismissControlTime 毫秒,默认2500
*/
public
void
setDismissControlTime
(
int
dismissControlTime
)
{
this
.
mDismissControlTime
=
dismissControlTime
;
}
public
int
getDismissControlTime
()
{
return
mDismissControlTime
;
}
}
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
浏览文件 @
9e9c6b44
...
...
@@ -15,7 +15,6 @@ import android.view.InflateException;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.WindowManager
;
import
android.widget.TextView
;
import
com.danikula.videocache.HttpProxyCacheServer
;
import
com.danikula.videocache.file.Md5FileNameGenerator
;
...
...
@@ -208,7 +207,18 @@ public abstract class GSYVideoView extends GSYTextureGroup implements GSYMediaPl
}
public
Context
getActivityContext
()
{
protected
void
updatePauseCover
()
{
if
((
mFullPauseBitmap
==
null
||
mFullPauseBitmap
.
isRecycled
())
&&
mShowPauseCover
)
{
try
{
initCover
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
mFullPauseBitmap
=
null
;
}
}
}
protected
Context
getActivityContext
()
{
return
CommonUtil
.
getActivityContext
(
getContext
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录