Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沁852
GSYVideoPlayer
提交
8fc79be1
G
GSYVideoPlayer
项目概览
沁852
/
GSYVideoPlayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
9
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 搜索 >>
提交
8fc79be1
编写于
11月 17, 2016
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.1.3
上级
4c06ec8c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
381 addition
and
110 deletion
+381
-110
0034.gif
0034.gif
+0
-0
README.md
README.md
+8
-2
gradle.properties
gradle.properties
+1
-1
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
...rc/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
+7
-105
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/CommonUtil.java
.../main/java/com/shuyu/gsyvideoplayer/utils/CommonUtil.java
+16
-0
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
...java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
+3
-2
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
...va/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
+346
-0
未找到文件。
0034.gif
0 → 100644
浏览文件 @
8fc79be1
1.6 MB
README.md
浏览文件 @
8fc79be1
...
...
@@ -4,13 +4,13 @@
<dependency>
<groupId>com.shuyu</groupId>
<artifactId>gsyVideoPlayer</artifactId>
<version>1.1.
2
</version>
<version>1.1.
3
</version>
<type>pom</type>
</dependency>
```
```
compile 'com.shuyu:gsyVideoPlayer:1.1.
2
'
compile 'com.shuyu:gsyVideoPlayer:1.1.
3
'
```
...
...
@@ -35,6 +35,12 @@ compile 'com.shuyu:gsyVideoPlayer:1.1.2'
*
<h4>
3、详情模式
</h4>
<img
src=
"https://github.com/CarGuo/GSYVideoPlayer/blob/master/04.gif"
width=
"240px"
height=
"426px"
/>
## 1.1.3
*
优化了第一种列表的全屏动画,5.0以上展开和返回过渡顺畅,支持自动旋转的开启与关闭
*
GIF 效果
<img
src=
"https://github.com/CarGuo/GSYVideoPlayer/blob/master/0034.gif"
width=
"240px"
height=
"426px"
/>
## 1.1.2
*
增加了TAG和position来实现第一种list列表(非ListVideoUtil模式的列表实现)的滑动错位问题
...
...
gradle.properties
浏览文件 @
8fc79be1
...
...
@@ -18,7 +18,7 @@ org.gradle.jvmargs=-Xmx1536m
BINTRAY_USER
=
BINTRAY_KEY
=
PROJ_GROUP
=
com.shuyu
PROJ_VERSION
=
1.1.
2
PROJ_VERSION
=
1.1.
3
PROJ_NAME
=
gsyVideo
PROJ_WEBSITEURL
=
hhttps://github.com/CarGuo/GSYVideoPlayer
PROJ_ISSUETRACKERURL
=
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
浏览文件 @
8fc79be1
...
...
@@ -16,7 +16,6 @@ import android.view.ViewGroup;
import
android.view.ViewParent
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.SeekBar
;
...
...
@@ -27,8 +26,8 @@ import com.danikula.videocache.HttpProxyCacheServer;
import
com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener
;
import
com.shuyu.gsyvideoplayer.listener.VideoAllCallBack
;
import
com.shuyu.gsyvideoplayer.utils.CommonUtil
;
import
com.shuyu.gsyvideoplayer.video.GSYBaseVideoPlayer
;
import
java.lang.reflect.Constructor
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Timer
;
...
...
@@ -36,18 +35,15 @@ import java.util.TimerTask;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideSupportActionBar
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
showSupportActionBar
;
/**
* Created by shuyu on 2016/11/11.
*/
public
abstract
class
GSYVideoPlayer
extends
FrameLayout
implements
View
.
OnClickListener
,
View
.
OnTouchListener
,
SeekBar
.
OnSeekBarChangeListener
,
GSYMediaPlayer
Listener
,
TextureView
.
SurfaceTextureListener
{
public
abstract
class
GSYVideoPlayer
extends
GSYBaseVideoPlayer
implements
View
.
OnClickListener
,
View
.
OnTouchListener
,
SeekBar
.
OnSeekBarChange
Listener
,
TextureView
.
SurfaceTextureListener
{
public
static
final
String
TAG
=
"GSYVideoPlayer"
;
public
static
final
int
FULLSCREEN_ID
=
83797
;
protected
static
final
int
CURRENT_STATE_NORMAL
=
0
;
//正常
protected
static
final
int
CURRENT_STATE_PREPAREING
=
1
;
//准备中
...
...
@@ -67,26 +63,20 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
public
static
boolean
WIFI_TIP_DIALOG_SHOWED
=
false
;
protected
static
long
CLICK_QUIT_FULLSCREEN_TIME
=
0
;
protected
static
Timer
UPDATE_PROGRESS_TIMER
;
private
Context
mContext
;
protected
ImageView
mStartButton
;
protected
SeekBar
mProgressBar
;
protected
ImageView
mFullscreenButton
;
protected
TextView
mCurrentTimeTextView
,
mTotalTimeTextView
;
protected
ViewGroup
mTextureViewContainer
;
protected
ViewGroup
mTopContainer
,
mBottomContainer
;
protected
GSYTextureView
mTextureView
;
protected
Surface
mSurface
;
protected
ImageView
mBackButton
;
protected
String
mUrl
;
protected
Object
[]
mObjects
;
protected
Map
<
String
,
String
>
mMapHeadData
=
new
HashMap
<>();
protected
ProgressTimerTask
mProgressTimerTask
;
protected
AudioManager
mAudioManager
;
//音频焦点的监听
...
...
@@ -104,8 +94,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
protected
float
mBrightnessData
=
-
1
;
//亮度
protected
int
mCurrentState
=
-
1
;
//当前的播放状态
protected
int
mDownPosition
;
//手指放下的位置
protected
int
mGestureDownVolume
;
//手势调节音量的大小
...
...
@@ -142,12 +130,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
protected
boolean
mLooping
=
false
;
//// TODO: 2016/11/13 循环
protected
boolean
mCache
=
false
;
//是否播边边缓冲
protected
boolean
mActionBar
=
false
;
//是否需要在利用window实现全屏幕的时候隐藏actionbar
protected
boolean
mStatusBar
=
false
;
//是否需要在利用window实现全屏幕的时候隐藏statusbar
/**
* 当前UI
...
...
@@ -869,89 +851,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
}
/**
* 利用window层播放全屏效果
*
* @param context
* @param actionBar 是否有actionBar,有的话需要隐藏
* @param statusBar 是否有状态bar,有的话需要隐藏
*/
public
void
startWindowFullscreen
(
final
Context
context
,
final
boolean
actionBar
,
final
boolean
statusBar
)
{
this
.
mActionBar
=
actionBar
;
this
.
mStatusBar
=
statusBar
;
hideSupportActionBar
(
context
,
actionBar
,
statusBar
);
ViewGroup
vp
=
(
ViewGroup
)
(
CommonUtil
.
scanForActivity
(
getContext
())).
findViewById
(
Window
.
ID_ANDROID_CONTENT
);
View
old
=
vp
.
findViewById
(
FULLSCREEN_ID
);
if
(
old
!=
null
)
{
vp
.
removeView
(
old
);
}
if
(
mTextureViewContainer
.
getChildCount
()
>
0
)
{
mTextureViewContainer
.
removeAllViews
();
}
try
{
Constructor
<
GSYVideoPlayer
>
constructor
=
(
Constructor
<
GSYVideoPlayer
>)
GSYVideoPlayer
.
this
.
getClass
().
getConstructor
(
Context
.
class
);
GSYVideoPlayer
gsyVideoPlayer
=
constructor
.
newInstance
(
getContext
());
gsyVideoPlayer
.
setId
(
FULLSCREEN_ID
);
WindowManager
wm
=
(
WindowManager
)
getContext
().
getSystemService
(
Context
.
WINDOW_SERVICE
);
int
w
=
wm
.
getDefaultDisplay
().
getWidth
();
int
h
=
wm
.
getDefaultDisplay
().
getHeight
();
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
h
,
w
);
lp
.
setMargins
((
w
-
h
)
/
2
,
-(
w
-
h
)
/
2
,
0
,
0
);
vp
.
addView
(
gsyVideoPlayer
,
lp
);
gsyVideoPlayer
.
setUp
(
mUrl
,
mCache
,
mObjects
);
gsyVideoPlayer
.
setStateAndUi
(
mCurrentState
);
gsyVideoPlayer
.
addTextureView
();
gsyVideoPlayer
.
setRotation
(
90
);
gsyVideoPlayer
.
getFullscreenButton
().
setImageResource
(
R
.
drawable
.
video_shrink
);
gsyVideoPlayer
.
getFullscreenButton
().
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
clearFullscreenLayout
();
}
});
gsyVideoPlayer
.
getBackButton
().
setVisibility
(
VISIBLE
);
gsyVideoPlayer
.
getBackButton
().
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
clearFullscreenLayout
();
}
});
GSYVideoManager
.
instance
().
setLastListener
(
this
);
GSYVideoManager
.
instance
().
setListener
(
gsyVideoPlayer
);
}
catch
(
InstantiationException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 退出window层播放全屏效果
*/
public
void
clearFullscreenLayout
()
{
showSupportActionBar
(
mContext
,
mActionBar
,
mStatusBar
);
ViewGroup
vp
=
(
ViewGroup
)
(
CommonUtil
.
scanForActivity
(
getContext
())).
findViewById
(
Window
.
ID_ANDROID_CONTENT
);
View
oldF
=
vp
.
findViewById
(
FULLSCREEN_ID
);
GSYVideoPlayer
gsyVideoPlayer
=
null
;
if
(
oldF
!=
null
)
{
gsyVideoPlayer
=
(
GSYVideoPlayer
)
oldF
;
vp
.
removeView
(
oldF
);
}
mCurrentState
=
GSYVideoManager
.
instance
().
getLastState
();
if
(
gsyVideoPlayer
!=
null
)
{
mCurrentState
=
gsyVideoPlayer
.
getCurrentState
();
}
GSYVideoManager
.
instance
().
setListener
(
GSYVideoManager
.
instance
().
lastListener
());
GSYVideoManager
.
instance
().
setLastListener
(
null
);
setStateAndUi
(
mCurrentState
);
addTextureView
();
CLICK_QUIT_FULLSCREEN_TIME
=
System
.
currentTimeMillis
();
}
/**
* 滑动改变亮度
*
...
...
@@ -1034,8 +933,11 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
return
mPlayPosition
;
}
public
void
setPlayPosition
(
int
playPostion
)
{
this
.
mPlayPosition
=
playPostion
;
/**
* 设置播放位置防止错位
*/
public
void
setPlayPosition
(
int
playPosition
)
{
this
.
mPlayPosition
=
playPosition
;
}
/**
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/CommonUtil.java
浏览文件 @
8fc79be1
...
...
@@ -8,6 +8,7 @@ import android.net.NetworkInfo;
import
android.support.v7.app.ActionBar
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.internal.view.ContextThemeWrapper
;
import
android.util.TypedValue
;
import
android.view.WindowManager
;
import
java.util.Formatter
;
...
...
@@ -79,6 +80,21 @@ public class CommonUtil {
return
result
;
}
/**
* 获取ActionBar高度
*
* @param activity activity
* @return ActionBar高度
*/
public
static
int
getActionBarHeight
(
Activity
activity
)
{
TypedValue
tv
=
new
TypedValue
();
if
(
activity
.
getTheme
().
resolveAttribute
(
android
.
R
.
attr
.
actionBarSize
,
tv
,
true
))
{
return
TypedValue
.
complexToDimensionPixelSize
(
tv
.
data
,
activity
.
getResources
().
getDisplayMetrics
());
}
return
0
;
}
public
static
void
hideSupportActionBar
(
Context
context
,
boolean
actionBar
,
boolean
statusBar
)
{
if
(
actionBar
)
{
ActionBar
ab
=
CommonUtil
.
getAppCompActivity
(
context
).
getSupportActionBar
();
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
浏览文件 @
8fc79be1
...
...
@@ -7,6 +7,7 @@ import android.view.OrientationEventListener;
import
com.shuyu.gsyvideoplayer.GSYVideoPlayer
;
import
com.shuyu.gsyvideoplayer.R
;
import
com.shuyu.gsyvideoplayer.video.GSYBaseVideoPlayer
;
/**
* 处理屏幕旋转的的逻辑
...
...
@@ -16,7 +17,7 @@ import com.shuyu.gsyvideoplayer.R;
public
class
OrientationUtils
{
private
Activity
activity
;
private
GSYVideoPlayer
gsyVideoPlayer
;
private
GSY
Base
VideoPlayer
gsyVideoPlayer
;
private
int
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
;
private
OrientationEventListener
orientationEventListener
;
...
...
@@ -28,7 +29,7 @@ public class OrientationUtils {
* @param activity
* @param gsyVideoPlayer
*/
public
OrientationUtils
(
Activity
activity
,
GSYVideoPlayer
gsyVideoPlayer
)
{
public
OrientationUtils
(
Activity
activity
,
GSY
Base
VideoPlayer
gsyVideoPlayer
)
{
this
.
activity
=
activity
;
this
.
gsyVideoPlayer
=
gsyVideoPlayer
;
init
();
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/GSYBaseVideoPlayer.java
0 → 100644
浏览文件 @
8fc79be1
package
com.shuyu.gsyvideoplayer.video
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.transition.TransitionManager
;
import
android.util.AttributeSet
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
import
com.shuyu.gsyvideoplayer.GSYVideoPlayer
;
import
com.shuyu.gsyvideoplayer.R
;
import
com.shuyu.gsyvideoplayer.listener.GSYMediaPlayerListener
;
import
com.shuyu.gsyvideoplayer.utils.CommonUtil
;
import
com.shuyu.gsyvideoplayer.utils.OrientationUtils
;
import
java.lang.reflect.Constructor
;
import
java.util.Map
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
getActionBarHeight
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
getStatusBarHeight
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
hideSupportActionBar
;
import
static
com
.
shuyu
.
gsyvideoplayer
.
utils
.
CommonUtil
.
showSupportActionBar
;
/**
* Created by shuyu on 2016/11/17.
*/
public
abstract
class
GSYBaseVideoPlayer
extends
FrameLayout
implements
GSYMediaPlayerListener
{
protected
static
final
int
FULLSCREEN_ID
=
83797
;
protected
static
long
CLICK_QUIT_FULLSCREEN_TIME
=
0
;
protected
boolean
mActionBar
=
false
;
//是否需要在利用window实现全屏幕的时候隐藏actionbar
protected
boolean
mStatusBar
=
false
;
//是否需要在利用window实现全屏幕的时候隐藏statusbar
protected
boolean
mCache
=
false
;
//是否播边边缓冲
protected
int
[]
mListItemRect
;
//当前item框的屏幕位置
protected
int
[]
mListItemSize
;
//当前item的大小
protected
int
mCurrentState
=
-
1
;
//当前的播放状态
protected
boolean
mRotateViewAuto
=
true
;
//是否自动旋转
protected
Context
mContext
;
protected
String
mUrl
;
protected
Object
[]
mObjects
;
protected
ViewGroup
mTextureViewContainer
;
private
OrientationUtils
mOrientationUtils
;
private
Handler
mHandler
=
new
Handler
();
public
GSYBaseVideoPlayer
(
Context
context
)
{
super
(
context
);
}
public
GSYBaseVideoPlayer
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
public
GSYBaseVideoPlayer
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
}
private
ViewGroup
getViewGroup
()
{
return
(
ViewGroup
)
(
CommonUtil
.
scanForActivity
(
getContext
())).
findViewById
(
Window
.
ID_ANDROID_CONTENT
);
}
/**
* 移除没用的
*/
private
void
removeVideo
(
ViewGroup
vp
)
{
View
old
=
vp
.
findViewById
(
FULLSCREEN_ID
);
if
(
old
!=
null
)
{
if
(
old
.
getParent
()
!=
null
)
{
ViewGroup
viewGroup
=
(
ViewGroup
)
old
.
getParent
();
vp
.
removeView
(
viewGroup
);
}
}
}
/**
* 保存大小和状态
*/
private
void
saveLocationStatus
(
Context
context
,
boolean
statusBar
,
boolean
actionBar
)
{
getLocationOnScreen
(
mListItemRect
);
int
statusBarH
=
getStatusBarHeight
(
context
);
int
actionBerH
=
getActionBarHeight
((
Activity
)
context
);
if
(
statusBar
)
{
mListItemRect
[
1
]
=
mListItemRect
[
1
]
-
statusBarH
;
}
if
(
actionBar
)
{
mListItemRect
[
1
]
=
mListItemRect
[
1
]
-
actionBerH
;
}
mListItemSize
[
0
]
=
getWidth
();
mListItemSize
[
1
]
=
getHeight
();
}
/**
* 全屏
*/
private
void
resolveFullVideoShow
(
Context
context
,
GSYBaseVideoPlayer
gsyVideoPlayer
,
int
h
,
int
w
)
{
FrameLayout
.
LayoutParams
lp
=
(
FrameLayout
.
LayoutParams
)
gsyVideoPlayer
.
getLayoutParams
();
lp
.
setMargins
(
0
,
0
,
0
,
0
);
lp
.
height
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
lp
.
width
=
ViewGroup
.
LayoutParams
.
MATCH_PARENT
;
lp
.
gravity
=
Gravity
.
CENTER
;
gsyVideoPlayer
.
setLayoutParams
(
lp
);
mOrientationUtils
=
new
OrientationUtils
((
Activity
)
context
,
gsyVideoPlayer
);
mOrientationUtils
.
setEnable
(
mRotateViewAuto
);
}
/**
* 恢复
*/
private
void
resolveNormalVideoShow
(
View
oldF
,
ViewGroup
vp
,
GSYVideoPlayer
gsyVideoPlayer
)
{
if
(
oldF
.
getParent
()
!=
null
)
{
ViewGroup
viewGroup
=
(
ViewGroup
)
oldF
.
getParent
();
vp
.
removeView
(
viewGroup
);
}
mCurrentState
=
GSYVideoManager
.
instance
().
getLastState
();
if
(
gsyVideoPlayer
!=
null
)
{
mCurrentState
=
gsyVideoPlayer
.
getCurrentState
();
}
GSYVideoManager
.
instance
().
setListener
(
GSYVideoManager
.
instance
().
lastListener
());
GSYVideoManager
.
instance
().
setLastListener
(
null
);
setStateAndUi
(
mCurrentState
);
addTextureView
();
CLICK_QUIT_FULLSCREEN_TIME
=
System
.
currentTimeMillis
();
}
/**
* 利用window层播放全屏效果
*
* @param context
* @param actionBar 是否有actionBar,有的话需要隐藏
* @param statusBar 是否有状态bar,有的话需要隐藏
*/
public
void
startWindowFullscreen
(
final
Context
context
,
final
boolean
actionBar
,
final
boolean
statusBar
)
{
hideSupportActionBar
(
context
,
actionBar
,
statusBar
);
this
.
mActionBar
=
actionBar
;
this
.
mStatusBar
=
statusBar
;
mListItemRect
=
new
int
[
2
];
mListItemSize
=
new
int
[
2
];
final
ViewGroup
vp
=
getViewGroup
();
removeVideo
(
vp
);
if
(
mTextureViewContainer
.
getChildCount
()
>
0
)
{
mTextureViewContainer
.
removeAllViews
();
}
saveLocationStatus
(
context
,
statusBar
,
actionBar
);
try
{
Constructor
<
GSYBaseVideoPlayer
>
constructor
=
(
Constructor
<
GSYBaseVideoPlayer
>)
GSYBaseVideoPlayer
.
this
.
getClass
().
getConstructor
(
Context
.
class
);
final
GSYBaseVideoPlayer
gsyVideoPlayer
=
constructor
.
newInstance
(
getContext
());
gsyVideoPlayer
.
setId
(
FULLSCREEN_ID
);
WindowManager
wm
=
(
WindowManager
)
getContext
().
getSystemService
(
Context
.
WINDOW_SERVICE
);
final
int
w
=
wm
.
getDefaultDisplay
().
getWidth
();
final
int
h
=
wm
.
getDefaultDisplay
().
getHeight
();
FrameLayout
.
LayoutParams
lpParent
=
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
MATCH_PARENT
);
FrameLayout
frameLayout
=
new
FrameLayout
(
context
);
frameLayout
.
setBackgroundColor
(
Color
.
BLACK
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
getWidth
(),
getHeight
());
lp
.
setMargins
(
mListItemRect
[
0
],
mListItemRect
[
1
],
0
,
0
);
frameLayout
.
addView
(
gsyVideoPlayer
,
lp
);
vp
.
addView
(
frameLayout
,
lpParent
);
mHandler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
TransitionManager
.
beginDelayedTransition
(
vp
);
resolveFullVideoShow
(
context
,
gsyVideoPlayer
,
h
,
w
);
}
},
300
);
}
else
{
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
getWidth
(),
getHeight
());
frameLayout
.
addView
(
gsyVideoPlayer
,
lp
);
vp
.
addView
(
frameLayout
,
lpParent
);
resolveFullVideoShow
(
context
,
gsyVideoPlayer
,
h
,
w
);
}
gsyVideoPlayer
.
setUp
(
mUrl
,
mCache
,
mObjects
);
gsyVideoPlayer
.
setStateAndUi
(
mCurrentState
);
gsyVideoPlayer
.
addTextureView
();
gsyVideoPlayer
.
getFullscreenButton
().
setImageResource
(
R
.
drawable
.
video_shrink
);
gsyVideoPlayer
.
getFullscreenButton
().
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
clearFullscreenLayout
();
}
});
gsyVideoPlayer
.
getBackButton
().
setVisibility
(
VISIBLE
);
gsyVideoPlayer
.
getBackButton
().
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
clearFullscreenLayout
();
}
});
GSYVideoManager
.
instance
().
setLastListener
(
this
);
GSYVideoManager
.
instance
().
setListener
(
gsyVideoPlayer
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 退出window层播放全屏效果
*/
public
void
clearFullscreenLayout
()
{
int
delay
=
mOrientationUtils
.
backToProtVideo
();
mOrientationUtils
.
setEnable
(
false
);
mHandler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
backToNormal
();
}
},
delay
);
}
/**
* 回到正常效果
*/
private
void
backToNormal
()
{
showSupportActionBar
(
mContext
,
mActionBar
,
mStatusBar
);
final
ViewGroup
vp
=
getViewGroup
();
final
View
oldF
=
vp
.
findViewById
(
FULLSCREEN_ID
);
final
GSYVideoPlayer
gsyVideoPlayer
;
if
(
oldF
!=
null
)
{
gsyVideoPlayer
=
(
GSYVideoPlayer
)
oldF
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
TransitionManager
.
beginDelayedTransition
(
vp
);
FrameLayout
.
LayoutParams
lp
=
(
FrameLayout
.
LayoutParams
)
gsyVideoPlayer
.
getLayoutParams
();
lp
.
setMargins
(
mListItemRect
[
0
],
mListItemRect
[
1
],
0
,
0
);
lp
.
width
=
mListItemSize
[
0
];
lp
.
height
=
mListItemSize
[
1
];
//注意配置回来,不然动画效果会不对
lp
.
gravity
=
Gravity
.
NO_GRAVITY
;
gsyVideoPlayer
.
setLayoutParams
(
lp
);
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
resolveNormalVideoShow
(
oldF
,
vp
,
gsyVideoPlayer
);
}
},
400
);
}
else
{
resolveNormalVideoShow
(
oldF
,
vp
,
gsyVideoPlayer
);
}
}
else
{
resolveNormalVideoShow
(
null
,
vp
,
null
);
}
}
/**
* 设置播放URL
*
* @param url
* @param cacheWithPlay 是否边播边缓存
* @param objects
* @return
*/
public
abstract
boolean
setUp
(
String
url
,
boolean
cacheWithPlay
,
Object
...
objects
);
/**
* 设置播放URL
*
* @param url
* @param cacheWithPlay 是否边播边缓存
* @param mapHeadData
* @param objects
* @return
*/
public
abstract
boolean
setUp
(
String
url
,
boolean
cacheWithPlay
,
Map
<
String
,
String
>
mapHeadData
,
Object
...
objects
);
/**
* 设置播放显示状态
*
* @param state
*/
protected
abstract
void
setStateAndUi
(
int
state
);
/**
* 添加播放的view
*/
protected
abstract
void
addTextureView
();
/**
* 获取全屏按键
*/
public
abstract
ImageView
getFullscreenButton
();
/**
* 获取返回按键
*/
public
abstract
ImageView
getBackButton
();
public
boolean
isRotateViewAuto
()
{
return
mRotateViewAuto
;
}
/**
* 自动旋转
*/
public
void
setRotateViewAuto
(
boolean
rotateViewAuto
)
{
this
.
mRotateViewAuto
=
rotateViewAuto
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录