Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_26386469
GSYVideoPlayer
提交
95f1a33b
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,发现更多精彩内容 >>
提交
95f1a33b
编写于
12月 08, 2016
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.4.5 增加了EXOPlayer的播放切换支持
上级
82b237d8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
72 addition
and
16 deletion
+72
-16
app/src/main/java/com/example/gsyvideoplayer/GSYApplication.java
.../main/java/com/example/gsyvideoplayer/GSYApplication.java
+4
-0
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
...c/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
+60
-14
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
...rc/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
+4
-2
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java
...ain/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java
+4
-0
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/GSYApplication.java
浏览文件 @
95f1a33b
...
...
@@ -2,6 +2,9 @@ package com.example.gsyvideoplayer;
import
android.app.Application
;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
import
com.shuyu.gsyvideoplayer.utils.GSYVideoType
;
//import com.squareup.leakcanary.LeakCanary;
/**
...
...
@@ -20,5 +23,6 @@ public class GSYApplication extends Application {
//}
//LeakCanary.install(this);
//GSYVideoType.enableMediaCodec();
GSYVideoManager
.
instance
().
setVideoType
(
this
,
GSYVideoType
.
IJKEXOPLAYER
);
}
}
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
浏览文件 @
95f1a33b
...
...
@@ -3,6 +3,7 @@ package com.shuyu.gsyvideoplayer;
import
android.content.Context
;
import
android.media.AudioManager
;
import
android.net.Uri
;
import
android.os.Handler
;
import
android.os.HandlerThread
;
import
android.os.Looper
;
...
...
@@ -22,9 +23,12 @@ import com.shuyu.gsyvideoplayer.utils.FileUtils;
import
com.shuyu.gsyvideoplayer.utils.StorageUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.ref.WeakReference
;
import
java.util.Map
;
import
tv.danmaku.ijk.media.exo.IjkExoMediaPlayer
;
import
tv.danmaku.ijk.media.player.AbstractMediaPlayer
;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
;
...
...
@@ -46,7 +50,7 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
public
static
final
int
HANDLER_SETDISPLAY
=
1
;
public
static
final
int
HANDLER_RELEASE
=
2
;
private
Ijk
MediaPlayer
mediaPlayer
;
private
Abstract
MediaPlayer
mediaPlayer
;
private
HandlerThread
mMediaHandlerThread
;
private
MediaHandler
mMediaHandler
;
private
Handler
mainThreadHandler
;
...
...
@@ -60,6 +64,8 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
private
String
playTag
=
""
;
//播放的tag,防止错位置,因为普通的url也可能重复
private
Context
context
;
private
int
currentVideoWidth
=
0
;
//当前播放的视频宽的高
private
int
currentVideoHeight
=
0
;
//当前播放的视屏的高
...
...
@@ -70,6 +76,8 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
private
int
buffterPoint
;
private
int
videoType
=
GSYVideoType
.
IJKPLAYER
;
public
static
synchronized
GSYVideoManager
instance
()
{
if
(
videoManager
==
null
)
{
...
...
@@ -241,16 +249,13 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
currentVideoWidth
=
0
;
currentVideoHeight
=
0
;
mediaPlayer
.
release
();
mediaPlayer
=
new
IjkMediaPlayer
();
if
(
GSYVideoType
.
isMediaCodec
())
{
Debuger
.
printfLog
(
"enable mediaCodec"
);
mediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec"
,
1
);
mediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec-auto-rotate"
,
1
);
mediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec-handle-resolution-change"
,
1
);
if
(
videoType
==
GSYVideoType
.
IJKPLAYER
)
{
initIJKPlayer
(
msg
);
}
else
if
(
videoType
==
GSYVideoType
.
IJKEXOPLAYER
)
{
initEXOPlayer
(
msg
);
}
mediaPlayer
.
setAudioStreamType
(
AudioManager
.
STREAM_MUSIC
);
mediaPlayer
.
setDataSource
(((
GSYModel
)
msg
.
obj
).
getUrl
(),
((
GSYModel
)
msg
.
obj
).
getMapHeadData
());
mediaPlayer
.
setLooping
(((
GSYModel
)
msg
.
obj
).
isLooping
());
mediaPlayer
.
setOnCompletionListener
(
GSYVideoManager
.
this
);
mediaPlayer
.
setOnBufferingUpdateListener
(
GSYVideoManager
.
this
);
mediaPlayer
.
setScreenOnWhilePlaying
(
true
);
...
...
@@ -259,15 +264,42 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
mediaPlayer
.
setOnErrorListener
(
GSYVideoManager
.
this
);
mediaPlayer
.
setOnInfoListener
(
GSYVideoManager
.
this
);
mediaPlayer
.
setOnVideoSizeChangedListener
(
GSYVideoManager
.
this
);
if
(((
GSYModel
)
msg
.
obj
).
getSpeed
()
!=
1
&&
((
GSYModel
)
msg
.
obj
).
getSpeed
()
>
0
)
{
mediaPlayer
.
setSpeed
(((
GSYModel
)
msg
.
obj
).
getSpeed
());
}
mediaPlayer
.
prepareAsync
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
private
void
initIJKPlayer
(
Message
msg
)
{
mediaPlayer
=
new
IjkMediaPlayer
();
mediaPlayer
.
setAudioStreamType
(
AudioManager
.
STREAM_MUSIC
);
try
{
if
(
GSYVideoType
.
isMediaCodec
())
{
Debuger
.
printfLog
(
"enable mediaCodec"
);
((
IjkMediaPlayer
)
mediaPlayer
).
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec"
,
1
);
((
IjkMediaPlayer
)
mediaPlayer
).
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec-auto-rotate"
,
1
);
((
IjkMediaPlayer
)
mediaPlayer
).
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec-handle-resolution-change"
,
1
);
}
((
IjkMediaPlayer
)
mediaPlayer
).
setDataSource
(((
GSYModel
)
msg
.
obj
).
getUrl
(),
((
GSYModel
)
msg
.
obj
).
getMapHeadData
());
mediaPlayer
.
setLooping
(((
GSYModel
)
msg
.
obj
).
isLooping
());
if
(((
GSYModel
)
msg
.
obj
).
getSpeed
()
!=
1
&&
((
GSYModel
)
msg
.
obj
).
getSpeed
()
>
0
)
{
((
IjkMediaPlayer
)
mediaPlayer
).
setSpeed
(((
GSYModel
)
msg
.
obj
).
getSpeed
());
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
private
void
initEXOPlayer
(
Message
msg
)
{
mediaPlayer
=
new
IjkExoMediaPlayer
(
context
);
mediaPlayer
.
setAudioStreamType
(
AudioManager
.
STREAM_MUSIC
);
try
{
mediaPlayer
.
setDataSource
(
context
,
Uri
.
parse
(((
GSYModel
)
msg
.
obj
).
getUrl
()),
((
GSYModel
)
msg
.
obj
).
getMapHeadData
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
void
prepare
(
final
String
url
,
final
Map
<
String
,
String
>
mapHeadData
,
boolean
loop
,
float
speed
)
{
if
(
TextUtils
.
isEmpty
(
url
))
return
;
...
...
@@ -410,7 +442,7 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
}
public
Ijk
MediaPlayer
getMediaPlayer
()
{
public
Abstract
MediaPlayer
getMediaPlayer
()
{
return
mediaPlayer
;
}
...
...
@@ -453,4 +485,18 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
public
void
setPlayPosition
(
int
playPosition
)
{
this
.
playPosition
=
playPosition
;
}
public
int
getVideoType
()
{
return
videoType
;
}
/**
* 设置了视频的播放类型
* GSYVideoType IJKPLAYER = 0 or IJKEXOPLAYER = 1;
*/
public
void
setVideoType
(
Context
context
,
int
videoType
)
{
this
.
context
=
context
.
getApplicationContext
();
this
.
videoType
=
videoType
;
}
}
\ No newline at end of file
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
浏览文件 @
95f1a33b
...
...
@@ -35,6 +35,7 @@ import java.util.Timer;
import
java.util.TimerTask
;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
getTextSpeed
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideNavKey
;
...
...
@@ -1195,8 +1196,9 @@ public abstract class GSYVideoPlayer extends GSYBaseVideoPlayer implements View.
* 再打开已经缓存的本地文件,网络速度才会回0.因为是播放本地文件了
*/
public
long
getNetSpeed
()
{
if
(
GSYVideoManager
.
instance
().
getMediaPlayer
()
!=
null
)
{
return
GSYVideoManager
.
instance
().
getMediaPlayer
().
getTcpSpeed
();
if
(
GSYVideoManager
.
instance
().
getMediaPlayer
()
!=
null
&&
(
GSYVideoManager
.
instance
().
getMediaPlayer
()
instanceof
IjkMediaPlayer
))
{
return
((
IjkMediaPlayer
)
GSYVideoManager
.
instance
().
getMediaPlayer
()).
getTcpSpeed
();
}
else
{
return
-
1
;
}
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/GSYVideoType.java
浏览文件 @
95f1a33b
...
...
@@ -16,6 +16,10 @@ public class GSYVideoType {
public
final
static
int
SCREEN_TYPE_4_3
=
2
;
public
final
static
int
IJKPLAYER
=
0
;
public
final
static
int
IJKEXOPLAYER
=
1
;
//显示比例类型
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录