Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_26386469
GSYVideoPlayer
提交
962cc2de
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,体验更适合开发者的 AI 搜索 >>
提交
962cc2de
编写于
5月 11, 2018
作者:
G
guoshuyu
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
0f6f59b6
83dad060
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
230 addition
and
25 deletion
+230
-25
.travis.yml
.travis.yml
+3
-3
README.md
README.md
+9
-0
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
...rc/main/java/com/example/gsyvideoplayer/DetailPlayer.java
+17
-4
app/src/main/java/com/example/gsyvideoplayer/InputUrlDetailActivity.java
...va/com/example/gsyvideoplayer/InputUrlDetailActivity.java
+13
-0
app/src/main/java/com/example/gsyvideoplayer/MainActivity.java
...rc/main/java/com/example/gsyvideoplayer/MainActivity.java
+22
-0
app/src/main/java/com/example/gsyvideoplayer/RecyclerView2Activity.java
...ava/com/example/gsyvideoplayer/RecyclerView2Activity.java
+1
-0
app/src/main/java/com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
...com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
+6
-4
app/src/main/java/com/example/gsyvideoplayer/utils/floatUtil/FloatToast.java
...om/example/gsyvideoplayer/utils/floatUtil/FloatToast.java
+1
-0
app/src/main/res/layout/activity_input_url_detail.xml
app/src/main/res/layout/activity_input_url_detail.xml
+10
-2
app/src/main/res/values/styles.xml
app/src/main/res/values/styles.xml
+1
-1
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYBaseActivityDetail.java
.../java/com/shuyu/gsyvideoplayer/GSYBaseActivityDetail.java
+8
-1
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/builder/GSYVideoOptionBuilder.java
...m/shuyu/gsyvideoplayer/builder/GSYVideoOptionBuilder.java
+14
-0
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
...java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
+13
-5
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
...m/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
+98
-5
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
...ava/com/shuyu/gsyvideoplayer/video/base/GSYVideoView.java
+14
-0
未找到文件。
.travis.yml
浏览文件 @
962cc2de
...
...
@@ -4,8 +4,8 @@ android:
components
:
-
platform-tools
-
tools
-
build-tools-2
6
.0.2
-
android-2
6
-
build-tools-2
7
.0.2
-
android-2
7
-
extra-android-support
-
extra-android-m2repository
...
...
@@ -14,4 +14,4 @@ before_install:
script
:
-
cd gsyVideoPlayer
-
../gradlew assembleRelease
\ No newline at end of file
-
../gradlew assembleRelease
README.md
浏览文件 @
962cc2de
...
...
@@ -133,6 +133,15 @@ compile 'com.shuyu:gsyVideoPlayer-ex_so:4.1.2'
### 4.1.3(2018-xx-xx 未发布)
*
优化单双击
*
update support and build sdk to 27
*
增加是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效。
```
/**
* 是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
* @param autoFullWithSize 默认false
*/
public void setAutoFullWithSize(boolean autoFullWithSize)
```
### 4.1.2(2018-04-14)
*
修复已知问题。
...
...
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
浏览文件 @
962cc2de
...
...
@@ -2,6 +2,7 @@ package com.example.gsyvideoplayer;
import
android.content.res.Configuration
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.support.v4.widget.NestedScrollView
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
...
...
@@ -12,6 +13,8 @@ import com.example.gsyvideoplayer.video.LandLayoutVideo;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
import
com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
;
import
com.shuyu.gsyvideoplayer.listener.GSYVideoProgressListener
;
import
com.shuyu.gsyvideoplayer.model.VideoOptionModel
;
import
com.shuyu.gsyvideoplayer.utils.FileUtils
;
import
com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer
;
import
com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
;
...
...
@@ -20,8 +23,12 @@ import com.shuyu.gsyvideoplayer.utils.Debuger;
import
com.shuyu.gsyvideoplayer.utils.OrientationUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
;
public
class
DetailPlayer
extends
AppCompatActivity
{
...
...
@@ -55,7 +62,13 @@ public class DetailPlayer extends AppCompatActivity {
//断网自动重新链接,url前接上ijkhttphook:
//String url = "ijkhttphook:https://res.exexm.com/cw_145225549855002";
String
url
=
"http://7xjmzj.com1.z0.glb.clouddn.com/20171026175005_JObCxCE2.mp4"
;
//String url = "http://7xjmzj.com1.z0.glb.clouddn.com/20171026175005_JObCxCE2.mp4";
//String url = "http://qiniu.carmmi.com/image/132451525666042.mp4";
String
url
=
"http://7xse1z.com1.z0.glb.clouddn.com/1491813192"
;
//String url = "file://"+ Environment.getExternalStorageDirectory().getPath() + "Download/132451525666042.mp4";
//String url = "http://ipsimg-huabei2.speiyou.cn/010/video/other/20180427/40288b156241ec6301624243bdf7021e/40288b156290270d0162a3e7eb2e0726/1524814477/movie.mp4";
//String url = "http://ipsimg-huabei2.speiyou.cn/010/video/other/20180424/40288b156290270d0162a3db8cdd033e/40288b156290270d0162a3e8207f074f/e787a64c-f2d0-48fe-896d-246af05f111a.mp4";
//String url = "http://video.7k.cn/app_video/20171202/6c8cf3ea/v.m3u8.mp4";
//String url = "http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8";
...
...
@@ -87,10 +100,10 @@ public class DetailPlayer extends AppCompatActivity {
//detailPlayer.setShowPauseCover(false);
//如果视频帧数太高导致卡画面不同步
//VideoOptionModel videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop",
5
);
//VideoOptionModel videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop",
30
);
//如果视频seek之后从头播放
//VideoOptionModel videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "enable-accurate-seek", 1);
//
L
ist<VideoOptionModel> list = new ArrayList<>();
//
l
ist<VideoOptionModel> list = new ArrayList<>();
//list.add(videoOptionModel);
//GSYVideoManager.instance().setOptionModelList(list);
...
...
@@ -115,9 +128,9 @@ public class DetailPlayer extends AppCompatActivity {
.
setIsTouchWiget
(
true
)
.
setRotateViewAuto
(
false
)
.
setLockLand
(
false
)
.
setAutoFullWithSize
(
true
)
.
setShowFullAnimation
(
false
)
.
setNeedLockFull
(
true
)
.
setSeekRatio
(
1
)
.
setUrl
(
url
)
.
setCacheWithPlay
(
false
)
.
setVideoTitle
(
"测试视频"
)
...
...
app/src/main/java/com/example/gsyvideoplayer/InputUrlDetailActivity.java
浏览文件 @
962cc2de
...
...
@@ -11,6 +11,7 @@ import android.widget.Button;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
com.bumptech.glide.Glide
;
import
com.example.gsyvideoplayer.video.LandLayoutVideo
;
import
com.example.gsyvideoplayer.view.CustomInputDialog
;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
...
...
@@ -127,6 +128,18 @@ public class InputUrlDetailActivity extends AppCompatActivity {
}
});
detailPlayer
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
ImageView
testImage
=
findViewById
(
R
.
id
.
test_image_view
);
Glide
.
with
(
InputUrlDetailActivity
.
this
.
getApplicationContext
())
.
load
(
"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1525708180755&di=078af5aedf4b44268425be46bf25e407&imgtype=0&src=http%3A%2F%2Fc.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2F203fb80e7bec54e78494e3a3bb389b504fc26a17.jpg"
)
.
into
(
testImage
);
}
},
5000
);
}
@Override
...
...
app/src/main/java/com/example/gsyvideoplayer/MainActivity.java
浏览文件 @
962cc2de
package
com.example.gsyvideoplayer
;
import
android.Manifest
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.Toast
;
import
com.example.gsyvideoplayer.utils.JumpUtils
;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
...
...
@@ -12,6 +16,8 @@ import com.shuyu.gsyvideoplayer.utils.Debuger;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.OnClick
;
import
permissions.dispatcher.PermissionUtils
;
import
permissions.dispatcher.RuntimePermissions
;
public
class
MainActivity
extends
AppCompatActivity
{
...
...
@@ -21,12 +27,28 @@ public class MainActivity extends AppCompatActivity {
@BindView
(
R
.
id
.
open_btn_empty
)
Button
openBtn2
;
final
String
[]
permissions
=
{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
};
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
Debuger
.
enable
();
ButterKnife
.
bind
(
this
);
boolean
hadPermission
=
PermissionUtils
.
hasSelfPermissions
(
this
,
permissions
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
&&
!
hadPermission
)
{
String
[]
permissions
=
{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
};
requestPermissions
(
permissions
,
1110
);
}
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
boolean
sdPermissionResult
=
PermissionUtils
.
verifyPermissions
(
grantResults
);
if
(!
sdPermissionResult
)
{
Toast
.
makeText
(
this
,
"没获取到sd卡权限,无法播放本地视频哦"
,
Toast
.
LENGTH_LONG
).
show
();
}
}
@OnClick
({
R
.
id
.
open_btn
,
R
.
id
.
list_btn
,
R
.
id
.
list_btn_2
,
R
.
id
.
list_detail
,
R
.
id
.
clear_cache
,
R
.
id
.
recycler
,
R
.
id
.
recycler_2
,
R
.
id
.
list_detail_list
,
R
.
id
.
web_detail
,
R
.
id
.
danmaku_video
,
R
.
id
.
fragment_video
,
...
...
app/src/main/java/com/example/gsyvideoplayer/RecyclerView2Activity.java
浏览文件 @
962cc2de
...
...
@@ -137,6 +137,7 @@ public class RecyclerView2Activity extends AppCompatActivity {
.
setHideStatusBar
(
true
)
.
setNeedLockFull
(
true
)
.
setCacheWithPlay
(
true
)
.
setAutoFullWithSize
(
true
)
.
setShowFullAnimation
(
true
)
.
setLockLand
(
true
).
setVideoAllCallBack
(
new
GSYSampleCallBack
()
{
@Override
...
...
app/src/main/java/com/example/gsyvideoplayer/adapter/ListNormalAdapter.java
浏览文件 @
962cc2de
...
...
@@ -79,8 +79,9 @@ public class ListNormalAdapter extends BaseAdapter {
//final String url = "https://res.exexm.com/cw_145225549855002";
final
String
url
=
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
;
//final String url = "http://7xse1z.com1.z0.glb.clouddn.com/1491813192";
final
String
urlH
=
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
;
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";
...
...
@@ -95,7 +96,7 @@ public class ListNormalAdapter extends BaseAdapter {
//默认缓存路径
//使用lazy的set可以避免滑动卡的情况存在
holder
.
gsyVideoPlayer
.
setUpLazy
(
url
,
tru
e
,
null
,
null
,
"这是title"
);
holder
.
gsyVideoPlayer
.
setUpLazy
(
url
,
fals
e
,
null
,
null
,
"这是title"
);
//holder.gsyVideoPlayer.setNeedShowWifiTip(false);
...
...
@@ -148,6 +149,7 @@ public class ListNormalAdapter extends BaseAdapter {
holder
.
gsyVideoPlayer
.
setRotateViewAuto
(!
getListNeedAutoLand
());
holder
.
gsyVideoPlayer
.
setLockLand
(!
getListNeedAutoLand
());
holder
.
gsyVideoPlayer
.
setPlayTag
(
TAG
);
holder
.
gsyVideoPlayer
.
setAutoFullWithSize
(
true
);
holder
.
gsyVideoPlayer
.
setReleaseWhenLossAudio
(
false
);
holder
.
gsyVideoPlayer
.
setShowFullAnimation
(!
getListNeedAutoLand
());
holder
.
gsyVideoPlayer
.
setIsTouchWiget
(
false
);
...
...
@@ -247,7 +249,7 @@ public class ListNormalAdapter extends BaseAdapter {
* @return 返回true为支持列表重力全屏
*/
public
boolean
getListNeedAutoLand
()
{
return
tru
e
;
return
fals
e
;
}
private
void
initOrientationUtils
(
StandardGSYVideoPlayer
standardGSYVideoPlayer
,
boolean
full
)
{
...
...
app/src/main/java/com/example/gsyvideoplayer/utils/floatUtil/FloatToast.java
浏览文件 @
962cc2de
...
...
@@ -68,6 +68,7 @@ class FloatToast extends FloatView {
private
void
initTN
()
{
try
{
//todo android P test
Field
tnField
=
toast
.
getClass
().
getDeclaredField
(
"mTN"
);
tnField
.
setAccessible
(
true
);
mTN
=
tnField
.
get
(
toast
);
...
...
app/src/main/res/layout/activity_input_url_detail.xml
浏览文件 @
962cc2de
...
...
@@ -35,6 +35,15 @@
android:layout_height=
"@dimen/post_media_height"
/>
<ImageView
android:id=
"@+id/test_image_view"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
android:layout_alignParentBottom=
"true"
android:layout_alignParentRight=
"true"
android:layout_margin=
"10dp"
android:src=
"@mipmap/ic_launcher"
/>
<Button
android:id=
"@+id/inputUrl"
android:layout_width=
"wrap_content"
...
...
@@ -42,7 +51,6 @@
android:layout_alignParentBottom=
"true"
android:layout_alignParentRight=
"true"
android:layout_margin=
"10dp"
android:text=
"切换url"
/>
android:text=
"切换url"
/>
</RelativeLayout>
app/src/main/res/values/styles.xml
浏览文件 @
962cc2de
...
...
@@ -12,7 +12,7 @@
<style
name=
"Theme.AppCompat.Translucent"
parent=
"AppTheme"
>
<item
name=
"android:windowBackground"
>
@android:color/transparent
</item>
<item
name=
"android:colorBackgroundCacheHint"
>
@null
</item>
<item
name=
"android:window
IsTranslucent
"
>
true
</item>
<item
name=
"android:window
DisablePreview
"
>
true
</item>
<item
name=
"windowActionBar"
>
false
</item>
<item
name=
"windowNoTitle"
>
true
</item>
</style>
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/GSYBaseActivityDetail.java
浏览文件 @
962cc2de
...
...
@@ -124,7 +124,7 @@ public abstract class GSYBaseActivityDetail<T extends GSYBaseVideoPlayer> extend
throw
new
NullPointerException
(
"initVideo() or initVideoBuilderMode() first"
);
}
//开始播放了才能旋转和全屏
orientationUtils
.
setEnable
(
getDetailOrientationRotateAuto
());
orientationUtils
.
setEnable
(
getDetailOrientationRotateAuto
()
&&
!
isAutoFullWithSize
()
);
isPlay
=
true
;
}
...
...
@@ -257,4 +257,11 @@ public abstract class GSYBaseActivityDetail<T extends GSYBaseVideoPlayer> extend
* 是否启动旋转横屏,true表示启动
*/
public
abstract
boolean
getDetailOrientationRotateAuto
();
/**
* 是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
*/
public
boolean
isAutoFullWithSize
()
{
return
false
;
}
}
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/builder/GSYVideoOptionBuilder.java
浏览文件 @
962cc2de
...
...
@@ -59,6 +59,9 @@ public class GSYVideoOptionBuilder {
//是否使用全屏动画效果
protected
boolean
mShowFullAnimation
=
true
;
//是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
protected
boolean
mAutoFullWithSize
=
false
;
//是否需要显示流量提示
protected
boolean
mNeedShowWifiTip
=
true
;
...
...
@@ -156,6 +159,16 @@ public class GSYVideoOptionBuilder {
protected
GSYVideoProgressListener
mGSYVideoProgressListener
;
/**
* 是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
*
* @param autoFullWithSize 默认false
*/
public
GSYVideoOptionBuilder
setAutoFullWithSize
(
boolean
autoFullWithSize
)
{
this
.
mAutoFullWithSize
=
autoFullWithSize
;
return
this
;
}
/**
* 全屏动画
*
...
...
@@ -585,6 +598,7 @@ public class GSYVideoOptionBuilder {
if
(
mGSYVideoProgressListener
!=
null
)
{
gsyVideoPlayer
.
setGSYVideoProgressListener
(
mGSYVideoProgressListener
);
}
gsyVideoPlayer
.
setAutoFullWithSize
(
mAutoFullWithSize
);
gsyVideoPlayer
.
setRotateViewAuto
(
mRotateViewAuto
);
gsyVideoPlayer
.
setLockLand
(
mLockLand
);
gsyVideoPlayer
.
setSpeed
(
mSpeed
,
mSounchTouch
);
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
浏览文件 @
962cc2de
...
...
@@ -21,9 +21,12 @@ public class OrientationUtils {
private
int
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
;
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
mRotateWithSystem
=
true
;
//是否跟随系统
//是否跟随系统
private
boolean
mRotateWithSystem
=
true
;
/**
* @param activity
...
...
@@ -41,9 +44,10 @@ public class OrientationUtils {
public
void
onOrientationChanged
(
int
rotation
)
{
boolean
autoRotateOn
=
(
Settings
.
System
.
getInt
(
activity
.
getContentResolver
(),
Settings
.
System
.
ACCELEROMETER_ROTATION
,
0
)
==
1
);
if
(!
autoRotateOn
&&
mRotateWithSystem
)
{
//if (mIsLand == 0) {
return
;
//}
return
;
}
if
(
gsyVideoPlayer
!=
null
&&
gsyVideoPlayer
.
isVerticalFullByVideoSize
())
{
return
;
}
// 设置竖屏
if
(((
rotation
>=
0
)
&&
(
rotation
<=
30
))
||
(
rotation
>=
330
))
{
...
...
@@ -122,6 +126,9 @@ public class OrientationUtils {
* 点击切换的逻辑,比如竖屏的时候点击了就是切换到横屏不会受屏幕的影响
*/
public
void
resolveByClick
()
{
if
(
mIsLand
==
0
&&
gsyVideoPlayer
!=
null
&&
gsyVideoPlayer
.
isVerticalFullByVideoSize
())
{
return
;
}
mClick
=
true
;
if
(
mIsLand
==
0
)
{
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
;
...
...
@@ -231,6 +238,7 @@ public class OrientationUtils {
/**
* 是否更新系统旋转,false的话,系统禁止旋转也会跟着旋转
*
* @param rotateWithSystem 默认true
*/
public
void
setRotateWithSystem
(
boolean
rotateWithSystem
)
{
...
...
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/video/base/GSYBaseVideoPlayer.java
浏览文件 @
962cc2de
...
...
@@ -22,6 +22,8 @@ import com.transitionseverywhere.TransitionManager;
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
.
getStatusBarHeight
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideNavKey
;
...
...
@@ -63,6 +65,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
//当前全屏是否锁定全屏
protected
boolean
mLockLand
=
false
;
//是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
protected
boolean
mAutoFullWithSize
=
false
;
//小窗口关闭按键
protected
View
mSmallClose
;
...
...
@@ -139,13 +144,28 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
super
.
lockTouchLogic
();
if
(
mLockCurScreen
)
{
if
(
mOrientationUtils
!=
null
)
mOrientationUtils
.
setEnable
(
mRotateViewAuto
);
mOrientationUtils
.
setEnable
(
isRotateViewAuto
()
);
}
else
{
if
(
mOrientationUtils
!=
null
)
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
()
{
return
(
ViewGroup
)
(
CommonUtil
.
scanForActivity
(
getContext
())).
findViewById
(
Window
.
ID_ANDROID_CONTENT
);
...
...
@@ -216,6 +236,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
to
.
mVideoAllCallBack
=
from
.
mVideoAllCallBack
;
to
.
mActionBar
=
from
.
mActionBar
;
to
.
mStatusBar
=
from
.
mStatusBar
;
to
.
mAutoFullWithSize
=
from
.
mAutoFullWithSize
;
if
(
from
.
mSetUpLazy
)
{
to
.
setUpLazy
(
from
.
mOriginUrl
,
from
.
mCache
,
from
.
mCachePath
,
from
.
mMapHeadData
,
from
.
mTitle
);
to
.
mUrl
=
from
.
mUrl
;
...
...
@@ -278,15 +299,20 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
gsyVideoPlayer
.
setLayoutParams
(
lp
);
gsyVideoPlayer
.
setIfCurrentIsFullscreen
(
true
);
mOrientationUtils
=
new
OrientationUtils
((
Activity
)
context
,
gsyVideoPlayer
);
mOrientationUtils
.
setEnable
(
mRotateViewAuto
);
mOrientationUtils
.
setEnable
(
isRotateViewAuto
()
);
mOrientationUtils
.
setRotateWithSystem
(
mRotateWithSystem
);
gsyVideoPlayer
.
mOrientationUtils
=
mOrientationUtils
;
final
boolean
isVertical
=
isVerticalFullByVideoSize
();
final
boolean
isLockLand
=
isLockLandByAutoFullSize
();
if
(
isShowFullAnimation
())
{
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
mLockLand
&&
mOrientationUtils
.
getIsLand
()
!=
1
)
{
Debuger
.
printfLog
(
"GSYVideoBase resolveFullVideoShow isVerticalFullByVideoSize "
+
isVertical
);
//autoFull模式下,非横屏视频视频不横屏,并且不自动旋转
if
(!
isVertical
&&
isLockLand
&&
mOrientationUtils
.
getIsLand
()
!=
1
)
{
mOrientationUtils
.
resolveByClick
();
}
gsyVideoPlayer
.
setVisibility
(
VISIBLE
);
...
...
@@ -294,7 +320,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
}
},
300
);
}
else
{
if
(
m
LockLand
)
{
if
(
!
isVertical
&&
is
LockLand
)
{
mOrientationUtils
.
resolveByClick
();
}
gsyVideoPlayer
.
setVisibility
(
VISIBLE
);
...
...
@@ -441,12 +467,64 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
postDelayed
(
mCheckoutTask
,
500
);
}
/**
* 是否竖屏模式的竖屏
*/
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
=
isVerticalFullByVideoSize
();
Debuger
.
printfLog
(
"GSYVideoBase onPrepared isVerticalFullByVideoSize "
+
isV
);
if
(
isV
)
{
if
(
mOrientationUtils
!=
null
)
mOrientationUtils
.
backToProtVideo
();
}
}
}
protected
abstract
int
getFullId
();
protected
abstract
int
getSmallId
();
/************************* 开放接口 *************************/
/**
* 是否根据视频尺寸,自动选择竖屏全屏或者横屏全屏,注意,这时候默认旋转无效
*/
public
boolean
isVerticalFullByVideoSize
()
{
return
isVerticalVideo
()
&&
isAutoFullWithSize
();
}
/**
* 旋转处理
*
...
...
@@ -477,7 +555,7 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
}
}
else
{
//新版本isIfCurrentIsFullscreen的标志位内部提前设置了,所以不会和手动点击冲突
if
(
isIfCurrentIsFullscreen
())
{
if
(
isIfCurrentIsFullscreen
()
&&
isVerticalFullByVideoSize
()
)
{
backFromFull
(
activity
);
}
if
(
orientationUtils
!=
null
)
{
...
...
@@ -722,6 +800,9 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
}
public
boolean
isRotateViewAuto
()
{
if
(
mAutoFullWithSize
)
{
return
false
;
}
return
mRotateViewAuto
;
}
...
...
@@ -836,4 +917,16 @@ public abstract class GSYBaseVideoPlayer extends GSYVideoControlView {
public
void
setSaveBeforeFullSystemUiVisibility
(
int
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
浏览文件 @
962cc2de
...
...
@@ -1133,4 +1133,18 @@ public abstract class GSYVideoView extends GSYTextureRenderView implements GSYMe
public
void
setReleaseWhenLossAudio
(
boolean
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录