Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ac13
GSYVideoPlayer
提交
ac4ce47d
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,发现更多精彩内容 >>
提交
ac4ce47d
编写于
1月 26, 2018
作者:
G
guoshuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加GSYSampleADVideoPlayer跳过视频支持
上级
64a6e115
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
25 deletion
+69
-25
app/src/main/java/com/example/gsyvideoplayer/DetailADPlayer.java
.../main/java/com/example/gsyvideoplayer/DetailADPlayer.java
+9
-1
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/GSYSampleADVideoPlayer.java
...om/shuyu/gsyvideoplayer/video/GSYSampleADVideoPlayer.java
+54
-22
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/ListGSYVideoPlayer.java
...va/com/shuyu/gsyvideoplayer/video/ListGSYVideoPlayer.java
+6
-2
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/DetailADPlayer.java
浏览文件 @
ac4ce47d
...
@@ -40,10 +40,18 @@ public class DetailADPlayer extends GSYBaseActivityDetail<ListGSYVideoPlayer> {
...
@@ -40,10 +40,18 @@ public class DetailADPlayer extends GSYBaseActivityDetail<ListGSYVideoPlayer> {
initVideo
();
initVideo
();
ArrayList
<
GSYSampleADVideoPlayer
.
GSYADVideoModel
>
urls
=
new
ArrayList
<>();
ArrayList
<
GSYSampleADVideoPlayer
.
GSYADVideoModel
>
urls
=
new
ArrayList
<>();
//广告1
urls
.
add
(
new
GSYSampleADVideoPlayer
.
GSYADVideoModel
(
"http://video.7k.cn/app_video/20171202/6c8cf3ea/v.m3u8.mp4"
,
urls
.
add
(
new
GSYSampleADVideoPlayer
.
GSYADVideoModel
(
"http://video.7k.cn/app_video/20171202/6c8cf3ea/v.m3u8.mp4"
,
""
,
GSYSampleADVideoPlayer
.
GSYADVideoModel
.
TYPE_AD
));
""
,
GSYSampleADVideoPlayer
.
GSYADVideoModel
.
TYPE_AD
));
//正式内容1
urls
.
add
(
new
GSYSampleADVideoPlayer
.
GSYADVideoModel
(
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
,
urls
.
add
(
new
GSYSampleADVideoPlayer
.
GSYADVideoModel
(
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
,
"正文标题"
,
GSYSampleADVideoPlayer
.
GSYADVideoModel
.
TYPE_NORMAL
));
"正文1标题"
,
GSYSampleADVideoPlayer
.
GSYADVideoModel
.
TYPE_NORMAL
));
//广告2
urls
.
add
(
new
GSYSampleADVideoPlayer
.
GSYADVideoModel
(
"http://video.7k.cn/app_video/20171202/6c8cf3ea/v.m3u8.mp4"
,
""
,
GSYSampleADVideoPlayer
.
GSYADVideoModel
.
TYPE_AD
,
true
));
//正式内容2
urls
.
add
(
new
GSYSampleADVideoPlayer
.
GSYADVideoModel
(
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f30.mp4"
,
"正文2标题"
,
GSYSampleADVideoPlayer
.
GSYADVideoModel
.
TYPE_NORMAL
));
detailPlayer
.
setAdUp
(
urls
,
true
,
0
);
detailPlayer
.
setAdUp
(
urls
,
true
,
0
);
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/GSYSampleADVideoPlayer.java
浏览文件 @
ac4ce47d
...
@@ -3,7 +3,6 @@ package com.shuyu.gsyvideoplayer.video;
...
@@ -3,7 +3,6 @@ package com.shuyu.gsyvideoplayer.video;
import
android.content.Context
;
import
android.content.Context
;
import
android.graphics.Color
;
import
android.graphics.Color
;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
...
@@ -70,7 +69,7 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
...
@@ -70,7 +69,7 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
*
*
* @param url 播放url
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cacheWithPlay 是否边播边缓存
* @param position
* @param position
需要播放的位置
* @return
* @return
*/
*/
@Override
@Override
...
@@ -83,7 +82,7 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
...
@@ -83,7 +82,7 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
*
*
* @param url 播放url
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cacheWithPlay 是否边播边缓存
* @param position
* @param position
需要播放的位置
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @return
* @return
*/
*/
...
@@ -97,7 +96,7 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
...
@@ -97,7 +96,7 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
*
*
* @param url 播放url
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cacheWithPlay 是否边播边缓存
* @param position
* @param position
需要播放的位置
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param mapHeadData http header
* @param mapHeadData http header
* @return
* @return
...
@@ -112,15 +111,23 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
...
@@ -112,15 +111,23 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
*
*
* @param url 播放url
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cacheWithPlay 是否边播边缓存
* @param position
* @param position
需要播放的位置
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param mapHeadData http header
* @param mapHeadData http header
* @param changeState
* @param changeState
切换的时候释放surface
* @return
* @return
*/
*/
@Override
@Override
protected
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
boolean
cacheWithPlay
,
int
position
,
File
cachePath
,
Map
<
String
,
String
>
mapHeadData
,
boolean
changeState
)
{
protected
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
boolean
cacheWithPlay
,
int
position
,
File
cachePath
,
Map
<
String
,
String
>
mapHeadData
,
boolean
changeState
)
{
initSetupModel
(
url
.
get
(
position
));
GSYVideoModel
gsyVideoModel
=
url
.
get
(
position
);
if
(
gsyVideoModel
instanceof
GSYADVideoModel
)
{
GSYADVideoModel
gsyadVideoModel
=
(
GSYADVideoModel
)
gsyVideoModel
;
if
(
gsyadVideoModel
.
isSkip
()
&&
position
<
(
url
.
size
()
-
1
))
{
return
setUp
(
url
,
cacheWithPlay
,
position
+
1
,
cachePath
,
mapHeadData
,
changeState
);
}
isAdModel
=
(
gsyadVideoModel
.
getType
()
==
GSYADVideoModel
.
TYPE_AD
);
}
changeAdUIState
();
return
super
.
setUp
(
url
,
cacheWithPlay
,
position
,
cachePath
,
mapHeadData
,
changeState
);
return
super
.
setUp
(
url
,
cacheWithPlay
,
position
,
cachePath
,
mapHeadData
,
changeState
);
}
}
...
@@ -208,18 +215,6 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
...
@@ -208,18 +215,6 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
st
.
changeAdUIState
();
st
.
changeAdUIState
();
}
}
/**
* 针对每个播放数据源的类型,设置状态
*
* @param gsyVideoModel
*/
protected
void
initSetupModel
(
GSYVideoModel
gsyVideoModel
)
{
if
(
gsyVideoModel
instanceof
GSYADVideoModel
)
{
GSYADVideoModel
gsyadVideoModel
=
(
GSYADVideoModel
)
gsyVideoModel
;
isAdModel
=
(
gsyadVideoModel
.
getType
()
==
GSYADVideoModel
.
TYPE_AD
);
}
changeAdUIState
();
}
/**
/**
* 根据是否广告url修改ui显示状态
* 根据是否广告url修改ui显示状态
...
@@ -278,24 +273,61 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
...
@@ -278,24 +273,61 @@ public class GSYSampleADVideoPlayer extends ListGSYVideoPlayer {
}
}
public
static
class
GSYADVideoModel
extends
GSYVideoModel
{
public
static
class
GSYADVideoModel
extends
GSYVideoModel
{
/**
* 正常
*/
public
static
int
TYPE_NORMAL
=
0
;
public
static
int
TYPE_NORMAL
=
0
;
/**
* 广告
*/
public
static
int
TYPE_AD
=
1
;
public
static
int
TYPE_AD
=
1
;
/**
* 类型
*/
private
int
mType
=
TYPE_NORMAL
;
private
int
mType
=
TYPE_NORMAL
;
/**
* 是否跳过
*/
private
boolean
isSkip
;
/**
* @param url 播放url
* @param title 标题
* @param type 类型 广告还是正常类型
*/
public
GSYADVideoModel
(
String
url
,
String
title
,
int
type
)
{
public
GSYADVideoModel
(
String
url
,
String
title
,
int
type
)
{
this
(
url
,
title
,
type
,
false
);
}
/**
* @param url 播放url
* @param title 标题
* @param type 类型 广告还是正常类型
* @param isSkip 是否跳过
*/
public
GSYADVideoModel
(
String
url
,
String
title
,
int
type
,
boolean
isSkip
)
{
super
(
url
,
title
);
super
(
url
,
title
);
mType
=
type
;
this
.
mType
=
type
;
this
.
isSkip
=
isSkip
;
}
}
public
int
getType
()
{
public
int
getType
()
{
return
mType
;
return
mType
;
}
}
public
void
set
m
Type
(
int
type
)
{
public
void
setType
(
int
type
)
{
this
.
mType
=
type
;
this
.
mType
=
type
;
}
}
public
boolean
isSkip
()
{
return
isSkip
;
}
public
void
setSkip
(
boolean
skip
)
{
isSkip
=
skip
;
}
}
}
}
}
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/ListGSYVideoPlayer.java
浏览文件 @
ac4ce47d
...
@@ -48,6 +48,7 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
...
@@ -48,6 +48,7 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
* 设置播放URL
* 设置播放URL
*
*
* @param url 播放url
* @param url 播放url
* @param position 需要播放的位置
* @param cacheWithPlay 是否边播边缓存
* @param cacheWithPlay 是否边播边缓存
* @return
* @return
*/
*/
...
@@ -60,6 +61,7 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
...
@@ -60,6 +61,7 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
*
*
* @param url 播放url
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cacheWithPlay 是否边播边缓存
* @param position 需要播放的位置
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @return
* @return
*/
*/
...
@@ -72,6 +74,7 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
...
@@ -72,6 +74,7 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
*
*
* @param url 播放url
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cacheWithPlay 是否边播边缓存
* @param position 需要播放的位置
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param mapHeadData http header
* @param mapHeadData http header
* @return
* @return
...
@@ -85,9 +88,10 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
...
@@ -85,9 +88,10 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
*
*
* @param url 播放url
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cacheWithPlay 是否边播边缓存
* @param position 需要播放的位置
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param mapHeadData http header
* @param mapHeadData http header
* @param changeState
* @param changeState
切换的时候释放surface
* @return
* @return
*/
*/
protected
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
boolean
cacheWithPlay
,
int
position
,
File
cachePath
,
Map
<
String
,
String
>
mapHeadData
,
boolean
changeState
)
{
protected
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
boolean
cacheWithPlay
,
int
position
,
File
cachePath
,
Map
<
String
,
String
>
mapHeadData
,
boolean
changeState
)
{
...
@@ -198,7 +202,7 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
...
@@ -198,7 +202,7 @@ public class ListGSYVideoPlayer extends StandardGSYVideoPlayer {
*/
*/
public
boolean
playNext
()
{
public
boolean
playNext
()
{
if
(
mPlayPosition
<
(
mUriList
.
size
()
-
1
))
{
if
(
mPlayPosition
<
(
mUriList
.
size
()
-
1
))
{
mPlayPosition
+=
1
;
mPlayPosition
+=
1
;
GSYVideoModel
gsyVideoModel
=
mUriList
.
get
(
mPlayPosition
);
GSYVideoModel
gsyVideoModel
=
mUriList
.
get
(
mPlayPosition
);
mSaveChangeViewTIme
=
0
;
mSaveChangeViewTIme
=
0
;
setUp
(
mUriList
,
mCache
,
mPlayPosition
,
null
,
mMapHeadData
,
false
);
setUp
(
mUriList
,
mCache
,
mPlayPosition
,
null
,
mMapHeadData
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录