Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_26386469
GSYVideoPlayer
提交
8f01383b
G
GSYVideoPlayer
项目概览
qq_26386469
/
GSYVideoPlayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
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,发现更多精彩内容 >>
提交
8f01383b
编写于
6月 10, 2019
作者:
ErnestX
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: safe check getActivityContext to avoid NPE
上级
e4bd4734
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
28 addition
and
20 deletion
+28
-20
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
...m/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
+2
-2
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java
.../shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java
+13
-10
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
...ava/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
+13
-8
未找到文件。
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
浏览文件 @
8f01383b
...
...
@@ -628,10 +628,10 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
final
GSYBaseVideoPlayer
gsyVideoPlayer
;
if
(!
hadNewConstructor
)
{
constructor
=
(
Constructor
<
GSYBaseVideoPlayer
>)
GSYBaseVideoPlayer
.
this
.
getClass
().
getConstructor
(
Context
.
class
);
gsyVideoPlayer
=
constructor
.
newInstance
(
getActivityContext
()
);
gsyVideoPlayer
=
constructor
.
newInstance
(
mContext
);
}
else
{
constructor
=
(
Constructor
<
GSYBaseVideoPlayer
>)
GSYBaseVideoPlayer
.
this
.
getClass
().
getConstructor
(
Context
.
class
,
Boolean
.
class
);
gsyVideoPlayer
=
constructor
.
newInstance
(
getActivityContext
()
,
true
);
gsyVideoPlayer
=
constructor
.
newInstance
(
mContext
,
true
);
}
gsyVideoPlayer
.
setId
(
getFullId
());
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoControlView.java
浏览文件 @
8f01383b
...
...
@@ -273,9 +273,10 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
});
}
if
(
getActivityContext
()!=
null
)
{
mSeekEndOffset
=
CommonUtil
.
dip2px
(
getActivityContext
(),
50
);
}
}
@Override
protected
void
onDetachedFromWindow
()
{
...
...
@@ -668,10 +669,12 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
}
protected
void
touchSurfaceMove
(
float
deltaX
,
float
deltaY
,
float
y
)
{
int
curWidth
=
CommonUtil
.
getCurrentScreenLand
((
Activity
)
getActivityContext
())
?
mScreenHeight
:
mScreenWidth
;
int
curHeight
=
CommonUtil
.
getCurrentScreenLand
((
Activity
)
getActivityContext
())
?
mScreenWidth
:
mScreenHeight
;
int
curWidth
=
0
;
int
curHeight
=
0
;
if
(
getActivityContext
()!=
null
)
{
curWidth
=
CommonUtil
.
getCurrentScreenLand
((
Activity
)
getActivityContext
())
?
mScreenHeight
:
mScreenWidth
;
curHeight
=
CommonUtil
.
getCurrentScreenLand
((
Activity
)
getActivityContext
())
?
mScreenWidth
:
mScreenHeight
;
}
if
(
mChangePosition
)
{
int
totalTimeDuration
=
getDuration
();
mSeekTimePosition
=
(
int
)
(
mDownPosition
+
(
deltaX
*
totalTimeDuration
/
curWidth
)
/
mSeekRatio
);
...
...
@@ -698,10 +701,10 @@ public abstract class GSYVideoControlView extends GSYVideoView implements View.O
}
protected
void
touchSurfaceMoveFullLogic
(
float
absDeltaX
,
float
absDeltaY
)
{
int
curWidth
=
CommonUtil
.
getCurrentScreenLand
((
Activity
)
getActivityContext
())
?
mScreenHeight
:
mScreenWidth
;
int
curWidth
=
0
;
if
(
getActivityContext
()!=
null
)
{
curWidth
=
CommonUtil
.
getCurrentScreenLand
((
Activity
)
getActivityContext
())
?
mScreenHeight
:
mScreenWidth
;
}
if
(
absDeltaX
>
mThreshold
||
absDeltaY
>
mThreshold
)
{
cancelProgressTimer
();
if
(
absDeltaX
>=
mThreshold
)
{
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
浏览文件 @
8f01383b
...
...
@@ -270,9 +270,9 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
mTextureViewContainer
=
(
ViewGroup
)
findViewById
(
R
.
id
.
surface_container
);
if
(
isInEditMode
())
return
;
mScreenWidth
=
getActivityContext
()
.
getResources
().
getDisplayMetrics
().
widthPixels
;
mScreenHeight
=
getActivityContext
()
.
getResources
().
getDisplayMetrics
().
heightPixels
;
mAudioManager
=
(
AudioManager
)
getActivityContext
()
.
getApplicationContext
().
getSystemService
(
Context
.
AUDIO_SERVICE
);
mScreenWidth
=
mContext
.
getResources
().
getDisplayMetrics
().
widthPixels
;
mScreenHeight
=
mContext
.
getResources
().
getDisplayMetrics
().
heightPixels
;
mAudioManager
=
(
AudioManager
)
mContext
.
getApplicationContext
().
getSystemService
(
Context
.
AUDIO_SERVICE
);
}
...
...
@@ -329,7 +329,9 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
getGSYVideoManager
().
setPlayTag
(
mPlayTag
);
getGSYVideoManager
().
setPlayPosition
(
mPlayPosition
);
mAudioManager
.
requestAudioFocus
(
onAudioFocusChangeListener
,
AudioManager
.
STREAM_MUSIC
,
AudioManager
.
AUDIOFOCUS_GAIN_TRANSIENT
);
((
Activity
)
getActivityContext
()).
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
if
(
mContext
instanceof
Activity
)
{
((
Activity
)
mContext
).
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
}
mBackUpPlayingBufferState
=
-
1
;
getGSYVideoManager
().
prepare
(
mUrl
,
(
mMapHeadData
==
null
)
?
new
HashMap
<
String
,
String
>()
:
mMapHeadData
,
mLooping
,
mSpeed
,
mCache
,
mCachePath
,
mOverrideExtension
);
setStateAndUi
(
CURRENT_STATE_PREPAREING
);
...
...
@@ -603,8 +605,9 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
if
(!
mIfCurrentIsFullscreen
)
getGSYVideoManager
().
setLastListener
(
null
);
mAudioManager
.
abandonAudioFocus
(
onAudioFocusChangeListener
);
((
Activity
)
getActivityContext
()).
getWindow
().
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
if
(
mContext
instanceof
Activity
)
{
((
Activity
)
mContext
).
getWindow
().
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
}
releaseNetWorkState
();
if
(
mVideoAllCallBack
!=
null
&&
isCurrentMediaListener
())
{
...
...
@@ -633,7 +636,9 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
getGSYVideoManager
().
setCurrentVideoWidth
(
0
);
mAudioManager
.
abandonAudioFocus
(
onAudioFocusChangeListener
);
((
Activity
)
getActivityContext
()).
getWindow
().
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
if
(
mContext
instanceof
Activity
)
{
((
Activity
)
mContext
).
getWindow
().
clearFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
}
releaseNetWorkState
();
...
...
@@ -821,7 +826,7 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
*/
protected
void
createNetWorkState
()
{
if
(
mNetInfoModule
==
null
)
{
mNetInfoModule
=
new
NetInfoModule
(
getActivityContext
()
.
getApplicationContext
(),
new
NetInfoModule
.
NetChangeListener
()
{
mNetInfoModule
=
new
NetInfoModule
(
mContext
.
getApplicationContext
(),
new
NetInfoModule
.
NetChangeListener
()
{
@Override
public
void
changed
(
String
state
)
{
if
(!
mNetSate
.
equals
(
state
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录