Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_26386469
GSYVideoPlayer
提交
d763a916
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,体验更适合开发者的 AI 搜索 >>
提交
d763a916
编写于
7月 05, 2017
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
兼容Appbar中使用 (2017-07-05)
上级
ad326ab3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
50 addition
and
27 deletion
+50
-27
UPDATE_VERSION.md
UPDATE_VERSION.md
+3
-0
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
...rc/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
+18
-12
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/CommonUtil.java
.../main/java/com/shuyu/gsyvideoplayer/utils/CommonUtil.java
+11
-0
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/CustomGSYVideoPlayer.java
.../com/shuyu/gsyvideoplayer/video/CustomGSYVideoPlayer.java
+1
-1
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
...va/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
+6
-3
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
...om/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
+11
-11
未找到文件。
UPDATE_VERSION.md
浏览文件 @
d763a916
...
...
@@ -2,6 +2,9 @@
### 1.6.9()
*
兼容Appbar中使用,感谢
[
@loveRose
](
https://github.com/loveRose
)
*
修改setup的设置参数。
*
升级修改所有回调接口,回调接口中返回当前播放器。
*
非全屏播放器可获取全屏播放器对象。
```
/**
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
浏览文件 @
d763a916
...
...
@@ -172,7 +172,13 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
}
protected
void
init
(
Context
context
)
{
this
.
mContext
=
context
;
if
(
getActivityContext
()
!=
null
)
{
this
.
mContext
=
getActivityContext
();
}
else
{
this
.
mContext
=
context
;
}
View
.
inflate
(
context
,
getLayoutId
(),
this
);
mStartButton
=
findViewById
(
R
.
id
.
start
);
mSmallClose
=
findViewById
(
R
.
id
.
small_close
);
...
...
@@ -196,11 +202,11 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
mTextureViewContainer
.
setOnTouchListener
(
this
);
mFullscreenButton
.
setOnTouchListener
(
this
);
mScreenWidth
=
getContext
().
getResources
().
getDisplayMetrics
().
widthPixels
;
mScreenHeight
=
getContext
().
getResources
().
getDisplayMetrics
().
heightPixels
;
mAudioManager
=
(
AudioManager
)
getContext
().
getApplicationContext
().
getSystemService
(
Context
.
AUDIO_SERVICE
);
mScreenWidth
=
get
Activity
Context
().
getResources
().
getDisplayMetrics
().
widthPixels
;
mScreenHeight
=
get
Activity
Context
().
getResources
().
getDisplayMetrics
().
heightPixels
;
mAudioManager
=
(
AudioManager
)
get
Activity
Context
().
getApplicationContext
().
getSystemService
(
Context
.
AUDIO_SERVICE
);
mSeekEndOffset
=
CommonUtil
.
dip2px
(
getContext
(),
50
);
mSeekEndOffset
=
CommonUtil
.
dip2px
(
get
Activity
Context
(),
50
);
}
...
...
@@ -217,7 +223,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
*
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param title title
* @param title
title
* @return
*/
public
boolean
setUp
(
String
url
,
boolean
cacheWithPlay
,
String
title
)
{
...
...
@@ -232,7 +238,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
* @param cacheWithPlay 是否边播边缓存
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param mapHeadData 头部信息
* @param title title
* @param title
title
* @return
*/
@Override
...
...
@@ -252,7 +258,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param title title
* @param title
title
* @return
*/
@Override
...
...
@@ -265,7 +271,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
return
false
;
mCurrentState
=
CURRENT_STATE_NORMAL
;
if
(
cacheWithPlay
&&
url
.
startsWith
(
"http"
)
&&
!
url
.
contains
(
"127.0.0.1"
)
&&
!
url
.
contains
(
".m3u8"
))
{
HttpProxyCacheServer
proxy
=
GSYVideoManager
.
getProxy
(
getContext
().
getApplicationContext
(),
cachePath
);
HttpProxyCacheServer
proxy
=
GSYVideoManager
.
getProxy
(
get
Activity
Context
().
getApplicationContext
(),
cachePath
);
//此处转换了url,然后再赋值给mUrl。
url
=
proxy
.
getProxyUrl
(
url
);
mCacheFile
=
(!
url
.
startsWith
(
"http"
));
...
...
@@ -333,7 +339,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
}
if
(
i
==
R
.
id
.
start
)
{
if
(
TextUtils
.
isEmpty
(
mUrl
))
{
Toast
.
makeText
(
getContext
(),
getResources
().
getString
(
R
.
string
.
no_url
),
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
get
Activity
Context
(),
getResources
().
getString
(
R
.
string
.
no_url
),
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
mCurrentState
==
CURRENT_STATE_NORMAL
||
mCurrentState
==
CURRENT_STATE_ERROR
)
{
...
...
@@ -1058,7 +1064,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
CommonUtil
.
deleteFile
(
path
);
}
else
{
String
path
=
StorageUtils
.
getIndividualCacheDirectory
(
getContext
().
getApplicationContext
()).
getAbsolutePath
()
(
get
Activity
Context
().
getApplicationContext
()).
getAbsolutePath
()
+
File
.
separator
+
name
+
".download"
;
CommonUtil
.
deleteFile
(
path
);
}
...
...
@@ -1232,7 +1238,7 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
*/
protected
void
createNetWorkState
()
{
if
(
mNetInfoModule
==
null
)
{
mNetInfoModule
=
new
NetInfoModule
(
getContext
().
getApplicationContext
(),
new
NetInfoModule
.
NetChangeListener
()
{
mNetInfoModule
=
new
NetInfoModule
(
get
Activity
Context
().
getApplicationContext
(),
new
NetInfoModule
.
NetChangeListener
()
{
@Override
public
void
changed
(
String
state
)
{
if
(!
mNetSate
.
equals
(
state
))
{
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/CommonUtil.java
浏览文件 @
d763a916
...
...
@@ -255,4 +255,15 @@ public class CommonUtil {
}
}
}
public
static
Activity
getActivityContext
(
Context
context
)
{
if
(
context
==
null
)
return
null
;
else
if
(
context
instanceof
Activity
)
return
(
Activity
)
context
;
else
if
(
context
instanceof
ContextWrapper
)
return
scanForActivity
(((
ContextWrapper
)
context
).
getBaseContext
());
return
null
;
}
}
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/CustomGSYVideoPlayer.java
浏览文件 @
d763a916
...
...
@@ -72,7 +72,7 @@ public class CustomGSYVideoPlayer extends StandardGSYVideoPlayer {
mPreviewLayout
.
removeAllViews
();
}
mPreviewTexture
=
null
;
mPreviewTexture
=
new
GSYTextureView
(
getContext
());
mPreviewTexture
=
new
GSYTextureView
(
get
Activity
Context
());
mPreviewTexture
.
setSurfaceTextureListener
(
new
TextureView
.
SurfaceTextureListener
()
{
@Override
public
void
onSurfaceTextureAvailable
(
SurfaceTexture
surface
,
int
width
,
int
height
)
{
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
浏览文件 @
d763a916
...
...
@@ -169,6 +169,9 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
super
(
context
,
attrs
,
defStyleAttr
);
}
public
Context
getActivityContext
()
{
return
CommonUtil
.
getActivityContext
(
getContext
());
}
private
ViewGroup
getViewGroup
()
{
return
(
ViewGroup
)
(
CommonUtil
.
scanForActivity
(
getContext
())).
findViewById
(
Window
.
ID_ANDROID_CONTENT
);
...
...
@@ -333,10 +336,10 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
final
GSYBaseVideoPlayer
gsyVideoPlayer
;
if
(!
hadNewConstructor
)
{
constructor
=
(
Constructor
<
GSYBaseVideoPlayer
>)
GSYBaseVideoPlayer
.
this
.
getClass
().
getConstructor
(
Context
.
class
);
gsyVideoPlayer
=
constructor
.
newInstance
(
getContext
());
gsyVideoPlayer
=
constructor
.
newInstance
(
get
Activity
Context
());
}
else
{
constructor
=
(
Constructor
<
GSYBaseVideoPlayer
>)
GSYBaseVideoPlayer
.
this
.
getClass
().
getConstructor
(
Context
.
class
,
Boolean
.
class
);
gsyVideoPlayer
=
constructor
.
newInstance
(
getContext
(),
true
);
gsyVideoPlayer
=
constructor
.
newInstance
(
get
Activity
Context
(),
true
);
}
gsyVideoPlayer
.
setId
(
FULLSCREEN_ID
);
...
...
@@ -540,7 +543,7 @@ public abstract class GSYBaseVideoPlayer extends FrameLayout implements GSYMedia
try
{
Constructor
<
GSYBaseVideoPlayer
>
constructor
=
(
Constructor
<
GSYBaseVideoPlayer
>)
GSYBaseVideoPlayer
.
this
.
getClass
().
getConstructor
(
Context
.
class
);
GSYBaseVideoPlayer
gsyVideoPlayer
=
constructor
.
newInstance
(
getContext
());
GSYBaseVideoPlayer
gsyVideoPlayer
=
constructor
.
newInstance
(
get
Activity
Context
());
gsyVideoPlayer
.
setId
(
SMALL_ID
);
FrameLayout
.
LayoutParams
lpParent
=
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
MATCH_PARENT
);
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
浏览文件 @
d763a916
...
...
@@ -297,11 +297,11 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
return
;
}
if
(
TextUtils
.
isEmpty
(
mUrl
))
{
Toast
.
makeText
(
getContext
(),
getResources
().
getString
(
R
.
string
.
no_url
),
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
get
Activity
Context
(),
getResources
().
getString
(
R
.
string
.
no_url
),
Toast
.
LENGTH_SHORT
).
show
();
return
;
}
if
(
mCurrentState
==
CURRENT_STATE_NORMAL
)
{
if
(!
mUrl
.
startsWith
(
"file"
)
&&
!
CommonUtil
.
isWifiConnected
(
getContext
())
&&
mNeedShowWifiTip
)
{
if
(!
mUrl
.
startsWith
(
"file"
)
&&
!
CommonUtil
.
isWifiConnected
(
get
Activity
Context
())
&&
mNeedShowWifiTip
)
{
showWifiDialog
();
return
;
}
...
...
@@ -330,7 +330,7 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
Toast
.
makeText
(
mContext
,
getResources
().
getString
(
R
.
string
.
no_net
),
Toast
.
LENGTH_LONG
).
show
();
return
;
}
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
getContext
());
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
get
Activity
Context
());
builder
.
setMessage
(
getResources
().
getString
(
R
.
string
.
tips_not_wifi
));
builder
.
setPositiveButton
(
getResources
().
getString
(
R
.
string
.
tips_not_wifi_confirm
),
new
DialogInterface
.
OnClickListener
()
{
@Override
...
...
@@ -643,7 +643,7 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
protected
void
showProgressDialog
(
float
deltaX
,
String
seekTime
,
int
seekTimePosition
,
String
totalTime
,
int
totalTimeDuration
)
{
super
.
showProgressDialog
(
deltaX
,
seekTime
,
seekTimePosition
,
totalTime
,
totalTimeDuration
);
if
(
mProgressDialog
==
null
)
{
View
localView
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
video_progress_dialog
,
null
);
View
localView
=
LayoutInflater
.
from
(
get
Activity
Context
()).
inflate
(
R
.
layout
.
video_progress_dialog
,
null
);
mDialogProgressBar
=
((
ProgressBar
)
localView
.
findViewById
(
R
.
id
.
duration_progressbar
));
if
(
mDialogProgressBarDrawable
!=
null
)
{
mDialogProgressBar
.
setProgressDrawable
(
mDialogProgressBarDrawable
);
...
...
@@ -651,7 +651,7 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
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
));
mProgressDialog
=
new
Dialog
(
getContext
(),
R
.
style
.
video_style_dialog_progress
);
mProgressDialog
=
new
Dialog
(
get
Activity
Context
(),
R
.
style
.
video_style_dialog_progress
);
mProgressDialog
.
setContentView
(
localView
);
mProgressDialog
.
getWindow
().
addFlags
(
Window
.
FEATURE_ACTION_BAR
);
mProgressDialog
.
getWindow
().
addFlags
(
32
);
...
...
@@ -702,12 +702,12 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
protected
void
showVolumeDialog
(
float
deltaY
,
int
volumePercent
)
{
super
.
showVolumeDialog
(
deltaY
,
volumePercent
);
if
(
mVolumeDialog
==
null
)
{
View
localView
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
video_volume_dialog
,
null
);
View
localView
=
LayoutInflater
.
from
(
get
Activity
Context
()).
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
=
new
Dialog
(
get
Activity
Context
(),
R
.
style
.
video_style_dialog_progress
);
mVolumeDialog
.
setContentView
(
localView
);
mVolumeDialog
.
getWindow
().
addFlags
(
8
);
mVolumeDialog
.
getWindow
().
addFlags
(
32
);
...
...
@@ -742,9 +742,9 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
@Override
protected
void
showBrightnessDialog
(
float
percent
)
{
if
(
mBrightnessDialog
==
null
)
{
View
localView
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
video_brightness
,
null
);
View
localView
=
LayoutInflater
.
from
(
get
Activity
Context
()).
inflate
(
R
.
layout
.
video_brightness
,
null
);
mBrightnessDialogTv
=
(
TextView
)
localView
.
findViewById
(
R
.
id
.
app_video_brightness
);
mBrightnessDialog
=
new
Dialog
(
getContext
(),
R
.
style
.
video_style_dialog_progress
);
mBrightnessDialog
=
new
Dialog
(
get
Activity
Context
(),
R
.
style
.
video_style_dialog_progress
);
mBrightnessDialog
.
setContentView
(
localView
);
mBrightnessDialog
.
getWindow
().
addFlags
(
8
);
mBrightnessDialog
.
getWindow
().
addFlags
(
32
);
...
...
@@ -918,8 +918,8 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
if
(
mCurrentState
!=
CURRENT_STATE_NORMAL
&&
mCurrentState
!=
CURRENT_STATE_ERROR
&&
mCurrentState
!=
CURRENT_STATE_AUTO_COMPLETE
)
{
if
(
get
Context
()
!=
null
&&
getContext
()
instanceof
Activity
)
{
((
Activity
)
getContext
()).
runOnUiThread
(
new
Runnable
()
{
if
(
get
ActivityContext
()
!=
null
)
{
((
Activity
)
get
Activity
Context
()).
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
hideAllWidget
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录