Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ac13
GSYVideoPlayer
提交
bfc96417
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 搜索 >>
提交
bfc96417
编写于
5月 09, 2018
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add AutoFullWithSize support
上级
0cf9e057
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
123 addition
and
11 deletion
+123
-11
app/src/main/java/com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
...com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
+5
-4
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
...java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
+7
-3
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
...m/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
+97
-4
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
...ava/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
+14
-0
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
浏览文件 @
bfc96417
...
@@ -79,8 +79,9 @@ public class ListNormalAdapter extends BaseAdapter {
...
@@ -79,8 +79,9 @@ public class ListNormalAdapter extends BaseAdapter {
//final String url = "https://res.exexm.com/cw_145225549855002";
//final String url = "https://res.exexm.com/cw_145225549855002";
final
String
url
=
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
;
final
String
urlH
=
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
;
//final String url = "http://7xse1z.com1.z0.glb.clouddn.com/1491813192";
final
String
urlV
=
"http://7xse1z.com1.z0.glb.clouddn.com/1491813192"
;
final
String
url
=
(
position
%
2
==
0
)
?
urlH
:
urlV
;
//final String url = "http://111.198.24.133:83/yyy_login_server/pic/YB059284/97778276040859/1.mp4";
//final String url = "http://111.198.24.133:83/yyy_login_server/pic/YB059284/97778276040859/1.mp4";
...
@@ -95,7 +96,7 @@ public class ListNormalAdapter extends BaseAdapter {
...
@@ -95,7 +96,7 @@ public class ListNormalAdapter extends BaseAdapter {
//默认缓存路径
//默认缓存路径
//使用lazy的set可以避免滑动卡的情况存在
//使用lazy的set可以避免滑动卡的情况存在
holder
.
gsyVideoPlayer
.
setUpLazy
(
url
,
tru
e
,
null
,
null
,
"这是title"
);
holder
.
gsyVideoPlayer
.
setUpLazy
(
url
,
fals
e
,
null
,
null
,
"这是title"
);
//holder.gsyVideoPlayer.setNeedShowWifiTip(false);
//holder.gsyVideoPlayer.setNeedShowWifiTip(false);
...
@@ -247,7 +248,7 @@ public class ListNormalAdapter extends BaseAdapter {
...
@@ -247,7 +248,7 @@ public class ListNormalAdapter extends BaseAdapter {
* @return 返回true为支持列表重力全屏
* @return 返回true为支持列表重力全屏
*/
*/
public
boolean
getListNeedAutoLand
()
{
public
boolean
getListNeedAutoLand
()
{
return
tru
e
;
return
fals
e
;
}
}
private
void
initOrientationUtils
(
StandardGSYVideoPlayer
standardGSYVideoPlayer
,
boolean
full
)
{
private
void
initOrientationUtils
(
StandardGSYVideoPlayer
standardGSYVideoPlayer
,
boolean
full
)
{
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
浏览文件 @
bfc96417
...
@@ -21,9 +21,12 @@ public class OrientationUtils {
...
@@ -21,9 +21,12 @@ public class OrientationUtils {
private
int
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
;
private
int
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
;
private
int
mIsLand
;
private
int
mIsLand
;
private
boolean
mClick
,
mClickLand
,
mClickPort
;
private
boolean
mClick
=
false
;
private
boolean
mClickLand
=
false
;
private
boolean
mClickPort
;
private
boolean
mEnable
=
true
;
private
boolean
mEnable
=
true
;
private
boolean
mRotateWithSystem
=
true
;
//是否跟随系统
//是否跟随系统
private
boolean
mRotateWithSystem
=
true
;
/**
/**
* @param activity
* @param activity
...
@@ -42,7 +45,7 @@ public class OrientationUtils {
...
@@ -42,7 +45,7 @@ public class OrientationUtils {
boolean
autoRotateOn
=
(
Settings
.
System
.
getInt
(
activity
.
getContentResolver
(),
Settings
.
System
.
ACCELEROMETER_ROTATION
,
0
)
==
1
);
boolean
autoRotateOn
=
(
Settings
.
System
.
getInt
(
activity
.
getContentResolver
(),
Settings
.
System
.
ACCELEROMETER_ROTATION
,
0
)
==
1
);
if
(!
autoRotateOn
&&
mRotateWithSystem
)
{
if
(!
autoRotateOn
&&
mRotateWithSystem
)
{
//if (mIsLand == 0) {
//if (mIsLand == 0) {
return
;
return
;
//}
//}
}
}
// 设置竖屏
// 设置竖屏
...
@@ -231,6 +234,7 @@ public class OrientationUtils {
...
@@ -231,6 +234,7 @@ public class OrientationUtils {
/**
/**
* 是否更新系统旋转,false的话,系统禁止旋转也会跟着旋转
* 是否更新系统旋转,false的话,系统禁止旋转也会跟着旋转
*
* @param rotateWithSystem 默认true
* @param rotateWithSystem 默认true
*/
*/
public
void
setRotateWithSystem
(
boolean
rotateWithSystem
)
{
public
void
setRotateWithSystem
(
boolean
rotateWithSystem
)
{
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
浏览文件 @
bfc96417
...
@@ -22,6 +22,8 @@ import com.transitionseverywhere.TransitionManager;
...
@@ -22,6 +22,8 @@ import com.transitionseverywhere.TransitionManager;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Constructor
;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
getActionBarHeight
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
getActionBarHeight
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
getStatusBarHeight
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
getStatusBarHeight
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideNavKey
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideNavKey
;
...
@@ -63,6 +65,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
...
@@ -63,6 +65,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
//当前全屏是否锁定全屏
//当前全屏是否锁定全屏
protected
boolean
mLockLand
=
false
;
protected
boolean
mLockLand
=
false
;
//是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
protected
boolean
mAutoFullWithSize
=
false
;
//小窗口关闭按键
//小窗口关闭按键
protected
View
mSmallClose
;
protected
View
mSmallClose
;
...
@@ -139,13 +144,28 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
...
@@ -139,13 +144,28 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
super
.
lockTouchLogic
();
super
.
lockTouchLogic
();
if
(
mLockCurScreen
)
{
if
(
mLockCurScreen
)
{
if
(
mOrientationUtils
!=
null
)
if
(
mOrientationUtils
!=
null
)
mOrientationUtils
.
setEnable
(
mRotateViewAuto
);
mOrientationUtils
.
setEnable
(
isRotateViewAuto
()
);
}
else
{
}
else
{
if
(
mOrientationUtils
!=
null
)
if
(
mOrientationUtils
!=
null
)
mOrientationUtils
.
setEnable
(
false
);
mOrientationUtils
.
setEnable
(
false
);
}
}
}
}
@Override
public
void
onPrepared
()
{
super
.
onPrepared
();
//确保开启竖屏检测的时候正常全屏
checkAutoFullSizeWhenFull
();
}
@Override
public
void
onInfo
(
int
what
,
int
extra
)
{
super
.
onInfo
(
what
,
extra
);
if
(
what
==
IMediaPlayer
.
MEDIA_INFO_VIDEO_ROTATION_CHANGED
)
{
checkAutoFullSizeWhenFull
();
}
}
private
ViewGroup
getViewGroup
()
{
private
ViewGroup
getViewGroup
()
{
return
(
ViewGroup
)
(
CommonUtil
.
scanForActivity
(
getContext
())).
findViewById
(
Window
.
ID_ANDROID_CONTENT
);
return
(
ViewGroup
)
(
CommonUtil
.
scanForActivity
(
getContext
())).
findViewById
(
Window
.
ID_ANDROID_CONTENT
);
...
@@ -216,6 +236,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
...
@@ -216,6 +236,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
to
.
mVideoAllCallBack
=
from
.
mVideoAllCallBack
;
to
.
mVideoAllCallBack
=
from
.
mVideoAllCallBack
;
to
.
mActionBar
=
from
.
mActionBar
;
to
.
mActionBar
=
from
.
mActionBar
;
to
.
mStatusBar
=
from
.
mStatusBar
;
to
.
mStatusBar
=
from
.
mStatusBar
;
to
.
mAutoFullWithSize
=
from
.
mAutoFullWithSize
;
if
(
from
.
mSetUpLazy
)
{
if
(
from
.
mSetUpLazy
)
{
to
.
setUpLazy
(
from
.
mOriginUrl
,
from
.
mCache
,
from
.
mCachePath
,
from
.
mMapHeadData
,
from
.
mTitle
);
to
.
setUpLazy
(
from
.
mOriginUrl
,
from
.
mCache
,
from
.
mCachePath
,
from
.
mMapHeadData
,
from
.
mTitle
);
to
.
mUrl
=
from
.
mUrl
;
to
.
mUrl
=
from
.
mUrl
;
...
@@ -278,15 +299,20 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
...
@@ -278,15 +299,20 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
gsyVideoPlayer
.
setLayoutParams
(
lp
);
gsyVideoPlayer
.
setLayoutParams
(
lp
);
gsyVideoPlayer
.
setIfCurrentIsFullscreen
(
true
);
gsyVideoPlayer
.
setIfCurrentIsFullscreen
(
true
);
mOrientationUtils
=
new
OrientationUtils
((
Activity
)
context
,
gsyVideoPlayer
);
mOrientationUtils
=
new
OrientationUtils
((
Activity
)
context
,
gsyVideoPlayer
);
mOrientationUtils
.
setEnable
(
mRotateViewAuto
);
mOrientationUtils
.
setEnable
(
isRotateViewAuto
()
);
mOrientationUtils
.
setRotateWithSystem
(
mRotateWithSystem
);
mOrientationUtils
.
setRotateWithSystem
(
mRotateWithSystem
);
gsyVideoPlayer
.
mOrientationUtils
=
mOrientationUtils
;
gsyVideoPlayer
.
mOrientationUtils
=
mOrientationUtils
;
final
boolean
isVertical
=
isVerticalVideoFull
();
final
boolean
isLockLand
=
isLockLandByAutoFullSize
();
if
(
isShowFullAnimation
())
{
if
(
isShowFullAnimation
())
{
postDelayed
(
new
Runnable
()
{
postDelayed
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(
mLockLand
&&
mOrientationUtils
.
getIsLand
()
!=
1
)
{
Debuger
.
printfLog
(
"GSYVideoBase resolveFullVideoShow isVerticalVideoFull "
+
isVertical
);
//autoFull模式下,非横屏视频视频不横屏,并且不自动旋转
if
(!
isVertical
&&
isLockLand
&&
mOrientationUtils
.
getIsLand
()
!=
1
)
{
mOrientationUtils
.
resolveByClick
();
mOrientationUtils
.
resolveByClick
();
}
}
gsyVideoPlayer
.
setVisibility
(
VISIBLE
);
gsyVideoPlayer
.
setVisibility
(
VISIBLE
);
...
@@ -294,7 +320,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
...
@@ -294,7 +320,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
}
}
},
300
);
},
300
);
}
else
{
}
else
{
if
(
m
LockLand
)
{
if
(
!
isVertical
&&
is
LockLand
)
{
mOrientationUtils
.
resolveByClick
();
mOrientationUtils
.
resolveByClick
();
}
}
gsyVideoPlayer
.
setVisibility
(
VISIBLE
);
gsyVideoPlayer
.
setVisibility
(
VISIBLE
);
...
@@ -441,6 +467,58 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
...
@@ -441,6 +467,58 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
postDelayed
(
mCheckoutTask
,
500
);
postDelayed
(
mCheckoutTask
,
500
);
}
}
/**
* 是否需要使用竖屏全屏
*/
protected
boolean
isVerticalVideoFull
()
{
return
isVerticalVideo
()
&&
isAutoFullWithSize
();
}
/**
* 是否竖屏模式的竖屏
*/
protected
boolean
isVerticalVideo
()
{
boolean
isVertical
=
false
;
int
videoHeight
=
getCurrentVideoHeight
();
int
videoWidth
=
getCurrentVideoWidth
();
Debuger
.
printfLog
(
"GSYVideoBase isVerticalVideo videoHeight "
+
videoHeight
+
" videoWidth "
+
videoWidth
);
Debuger
.
printfLog
(
"GSYVideoBase isVerticalVideo mRotate "
+
mRotate
);
if
(
videoHeight
>
0
&&
videoWidth
>
0
)
{
if
(
mRotate
==
90
||
mRotate
==
270
)
{
isVertical
=
videoWidth
>
videoHeight
;
}
else
{
isVertical
=
videoHeight
>
videoWidth
;
}
}
return
isVertical
;
}
/**
* 是否根据autoFullSize调整lockLand
*/
protected
boolean
isLockLandByAutoFullSize
()
{
boolean
isLockLand
=
mLockLand
;
if
(
isAutoFullWithSize
())
{
isLockLand
=
true
;
}
return
isLockLand
;
}
/**
* 确保开启竖屏检测的时候正常全屏
*/
protected
void
checkAutoFullSizeWhenFull
()
{
if
(
mIfCurrentIsFullscreen
)
{
//确保开启竖屏检测的时候正常全屏
boolean
isV
=
isVerticalVideoFull
();
Debuger
.
printfLog
(
"GSYVideoBase onPrepared isVerticalVideoFull "
+
isV
);
if
(
isV
)
{
if
(
mOrientationUtils
!=
null
)
mOrientationUtils
.
backToProtVideo
();
}
}
}
protected
abstract
int
getFullId
();
protected
abstract
int
getFullId
();
protected
abstract
int
getSmallId
();
protected
abstract
int
getSmallId
();
...
@@ -722,6 +800,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
...
@@ -722,6 +800,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
}
}
public
boolean
isRotateViewAuto
()
{
public
boolean
isRotateViewAuto
()
{
if
(
mAutoFullWithSize
)
{
return
false
;
}
return
mRotateViewAuto
;
return
mRotateViewAuto
;
}
}
...
@@ -836,4 +917,16 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
...
@@ -836,4 +917,16 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
public
void
setSaveBeforeFullSystemUiVisibility
(
int
systemUiVisibility
)
{
public
void
setSaveBeforeFullSystemUiVisibility
(
int
systemUiVisibility
)
{
this
.
mSystemUiVisibility
=
systemUiVisibility
;
this
.
mSystemUiVisibility
=
systemUiVisibility
;
}
}
public
boolean
isAutoFullWithSize
()
{
return
mAutoFullWithSize
;
}
/**
* 是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
* @param autoFullWithSize 默认false
*/
public
void
setAutoFullWithSize
(
boolean
autoFullWithSize
)
{
this
.
mAutoFullWithSize
=
autoFullWithSize
;
}
}
}
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
浏览文件 @
bfc96417
...
@@ -1133,4 +1133,18 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
...
@@ -1133,4 +1133,18 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
public
void
setReleaseWhenLossAudio
(
boolean
releaseWhenLossAudio
)
{
public
void
setReleaseWhenLossAudio
(
boolean
releaseWhenLossAudio
)
{
this
.
mReleaseWhenLossAudio
=
releaseWhenLossAudio
;
this
.
mReleaseWhenLossAudio
=
releaseWhenLossAudio
;
}
}
public
Map
<
String
,
String
>
getMapHeadData
()
{
return
mMapHeadData
;
}
/**
* 单独设置mapHeader
* @param headData
*/
public
void
setMapHeadData
(
Map
<
String
,
String
>
headData
)
{
if
(
headData
!=
null
)
{
this
.
mMapHeadData
=
headData
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录