Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ac13
GSYVideoPlayer
提交
97d3ac76
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 搜索 >>
提交
97d3ac76
编写于
9月 11, 2019
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #2247
上级
4b5dcde8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
37 deletion
+72
-37
app/src/main/java/com/example/gsyvideoplayer/exo/DetailExoListPlayer.java
...a/com/example/gsyvideoplayer/exo/DetailExoListPlayer.java
+4
-1
app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2MediaPlayer.java
...va/com/example/gsyvideoplayer/exo/GSYExo2MediaPlayer.java
+17
-0
app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2PlayerView.java
...ava/com/example/gsyvideoplayer/exo/GSYExo2PlayerView.java
+51
-36
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/exo/DetailExoListPlayer.java
浏览文件 @
97d3ac76
...
...
@@ -44,8 +44,8 @@ public class DetailExoListPlayer extends GSYBaseActivityDetail<GSYExo2PlayerView
initVideo
();
List
<
GSYVideoModel
>
urls
=
new
ArrayList
<>();
urls
.
add
(
new
GSYVideoModel
(
"https://media6.smartstudy.com/ae/07/3997/2/dest.m3u8"
,
"标题3"
));
urls
.
add
(
new
GSYVideoModel
(
"http://7xjmzj.com1.z0.glb.clouddn.com/20171026175005_JObCxCE2.mp4"
,
"标题1"
));
urls
.
add
(
new
GSYVideoModel
(
"https://media6.smartstudy.com/ae/07/3997/2/dest.m3u8"
,
"标题3"
));
urls
.
add
(
new
GSYVideoModel
(
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
,
"标题2"
));
detailPlayer
.
setUp
(
urls
,
0
);
...
...
@@ -91,6 +91,7 @@ public class DetailExoListPlayer extends GSYBaseActivityDetail<GSYExo2PlayerView
/**
* 重载为GSYExoVideoManager的方法处理
*/
...
...
@@ -151,4 +152,6 @@ public class DetailExoListPlayer extends GSYBaseActivityDetail<GSYExo2PlayerView
}
return
detailPlayer
;
}
}
app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2MediaPlayer.java
浏览文件 @
97d3ac76
...
...
@@ -7,11 +7,14 @@ import com.google.android.exoplayer2.C;
import
com.google.android.exoplayer2.Timeline
;
import
com.google.android.exoplayer2.source.ConcatenatingMediaSource
;
import
com.google.android.exoplayer2.source.MediaSource
;
import
com.shuyu.gsyvideoplayer.utils.Debuger
;
import
java.io.FileDescriptor
;
import
java.util.List
;
import
java.util.Map
;
import
tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer
;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
/**
* 自定义exo player,实现不同于库的exo 无缝切换效果
...
...
@@ -24,6 +27,8 @@ public class GSYExo2MediaPlayer extends IjkExo2MediaPlayer {
private
final
Timeline
.
Window
window
=
new
Timeline
.
Window
();
public
static
final
int
POSITION_DISCONTINUITY
=
899
;
public
GSYExo2MediaPlayer
(
Context
context
)
{
super
(
context
);
}
...
...
@@ -52,6 +57,12 @@ public class GSYExo2MediaPlayer extends IjkExo2MediaPlayer {
throw
new
UnsupportedOperationException
(
"Deprecated, try setDataSource(List<String> uris, Map<String, String> headers)"
);
}
@Override
public
void
onPositionDiscontinuity
(
int
reason
)
{
super
.
onPositionDiscontinuity
(
reason
);
notifyOnInfo
(
POSITION_DISCONTINUITY
,
reason
);
}
public
void
setDataSource
(
List
<
String
>
uris
,
Map
<
String
,
String
>
headers
,
boolean
cache
)
{
mHeaders
=
headers
;
if
(
uris
==
null
)
{
...
...
@@ -108,4 +119,10 @@ public class GSYExo2MediaPlayer extends IjkExo2MediaPlayer {
}
}
public
int
getCurrentWindowIndex
()
{
if
(
mInternalPlayer
==
null
)
{
return
0
;
}
return
mInternalPlayer
.
getCurrentWindowIndex
();
}
}
app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2PlayerView.java
浏览文件 @
97d3ac76
...
...
@@ -26,13 +26,14 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
example
.
gsyvideoplayer
.
exo
.
GSYExo2MediaPlayer
.
POSITION_DISCONTINUITY
;
/**
* Created by guoshuyu on 2018/5/16.
* 自定义View支持exo的list数据,实现无缝切换效果
*
* 这是一种思路,通过自定义后GSYExo2MediaPlayer内部,通过ConcatenatingMediaSource实现列表播放
* 诸如此类,还可以实现AdsMediaSource等
Created by guoshuyu on 2018/5/16.
自定义View支持exo的list数据,实现无缝切换效果
这是一种思路,通过自定义后GSYExo2MediaPlayer内部,通过ConcatenatingMediaSource实现列表播放
诸如此类,还可以实现AdsMediaSource等
*/
public
class
GSYExo2PlayerView
extends
StandardGSYVideoPlayer
{
...
...
@@ -42,7 +43,7 @@ public class GSYExo2PlayerView extends StandardGSYVideoPlayer {
protected
boolean
mExoCache
=
false
;
/**
*
1.5.0开始加入,如果需要不同布局区分功能,需要重载
1.5.0开始加入,如果需要不同布局区分功能,需要重载
*/
public
GSYExo2PlayerView
(
Context
context
,
Boolean
fullFlag
)
{
super
(
context
,
fullFlag
);
...
...
@@ -58,50 +59,50 @@ public class GSYExo2PlayerView extends StandardGSYVideoPlayer {
/**
*
设置播放URL
*
* @param url
播放url
* @param position
需要播放的位置
*
@return
设置播放URL
@param url
播放url
@param position
需要播放的位置
@return
*/
public
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
int
position
)
{
return
setUp
(
url
,
position
,
null
,
new
HashMap
<
String
,
String
>());
}
/**
*
设置播放URL
*
* @param url
播放url
* @param position
需要播放的位置
* @param cachePath
缓存路径,如果是M3U8或者HLS,请设置为false
*
@return
设置播放URL
@param url
播放url
@param position
需要播放的位置
@param cachePath
缓存路径,如果是M3U8或者HLS,请设置为false
@return
*/
public
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
int
position
,
File
cachePath
)
{
return
setUp
(
url
,
position
,
cachePath
,
new
HashMap
<
String
,
String
>());
}
/**
*
设置播放URL
*
* @param url
播放url
* @param position
需要播放的位置
* @param cachePath
缓存路径,如果是M3U8或者HLS,请设置为false
* @param mapHeadData
http header
*
@return
设置播放URL
@param url
播放url
@param position
需要播放的位置
@param cachePath
缓存路径,如果是M3U8或者HLS,请设置为false
@param mapHeadData
http header
@return
*/
public
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
int
position
,
File
cachePath
,
Map
<
String
,
String
>
mapHeadData
)
{
public
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
int
position
,
File
cachePath
,
Map
<
String
,
String
>
mapHeadData
)
{
return
setUp
(
url
,
position
,
cachePath
,
mapHeadData
,
true
);
}
/**
*
设置播放URL
*
* @param url
播放url
* @param position
需要播放的位置
* @param cachePath
缓存路径,如果是M3U8或者HLS,请设置为false
* @param mapHeadData
http header
* @param changeState
切换的时候释放surface
*
@return
设置播放URL
@param url
播放url
@param position
需要播放的位置
@param cachePath
缓存路径,如果是M3U8或者HLS,请设置为false
@param mapHeadData
http header
@param changeState
切换的时候释放surface
@return
*/
protected
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
int
position
,
File
cachePath
,
Map
<
String
,
String
>
mapHeadData
,
boolean
changeState
)
{
mUriList
=
url
;
...
...
@@ -125,6 +126,7 @@ public class GSYExo2PlayerView extends StandardGSYVideoPlayer {
st
.
mPlayPosition
=
sf
.
mPlayPosition
;
st
.
mUriList
=
sf
.
mUriList
;
st
.
mExoCache
=
sf
.
mExoCache
;
st
.
mTitle
=
sf
.
mTitle
;
}
@Override
...
...
@@ -151,6 +153,7 @@ public class GSYExo2PlayerView extends StandardGSYVideoPlayer {
super
.
resolveNormalVideoShow
(
oldF
,
vp
,
gsyVideoPlayer
);
}
@Override
protected
void
startPrepare
()
{
if
(
getGSYVideoManager
().
listener
()
!=
null
)
{
...
...
@@ -177,14 +180,14 @@ public class GSYExo2PlayerView extends StandardGSYVideoPlayer {
Debuger
.
printfError
(
"********************** urls isEmpty . Do you know why ? **********************"
);
}
((
GSYExoVideoManager
)
getGSYVideoManager
()).
prepare
(
urls
,
(
mMapHeadData
==
null
)
?
new
HashMap
<
String
,
String
>()
:
mMapHeadData
,
mLooping
,
mSpeed
,
mExoCache
,
mCachePath
);
((
GSYExoVideoManager
)
getGSYVideoManager
()).
prepare
(
urls
,
(
mMapHeadData
==
null
)
?
new
HashMap
<
String
,
String
>()
:
mMapHeadData
,
mLooping
,
mSpeed
,
mExoCache
,
mCachePath
);
setStateAndUi
(
CURRENT_STATE_PREPAREING
);
}
/**
*
显示wifi确定框,如需要自定义继承重写即可
显示wifi确定框,如需要自定义继承重写即可
*/
@Override
protected
void
showWifiDialog
()
{
...
...
@@ -242,5 +245,17 @@ public class GSYExo2PlayerView extends StandardGSYVideoPlayer {
return
GSYExoVideoManager
.
SMALL_ID
;
}
@Override
public
void
onInfo
(
int
what
,
int
extra
)
{
if
(
what
==
POSITION_DISCONTINUITY
)
{
int
window
=
((
GSYExo2MediaPlayer
)
getGSYVideoManager
().
getPlayer
().
getMediaPlayer
()).
getCurrentWindowIndex
();
mPlayPosition
=
window
;
GSYVideoModel
gsyVideoModel
=
mUriList
.
get
(
window
);
if
(!
TextUtils
.
isEmpty
(
gsyVideoModel
.
getTitle
()))
{
mTitleTextView
.
setText
(
gsyVideoModel
.
getTitle
());
}
}
else
{
super
.
onInfo
(
what
,
extra
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录