Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
GSYVideoPlayer
提交
2d9932a9
G
GSYVideoPlayer
项目概览
NotesChapter
/
GSYVideoPlayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
8
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,发现更多精彩内容 >>
提交
2d9932a9
编写于
5月 21, 2018
作者:
G
guoshuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix exo
上级
0284d70e
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
112 addition
and
158 deletion
+112
-158
README.md
README.md
+1
-0
app/src/main/java/com/example/gsyvideoplayer/DetailControlActivity.java
...ava/com/example/gsyvideoplayer/DetailControlActivity.java
+0
-1
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
...rc/main/java/com/example/gsyvideoplayer/DetailPlayer.java
+0
-1
app/src/main/java/com/example/gsyvideoplayer/GSYApplication.java
.../main/java/com/example/gsyvideoplayer/GSYApplication.java
+0
-2
app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2PlayerView.java
...ava/com/example/gsyvideoplayer/exo/GSYExo2PlayerView.java
+0
-5
app/src/main/java/com/example/gsyvideoplayer/exo/GSYExoVideoManager.java
...va/com/example/gsyvideoplayer/exo/GSYExoVideoManager.java
+4
-9
app/src/main/java/com/example/gsyvideoplayer/video/MultiSampleVideo.java
...va/com/example/gsyvideoplayer/video/MultiSampleVideo.java
+0
-8
app/src/main/java/com/example/gsyvideoplayer/video/manager/CustomManager.java
...m/example/gsyvideoplayer/video/manager/CustomManager.java
+4
-8
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYPreViewManager.java
...main/java/com/shuyu/gsyvideoplayer/GSYPreViewManager.java
+2
-6
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoADManager.java
...main/java/com/shuyu/gsyvideoplayer/GSYVideoADManager.java
+4
-12
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoBaseManager.java
...in/java/com/shuyu/gsyvideoplayer/GSYVideoBaseManager.java
+46
-52
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
...c/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
+6
-12
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/cache/ProxyCacheManager.java
...ava/com/shuyu/gsyvideoplayer/cache/ProxyCacheManager.java
+1
-0
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/player/EXO2PlayerManager.java
...va/com/shuyu/gsyvideoplayer/player/EXO2PlayerManager.java
+10
-3
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/player/IJKPlayerManager.java
...ava/com/shuyu/gsyvideoplayer/player/IJKPlayerManager.java
+3
-1
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/player/SystemPlayerManager.java
.../com/shuyu/gsyvideoplayer/player/SystemPlayerManager.java
+1
-1
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/GSYADVideoPlayer.java
...java/com/shuyu/gsyvideoplayer/video/GSYADVideoPlayer.java
+0
-9
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoPlayer.java
...a/com/shuyu/gsyvideoplayer/video/base/GSYVideoPlayer.java
+0
-9
gsyvideoplayer-exo2/src/main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java
...main/java/tv/danmaku/ijk/media/exo2/ExoSourceManager.java
+8
-4
gsyvideoplayer-exo2/src/main/java/tv/danmaku/ijk/media/exo2/IjkExo2MediaPlayer.java
...in/java/tv/danmaku/ijk/media/exo2/IjkExo2MediaPlayer.java
+22
-15
未找到文件。
README.md
浏览文件 @
2d9932a9
...
...
@@ -137,6 +137,7 @@ compile 'com.shuyu:gsyVideoPlayer-ex_so:4.1.3'
*
优化ExoPlayer的问题
*
增加ExoPlayer循环播放支持
*
增加ExoPlayer自定义DEMO,演示ExoPlayer实现无缝切换
*
ijk的
`logLevel`
、
`ijkLibLoader`
直接通过IJKPlayerManager静态方法设置
...
...
app/src/main/java/com/example/gsyvideoplayer/DetailControlActivity.java
浏览文件 @
2d9932a9
...
...
@@ -45,7 +45,6 @@ import permissions.dispatcher.OnPermissionDenied;
import
permissions.dispatcher.OnShowRationale
;
import
permissions.dispatcher.PermissionRequest
;
import
permissions.dispatcher.RuntimePermissions
;
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
;
/**
* sampleVideo支持全屏与非全屏切换的清晰度,旋转,镜像等功能.
...
...
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
浏览文件 @
2d9932a9
...
...
@@ -28,7 +28,6 @@ import java.util.List;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
;
public
class
DetailPlayer
extends
AppCompatActivity
{
...
...
app/src/main/java/com/example/gsyvideoplayer/GSYApplication.java
浏览文件 @
2d9932a9
...
...
@@ -5,8 +5,6 @@ import android.app.Application;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
import
com.shuyu.gsyvideoplayer.utils.GSYVideoType
;
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
;
//import com.squareup.leakcanary.LeakCanary;
/**
...
...
app/src/main/java/com/example/gsyvideoplayer/exo/GSYExo2PlayerView.java
浏览文件 @
2d9932a9
...
...
@@ -26,7 +26,6 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
/**
* Created by guoshuyu on 2018/5/16.
...
...
@@ -217,10 +216,6 @@ public class GSYExo2PlayerView extends StandardGSYVideoPlayer {
/**********以下重载GSYVideoPlayer的GSYVideoViewBridge相关实现***********/
public
void
setIjkLibLoader
(
IjkLibLoader
libLoader
)
{
GSYExoVideoManager
.
setIjkLibLoader
(
libLoader
);
}
@Override
public
GSYVideoViewBridge
getGSYVideoManager
()
{
GSYExoVideoManager
.
instance
().
initContext
(
getContext
().
getApplicationContext
());
...
...
app/src/main/java/com/example/gsyvideoplayer/exo/GSYExoVideoManager.java
浏览文件 @
2d9932a9
...
...
@@ -17,8 +17,6 @@ import java.io.File;
import
java.util.List
;
import
java.util.Map
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideNavKey
;
/**
...
...
@@ -35,11 +33,9 @@ public class GSYExoVideoManager extends GSYVideoBaseManager {
@SuppressLint
(
"StaticFieldLeak"
)
private
static
GSYExoVideoManager
videoManager
;
/***
* @param libLoader 是否使用外部动态加载so
* */
private
GSYExoVideoManager
(
IjkLibLoader
libLoader
)
{
init
(
libLoader
);
private
GSYExoVideoManager
()
{
init
();
}
/**
...
...
@@ -47,7 +43,7 @@ public class GSYExoVideoManager extends GSYVideoBaseManager {
*/
public
static
synchronized
GSYExoVideoManager
instance
()
{
if
(
videoManager
==
null
)
{
videoManager
=
new
GSYExoVideoManager
(
ijkLibLoader
);
videoManager
=
new
GSYExoVideoManager
();
}
return
videoManager
;
}
...
...
@@ -61,7 +57,6 @@ public class GSYExoVideoManager extends GSYVideoBaseManager {
if
(
urls
.
size
()
==
0
)
return
;
Message
msg
=
new
Message
();
msg
.
what
=
HANDLER_PREPARE
;
mMapHeadData
=
mapHeadData
;
msg
.
obj
=
new
GSYExoModel
(
urls
,
mapHeadData
,
loop
,
speed
,
cache
,
cachePath
);
sendMessage
(
msg
);
if
(
needTimeOutOther
)
{
...
...
app/src/main/java/com/example/gsyvideoplayer/video/MultiSampleVideo.java
浏览文件 @
2d9932a9
...
...
@@ -9,9 +9,6 @@ import com.example.gsyvideoplayer.video.manager.CustomManager;
import
com.shuyu.gsyvideoplayer.utils.Debuger
;
import
com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
;
import
java.io.File
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
/**
* 多个同时播放的播放控件
...
...
@@ -66,11 +63,6 @@ public class MultiSampleVideo extends SampleCoverVideo {
};
}
@Override
public
void
setIjkLibLoader
(
IjkLibLoader
libLoader
)
{
}
@Override
public
GSYVideoViewBridge
getGSYVideoManager
()
{
CustomManager
.
getCustomManager
(
getKey
()).
initContext
(
getContext
().
getApplicationContext
());
...
...
app/src/main/java/com/example/gsyvideoplayer/video/manager/CustomManager.java
浏览文件 @
2d9932a9
...
...
@@ -15,8 +15,6 @@ import com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer;
import
java.util.HashMap
;
import
java.util.Map
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideNavKey
;
/**
...
...
@@ -34,11 +32,9 @@ public class CustomManager extends GSYVideoBaseManager {
private
static
Map
<
String
,
CustomManager
>
sMap
=
new
HashMap
<>();
/***
* @param libLoader 是否使用外部动态加载so
* */
public
CustomManager
(
IjkLibLoader
libLoader
)
{
init
(
libLoader
);
public
CustomManager
()
{
init
();
}
...
...
@@ -120,7 +116,7 @@ public class CustomManager extends GSYVideoBaseManager {
}
CustomManager
customManager
=
sMap
.
get
(
key
);
if
(
customManager
==
null
)
{
customManager
=
new
CustomManager
(
null
);
customManager
=
new
CustomManager
();
sMap
.
put
(
key
,
customManager
);
}
return
customManager
;
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYPreViewManager.java
浏览文件 @
2d9932a9
...
...
@@ -14,7 +14,6 @@ import java.io.IOException;
import
java.util.Map
;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
;
/**
...
...
@@ -37,7 +36,6 @@ public class GSYPreViewManager implements IMediaPlayer.OnPreparedListener, IjkMe
private
MediaHandler
mMediaHandler
;
private
boolean
seekToComplete
=
true
;
private
static
IjkLibLoader
ijkLibLoader
;
//自定义so包加载类
public
static
synchronized
GSYPreViewManager
instance
()
{
if
(
videoManager
==
null
)
{
...
...
@@ -47,9 +45,7 @@ public class GSYPreViewManager implements IMediaPlayer.OnPreparedListener, IjkMe
}
private
GSYPreViewManager
()
{
IjkLibLoader
libLoader
=
GSYVideoManager
.
getIjkLibLoader
();
mediaPlayer
=
(
libLoader
==
null
)
?
new
IjkMediaPlayer
()
:
new
IjkMediaPlayer
(
libLoader
);
ijkLibLoader
=
libLoader
;
mediaPlayer
=
new
IjkMediaPlayer
();
mMediaHandlerThread
=
new
HandlerThread
(
TAG
);
mMediaHandlerThread
.
start
();
...
...
@@ -99,7 +95,7 @@ public class GSYPreViewManager implements IMediaPlayer.OnPreparedListener, IjkMe
}
private
void
initIJKPlayer
(
Message
msg
)
{
mediaPlayer
=
(
ijkLibLoader
==
null
)
?
new
IjkMediaPlayer
()
:
new
IjkMediaPlayer
(
ijkLibLoader
);
mediaPlayer
=
new
IjkMediaPlayer
(
);
mediaPlayer
.
setAudioStreamType
(
AudioManager
.
STREAM_MUSIC
);
try
{
mediaPlayer
.
setDataSource
(((
GSYModel
)
msg
.
obj
).
getUrl
(),
((
GSYModel
)
msg
.
obj
).
getMapHeadData
());
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoADManager.java
浏览文件 @
2d9932a9
...
...
@@ -11,8 +11,6 @@ import android.view.Window;
import
com.shuyu.gsyvideoplayer.utils.CommonUtil
;
import
com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideNavKey
;
/**
...
...
@@ -31,16 +29,10 @@ public class GSYVideoADManager extends GSYVideoBaseManager {
@SuppressLint
(
"StaticFieldLeak"
)
private
static
GSYVideoADManager
videoManager
;
//单例模式实在不好给instance()加参数,还是直接设为静态变量吧
//自定义so包加载类
private
static
IjkLibLoader
ijkLibLoader
;
/***
* @param libLoader 是否使用外部动态加载so
* */
private
GSYVideoADManager
(
IjkLibLoader
libLoader
)
{
ijkLibLoader
=
libLoader
;
init
(
libLoader
);
private
GSYVideoADManager
()
{
init
();
}
/**
...
...
@@ -48,7 +40,7 @@ public class GSYVideoADManager extends GSYVideoBaseManager {
*/
public
static
synchronized
GSYVideoADManager
instance
()
{
if
(
videoManager
==
null
)
{
videoManager
=
new
GSYVideoADManager
(
ijkLibLoader
);
videoManager
=
new
GSYVideoADManager
();
}
return
videoManager
;
}
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoBaseManager.java
浏览文件 @
2d9932a9
...
...
@@ -28,8 +28,6 @@ import java.util.List;
import
java.util.Map
;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
/**
* 基类管理器
* Created by guoshuyu on 2018/1/25.
...
...
@@ -51,9 +49,7 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
protected
static
final
int
BUFFER_TIME_OUT_ERROR
=
-
192
;
//外部超时错误码
//单例模式实在不好给instance()加参数,还是直接设为静态变量吧
//自定义so包加载类
protected
static
IjkLibLoader
ijkLibLoader
;
protected
Context
context
;
protected
MediaHandler
mMediaHandler
;
...
...
@@ -63,71 +59,70 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
protected
WeakReference
<
GSYMediaPlayerListener
>
lastListener
;
//配置ijk option
/**
* 配置ijk option
*/
protected
List
<
VideoOptionModel
>
optionModelList
;
//是否需要的自定义缓冲路径
protected
File
cacheFile
;
//播放的tag,防止错位置,因为普通的url也可能重复
/**
* 播放的tag,防止错位置,因为普通的url也可能重复
*/
protected
String
playTag
=
""
;
//header for cache
protected
Map
<
String
,
String
>
mMapHeadData
;
protected
Context
context
;
/**
*
*
播放内核管理
*/
protected
IPlayerManager
playerManager
;
/**
*
*
缓存管理
*/
protected
ICacheManager
cacheManager
;
//当前播放的视频宽的高
/**
* 当前播放的视频宽的高
*/
protected
int
currentVideoWidth
=
0
;
//当前播放的视屏的高
/**
* 当前播放的视屏的高
*/
protected
int
currentVideoHeight
=
0
;
//当前视频的最后状态
/**
* 当前视频的最后状态
*/
protected
int
lastState
;
//播放的tag,防止错位置,因为普通的url也可能重复
/**
* 播放的tag,防止错位置,因为普通的url也可能重复
*/
protected
int
playPosition
=
-
22
;
//缓冲比例
protected
int
buffterPoint
;
/**
* 缓冲比例
*/
protected
int
bufferPoint
;
//播放超时
/**
* 播放超时
*/
protected
int
timeOut
=
8
*
1000
;
//播放类型,默认IJK
/**
* 播放类型,默认IJK
*/
protected
int
videoType
=
GSYVideoType
.
IJKPLAYER
;
//是否需要静音
/**
* 是否需要静音
*/
protected
boolean
needMute
=
false
;
//是否需要外部超时判断
protected
boolean
needTimeOutOther
;
/**
* 设置自定义so包加载类
* 需要在instance之前设置
* 是否需要外部超时判断
*/
public
static
void
setIjkLibLoader
(
IjkLibLoader
libLoader
)
{
IJKPlayerManager
.
setIjkLibLoader
(
libLoader
);
ijkLibLoader
=
libLoader
;
}
public
static
IjkLibLoader
getIjkLibLoader
()
{
return
ijkLibLoader
;
}
protected
boolean
needTimeOutOther
;
/**
* 删除默认所有缓存文件
...
...
@@ -145,11 +140,7 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
}
}
/***
* @param libLoader 是否使用外部动态加载so
* */
protected
void
init
(
IjkLibLoader
libLoader
)
{
IJKPlayerManager
.
setIjkLibLoader
(
libLoader
);
protected
void
init
()
{
HandlerThread
mediaHandlerThread
=
new
HandlerThread
(
TAG
);
mediaHandlerThread
.
start
();
mMediaHandler
=
new
MediaHandler
((
mediaHandlerThread
.
getLooper
()));
...
...
@@ -171,6 +162,8 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
protected
ICacheManager
getCacheManager
(
int
type
)
{
switch
(
type
)
{
case
GSYVideoType
.
IJKEXOPLAYER2
:
//TODO 针对exoPlayer的cache处理
return
null
;
case
GSYVideoType
.
SYSTEMPLAYER
:
case
GSYVideoType
.
IJKPLAYER
:
default
:
...
...
@@ -220,7 +213,6 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
if
(
TextUtils
.
isEmpty
(
url
))
return
;
Message
msg
=
new
Message
();
msg
.
what
=
HANDLER_PREPARE
;
mMapHeadData
=
mapHeadData
;
GSYModel
fb
=
new
GSYModel
(
url
,
mapHeadData
,
loop
,
speed
,
cache
,
cachePath
);
msg
.
obj
=
fb
;
sendMessage
(
msg
);
...
...
@@ -286,10 +278,10 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
@Override
public
void
run
()
{
if
(
listener
()
!=
null
)
{
if
(
percent
>
buff
t
erPoint
)
{
if
(
percent
>
bufferPoint
)
{
listener
().
onBufferingUpdate
(
percent
);
}
else
{
listener
().
onBufferingUpdate
(
buff
t
erPoint
);
listener
().
onBufferingUpdate
(
bufferPoint
);
}
}
}
...
...
@@ -360,7 +352,7 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
@Override
public
void
onCacheAvailable
(
File
cacheFile
,
String
url
,
int
percentsAvailable
)
{
buff
t
erPoint
=
percentsAvailable
;
bufferPoint
=
percentsAvailable
;
}
@Override
...
...
@@ -469,7 +461,7 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
if
(
cacheManager
!=
null
)
{
cacheManager
.
release
();
}
buff
t
erPoint
=
0
;
bufferPoint
=
0
;
cancelTimeOutBuffer
();
break
;
case
HANDLER_RELEASE_SURFACE:
...
...
@@ -491,7 +483,9 @@ public abstract class GSYVideoBaseManager implements IMediaPlayer.OnPreparedList
playerManager
=
getPlayManager
(
videoType
);
cacheManager
=
getCacheManager
(
videoType
);
cacheManager
.
setCacheAvailableListener
(
this
);
if
(
cacheManager
!=
null
)
{
cacheManager
.
setCacheAvailableListener
(
this
);
}
playerManager
.
initVideoPlayer
(
context
,
msg
,
optionModelList
,
cacheManager
);
setNeedMute
(
needMute
);
IMediaPlayer
mediaPlayer
=
playerManager
.
getMediaPlayer
();
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
浏览文件 @
2d9932a9
...
...
@@ -12,8 +12,6 @@ import com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener;
import
com.shuyu.gsyvideoplayer.utils.CommonUtil
;
import
com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideNavKey
;
...
...
@@ -33,11 +31,9 @@ public class GSYVideoManager extends GSYVideoBaseManager {
@SuppressLint
(
"StaticFieldLeak"
)
private
static
GSYVideoManager
videoManager
;
/***
* @param libLoader 是否使用外部动态加载so
* */
private
GSYVideoManager
(
IjkLibLoader
libLoader
)
{
init
(
libLoader
);
private
GSYVideoManager
()
{
init
();
}
/**
...
...
@@ -45,7 +41,7 @@ public class GSYVideoManager extends GSYVideoBaseManager {
*/
public
static
synchronized
GSYVideoManager
instance
()
{
if
(
videoManager
==
null
)
{
videoManager
=
new
GSYVideoManager
(
ijkLibLoader
);
videoManager
=
new
GSYVideoManager
();
}
return
videoManager
;
}
...
...
@@ -54,12 +50,10 @@ public class GSYVideoManager extends GSYVideoBaseManager {
* 同步创建一个临时管理器
*/
public
static
synchronized
GSYVideoManager
tmpInstance
(
GSYMediaPlayerListener
listener
)
{
GSYVideoManager
gsyVideoManager
=
new
GSYVideoManager
(
ijkLibLoader
);
gsyVideoManager
.
buff
terPoint
=
videoManager
.
bufft
erPoint
;
GSYVideoManager
gsyVideoManager
=
new
GSYVideoManager
();
gsyVideoManager
.
buff
erPoint
=
videoManager
.
buff
erPoint
;
gsyVideoManager
.
optionModelList
=
videoManager
.
optionModelList
;
gsyVideoManager
.
cacheFile
=
videoManager
.
cacheFile
;
gsyVideoManager
.
playTag
=
videoManager
.
playTag
;
gsyVideoManager
.
mMapHeadData
=
videoManager
.
mMapHeadData
;
gsyVideoManager
.
currentVideoWidth
=
videoManager
.
currentVideoWidth
;
gsyVideoManager
.
currentVideoHeight
=
videoManager
.
currentVideoHeight
;
gsyVideoManager
.
context
=
videoManager
.
context
;
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/cache/ProxyCacheManager.java
浏览文件 @
2d9932a9
...
...
@@ -20,6 +20,7 @@ import java.util.Map;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
/**
* 代理缓存管理器
* Created by guoshuyu on 2018/5/18.
*/
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/player/EXO2PlayerManager.java
浏览文件 @
2d9932a9
...
...
@@ -45,9 +45,16 @@ public class EXO2PlayerManager implements IPlayerManager {
GSYModel
gsyModel
=
(
GSYModel
)
msg
.
obj
;
try
{
mediaPlayer
.
setLooping
(
gsyModel
.
isLooping
());
mediaPlayer
.
setCache
(
gsyModel
.
isCache
());
mediaPlayer
.
setCacheDir
(
gsyModel
.
getCachePath
());
mediaPlayer
.
setDataSource
(
context
,
Uri
.
parse
(
gsyModel
.
getUrl
()),
gsyModel
.
getMapHeadData
());
mediaPlayer
.
setPreview
(
gsyModel
.
getMapHeadData
()
!=
null
&&
gsyModel
.
getMapHeadData
().
size
()
>
0
);
if
(
gsyModel
.
isCache
()
&&
cacheManager
!=
null
)
{
//通过管理器处理
cacheManager
.
doCacheLogic
(
context
,
mediaPlayer
,
gsyModel
.
getUrl
(),
gsyModel
.
getMapHeadData
(),
gsyModel
.
getCachePath
());
}
else
{
//通过自己的内部缓存机制
mediaPlayer
.
setCache
(
gsyModel
.
isCache
());
mediaPlayer
.
setCacheDir
(
gsyModel
.
getCachePath
());
mediaPlayer
.
setDataSource
(
context
,
Uri
.
parse
(
gsyModel
.
getUrl
()),
gsyModel
.
getMapHeadData
());
}
//很遗憾,EXO2的setSpeed只能在播放前生效
if
(
gsyModel
.
getSpeed
()
!=
1
&&
gsyModel
.
getSpeed
()
>
0
)
{
mediaPlayer
.
setSpeed
(
gsyModel
.
getSpeed
(),
1
);
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/player/IJKPlayerManager.java
浏览文件 @
2d9932a9
...
...
@@ -31,7 +31,9 @@ import tv.danmaku.ijk.media.player.IjkMediaPlayer;
public
class
IJKPlayerManager
implements
IPlayerManager
{
//log level
/**
* log level
*/
private
static
int
logLevel
=
IjkMediaPlayer
.
IJK_LOG_DEFAULT
;
private
static
IjkLibLoader
ijkLibLoader
;
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/player/SystemPlayerManager.java
浏览文件 @
2d9932a9
...
...
@@ -44,7 +44,7 @@ public class SystemPlayerManager implements IPlayerManager {
if
(
gsyModel
.
isCache
()
&&
cacheManager
!=
null
)
{
cacheManager
.
doCacheLogic
(
context
,
mediaPlayer
,
gsyModel
.
getUrl
(),
gsyModel
.
getMapHeadData
(),
gsyModel
.
getCachePath
());
}
else
{
mediaPlayer
.
setDataSource
(
context
,
Uri
.
parse
(
gsyModel
.
getUrl
()),
((
GSYModel
)
msg
.
obj
)
.
getMapHeadData
());
mediaPlayer
.
setDataSource
(
context
,
Uri
.
parse
(
gsyModel
.
getUrl
()),
gsyModel
.
getMapHeadData
());
}
mediaPlayer
.
setLooping
(
gsyModel
.
isLooping
());
if
(
gsyModel
.
getSpeed
()
!=
1
&&
gsyModel
.
getSpeed
()
>
0
)
{
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/GSYADVideoPlayer.java
浏览文件 @
2d9932a9
...
...
@@ -15,9 +15,6 @@ import com.shuyu.gsyvideoplayer.utils.CommonUtil;
import
com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer
;
import
com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
;
import
java.io.File
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
/**
* Created by guoshuyu on 2018/2/1.
...
...
@@ -65,12 +62,6 @@ public class GSYADVideoPlayer extends StandardGSYVideoPlayer {
return
R
.
layout
.
video_layout_ad
;
}
@Override
public
void
setIjkLibLoader
(
IjkLibLoader
libLoader
)
{
GSYVideoADManager
.
setIjkLibLoader
(
libLoader
);
}
@Override
public
GSYVideoViewBridge
getGSYVideoManager
()
{
GSYVideoADManager
.
instance
().
initContext
(
getContext
().
getApplicationContext
());
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoPlayer.java
浏览文件 @
2d9932a9
...
...
@@ -5,7 +5,6 @@ import android.util.AttributeSet;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
import
tv.danmaku.ijk.media.player.IjkLibLoader
;
/**
* 兼容的空View,目前用于 GSYVideoManager的设置
...
...
@@ -30,14 +29,6 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer {
super
(
context
,
attrs
,
defStyleAttr
);
}
/**
* 设置自定义so包加载类,必须在setUp之前调用
* 不然setUp时会第一次实例化GSYVideoManager
*/
public
void
setIjkLibLoader
(
IjkLibLoader
libLoader
)
{
GSYVideoManager
.
setIjkLibLoader
(
libLoader
);
}
@Override
public
GSYVideoViewBridge
getGSYVideoManager
()
{
GSYVideoManager
.
instance
().
initContext
(
getContext
().
getApplicationContext
());
...
...
gsyvideoplayer-exo2/src/main/java/tv/danmaku/ijk/media/exo2/Exo
Help
er.java
→
gsyvideoplayer-exo2/src/main/java/tv/danmaku/ijk/media/exo2/Exo
SourceManag
er.java
浏览文件 @
2d9932a9
...
...
@@ -2,6 +2,7 @@ package tv.danmaku.ijk.media.exo2;
import
android.content.Context
;
import
android.net.Uri
;
import
android.support.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ext.rtmp.RtmpDataSourceFactory
;
...
...
@@ -32,9 +33,9 @@ import java.util.Map;
* Created by guoshuyu on 2018/5/18.
*/
public
class
Exo
Help
er
{
public
class
Exo
SourceManag
er
{
private
static
final
String
TAG
=
"
IjkExo2MediaPlay
er"
;
private
static
final
String
TAG
=
"
ExoSourceManag
er"
;
public
static
final
int
TYPE_RTMP
=
4
;
...
...
@@ -44,12 +45,15 @@ public class ExoHelper {
protected
Map
<
String
,
String
>
mMapHeadData
;
public
ExoHelper
(
Context
context
,
Map
<
String
,
String
>
mapHeadData
)
{
public
static
ExoSourceManager
newInstance
(
Context
context
,
@Nullable
Map
<
String
,
String
>
mapHeadData
)
{
return
new
ExoSourceManager
(
context
,
mapHeadData
);
}
private
ExoSourceManager
(
Context
context
,
Map
<
String
,
String
>
mapHeadData
)
{
mAppContext
=
context
.
getApplicationContext
();
mMapHeadData
=
mapHeadData
;
}
public
MediaSource
getMediaSource
(
String
dataSource
,
boolean
preview
,
boolean
cacheEnable
,
boolean
isLooping
,
File
cacheDir
)
{
Uri
contentUri
=
Uri
.
parse
(
dataSource
);
int
contentType
=
inferContentType
(
dataSource
);
...
...
gsyvideoplayer-exo2/src/main/java/tv/danmaku/ijk/media/exo2/IjkExo2MediaPlayer.java
浏览文件 @
2d9932a9
...
...
@@ -49,12 +49,13 @@ import tv.danmaku.ijk.media.player.misc.IjkTrackInfo;
* Exo
*/
public
class
IjkExo2MediaPlayer
extends
AbstractMediaPlayer
implements
Player
.
EventListener
,
AnalyticsListener
{
private
static
final
String
TAG
=
"IjkExo2MediaPlayer"
;
private
Context
mAppContext
;
private
SimpleExoPlayer
mInternalPlayer
;
private
EventLogger
mEventLogger
;
private
DefaultRenderersFactory
renderer
s
Factory
;
private
DefaultRenderersFactory
rendererFactory
;
private
MediaSource
mMediaSource
;
private
DefaultTrackSelector
mTrackSelector
;
private
String
mDataSource
;
...
...
@@ -64,9 +65,9 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
private
int
mVideoWidth
;
private
int
mVideoHeight
;
private
int
lastReportedPlaybackState
;
private
boolean
l
astReportedPlayWhenReady
;
private
boolean
mIsPrepare
ing
=
true
;
private
boolean
mI
sBuffering
=
false
;
private
boolean
isL
astReportedPlayWhenReady
;
private
boolean
isPrepar
ing
=
true
;
private
boolean
i
sBuffering
=
false
;
private
boolean
isLooping
=
false
;
/**
* 是否带上header
...
...
@@ -79,7 +80,7 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
/**
* dataSource等的帮组类
*/
private
Exo
Help
er
mExoHelper
;
private
Exo
SourceManag
er
mExoHelper
;
/**
* 缓存目录,可以为空
*/
...
...
@@ -91,7 +92,7 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
public
IjkExo2MediaPlayer
(
Context
context
)
{
mAppContext
=
context
.
getApplicationContext
();
lastReportedPlaybackState
=
Player
.
STATE_IDLE
;
mExoHelper
=
new
ExoHelper
(
context
,
mHeaders
);
mExoHelper
=
ExoSourceManager
.
newInstance
(
context
,
mHeaders
);
}
...
...
@@ -173,9 +174,9 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
:
DefaultRenderersFactory
.
EXTENSION_RENDERER_MODE_ON
)
:
DefaultRenderersFactory
.
EXTENSION_RENDERER_MODE_OFF
;
renderer
s
Factory
=
new
DefaultRenderersFactory
(
mAppContext
,
extensionRendererMode
);
rendererFactory
=
new
DefaultRenderersFactory
(
mAppContext
,
extensionRendererMode
);
DefaultLoadControl
loadControl
=
new
DefaultLoadControl
();
mInternalPlayer
=
ExoPlayerFactory
.
newSimpleInstance
(
renderer
s
Factory
,
mTrackSelector
,
loadControl
,
null
);
mInternalPlayer
=
ExoPlayerFactory
.
newSimpleInstance
(
rendererFactory
,
mTrackSelector
,
loadControl
,
null
);
mInternalPlayer
.
addListener
(
this
);
mInternalPlayer
.
addAnalyticsListener
(
this
);
mInternalPlayer
.
addListener
(
mEventLogger
);
...
...
@@ -406,6 +407,10 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
this
.
mMediaSource
=
mediaSource
;
}
public
ExoSourceManager
getExoHelper
()
{
return
mExoHelper
;
}
/**
* 倍速播放
*
...
...
@@ -431,6 +436,8 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
return
mInternalPlayer
.
getBufferedPercentage
();
}
@Override
public
void
onTimelineChanged
(
Timeline
timeline
,
Object
manifest
,
int
reason
)
{
...
...
@@ -451,22 +458,22 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
//重新播放状态顺序为:STATE_IDLE -》STATE_BUFFERING -》STATE_READY
//缓冲时顺序为:STATE_BUFFERING -》STATE_READY
//Log.e(TAG, "onPlayerStateChanged: playWhenReady = " + playWhenReady + ", playbackState = " + playbackState);
if
(
l
astReportedPlayWhenReady
!=
playWhenReady
||
lastReportedPlaybackState
!=
playbackState
)
{
if
(
mI
sBuffering
)
{
if
(
isL
astReportedPlayWhenReady
!=
playWhenReady
||
lastReportedPlaybackState
!=
playbackState
)
{
if
(
i
sBuffering
)
{
switch
(
playbackState
)
{
case
Player
.
STATE_ENDED
:
case
Player
.
STATE_READY
:
notifyOnInfo
(
IMediaPlayer
.
MEDIA_INFO_BUFFERING_END
,
mInternalPlayer
.
getBufferedPercentage
());
mI
sBuffering
=
false
;
i
sBuffering
=
false
;
break
;
}
}
if
(
mIsPrepare
ing
)
{
if
(
isPrepar
ing
)
{
switch
(
playbackState
)
{
case
Player
.
STATE_READY
:
notifyOnPrepared
();
mIsPrepare
ing
=
false
;
isPrepar
ing
=
false
;
break
;
}
}
...
...
@@ -474,7 +481,7 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
switch
(
playbackState
)
{
case
Player
.
STATE_BUFFERING
:
notifyOnInfo
(
IMediaPlayer
.
MEDIA_INFO_BUFFERING_START
,
mInternalPlayer
.
getBufferedPercentage
());
mI
sBuffering
=
true
;
i
sBuffering
=
true
;
break
;
case
Player
.
STATE_READY
:
break
;
...
...
@@ -485,7 +492,7 @@ public class IjkExo2MediaPlayer extends AbstractMediaPlayer implements Player.Ev
break
;
}
}
l
astReportedPlayWhenReady
=
playWhenReady
;
isL
astReportedPlayWhenReady
=
playWhenReady
;
lastReportedPlaybackState
=
playbackState
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录