Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
GSYVideoPlayer
提交
80421df8
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,体验更适合开发者的 AI 搜索 >>
提交
80421df8
编写于
11月 11, 2016
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
整理了代码
上级
027b7aca
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
89 addition
and
132 deletion
+89
-132
app/src/main/java/com/example/gsyvideoplayer/PlayActivity.java
...rc/main/java/com/example/gsyvideoplayer/PlayActivity.java
+7
-8
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYTextureView.java
...rc/main/java/com/shuyu/gsyvideoplayer/GSYTextureView.java
+1
-0
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
...c/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
+13
-5
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
...rc/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
+30
-89
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
...java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
+7
-5
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
...om/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
+31
-25
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/PlayActivity.java
浏览文件 @
80421df8
...
...
@@ -47,20 +47,20 @@ public class PlayActivity extends AppCompatActivity {
//standardPlayer.thumbImageView.setImageURI(uri);
//standardPlayer.titleTextView.setVisibility(View.GONE);
videoPlayer
.
backButton
.
setVisibility
(
View
.
VISIBLE
);
videoPlayer
.
getBackButton
()
.
setVisibility
(
View
.
VISIBLE
);
videoPlayer
.
setIsTouchWiget
(
true
);
orientationUtils
=
new
OrientationUtils
(
this
,
videoPlayer
);
videoPlayer
.
fullscreenButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
videoPlayer
.
getFullscreenButton
()
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
orientationUtils
.
resolveByClick
();
}
});
videoPlayer
.
backButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
videoPlayer
.
getBackButton
()
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
onBackPressed
();
...
...
@@ -91,10 +91,10 @@ public class PlayActivity extends AppCompatActivity {
public
void
onBackPressed
()
{
if
(
orientationUtils
.
getScreenType
()
==
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
)
{
videoPlayer
.
fullscreenButton
.
performClick
();
videoPlayer
.
getFullscreenButton
()
.
performClick
();
return
;
}
StandardGSYVideoPlayer
.
setJcBuriedPointStandard
(
null
);
videoPlayer
.
setStandardVideoAllCallBack
(
null
);
GSYVideoPlayer
.
releaseAllVideos
();
if
(
isTransition
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
super
.
onBackPressed
();
...
...
@@ -112,7 +112,7 @@ public class PlayActivity extends AppCompatActivity {
addTransitionListener
();
startPostponedEnterTransition
();
}
else
{
videoPlayer
.
startPlayLo
c
ic
();
videoPlayer
.
startPlayLo
g
ic
();
}
}
...
...
@@ -123,8 +123,7 @@ public class PlayActivity extends AppCompatActivity {
transition
.
addListener
(
new
OnTransitionListener
()
{
@Override
public
void
onTransitionEnd
(
Transition
transition
)
{
videoPlayer
.
startPlayLocic
();
// Make sure we remove ourselves as a listener
videoPlayer
.
startPlayLogic
();
transition
.
removeListener
(
this
);
}
});
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYTextureView.java
浏览文件 @
80421df8
...
...
@@ -5,6 +5,7 @@ import android.util.AttributeSet;
import
android.view.TextureView
;
/**
* 用于显示video的,做了横屏与竖屏的匹配,还有需要rotation需求的
* Created by shuyu on 2016/11/11.
*/
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoManager.java
浏览文件 @
80421df8
package
com.shuyu.gsyvideoplayer
;
import
android.app.Application
;
import
android.content.Context
;
import
android.media.AudioManager
;
import
android.net.Uri
;
...
...
@@ -22,6 +22,8 @@ import tv.danmaku.ijk.media.exo.IjkExoMediaPlayer;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
/**
* 视频管理,单例
* 目前使用的是IJK封装的谷歌EXOPlayer
* Created by shuyu on 2016/11/11.
*/
...
...
@@ -46,11 +48,11 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
private
WeakReference
<
GSYMediaPlayerListener
>
listener
;
private
WeakReference
<
GSYMediaPlayerListener
>
lastListener
;
private
HttpProxyCacheServer
proxy
;
private
HttpProxyCacheServer
proxy
;
//视频代理
private
int
currentVideoWidth
=
0
;
private
int
currentVideoHeight
=
0
;
private
int
lastState
;
private
int
currentVideoWidth
=
0
;
//当前播放的视频宽的高
private
int
currentVideoHeight
=
0
;
//当前播放的视屏的高
private
int
lastState
;
//当前视频的最后状态
/**
* 初始化,必须的
...
...
@@ -67,11 +69,17 @@ public class GSYVideoManager implements IMediaPlayer.OnPreparedListener, IMediaP
return
videoManager
;
}
/**
* 获取缓存代理服务
*/
public
static
HttpProxyCacheServer
getProxy
(
Context
context
)
{
HttpProxyCacheServer
proxy
=
GSYVideoManager
.
instance
().
proxy
;
return
proxy
==
null
?
(
proxy
=
GSYVideoManager
.
instance
().
newProxy
(
context
))
:
proxy
;
}
/**
* 创建缓存代理服务
*/
private
HttpProxyCacheServer
newProxy
(
Context
context
)
{
return
new
HttpProxyCacheServer
(
context
.
getApplicationContext
());
}
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/GSYVideoPlayer.java
浏览文件 @
80421df8
...
...
@@ -43,7 +43,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
public
static
final
String
TAG
=
"GSYVideoPlayer"
;
protected
static
final
int
CURRENT_STATE_NORMAL
=
0
;
protected
static
final
int
CURRENT_STATE_PREPAREING
=
1
;
protected
static
final
int
CURRENT_STATE_PLAYING
=
2
;
...
...
@@ -56,26 +55,28 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
protected
boolean
mTouchingProgressBar
=
false
;
protected
boolean
mIfCurrentIsFullscreen
=
false
;
protected
boolean
mIsTouchWiget
=
false
;
protected
boolean
mIfFullscreenIsDirectly
=
false
;
protected
static
boolean
IF_FULLSCREEN_FROM_NORMAL
=
false
;
//to prevent infinite looping
public
static
boolean
IF_RELEASE_WHEN_ON_PAUSE
=
true
;
protected
static
long
CLICK_QUIT_FULLSCREEN_TIME
=
0
;
public
static
final
int
FULL_SCREEN_NORMAL_DELAY
=
2000
;
public
static
boolean
IF_RELEASE_WHEN_ON_PAUSE
=
true
;
public
static
final
int
FULL_SCREEN_NORMAL_DELAY
=
2000
;
protected
static
Timer
UPDATE_PROGRESS_TIMER
;
protected
static
VideoAllCallBack
videoAllCallBack
;
public
static
boolean
WIFI_TIP_DIALOG_SHOWED
=
false
;
public
ImageView
startButton
;
public
SeekBar
progressBar
;
public
ImageView
fullscreenButton
;
public
TextView
currentTimeTextView
,
totalTimeTextView
;
public
ViewGroup
textureViewContainer
;
public
ViewGroup
topContainer
,
bottomContainer
;
public
GSYTextureView
textureView
;
public
Surface
mSurface
;
public
Activity
activity
;
protected
static
Timer
UPDATE_PROGRESS_TIMER
;
protected
VideoAllCallBack
videoAllCallBack
;
protected
ImageView
startButton
;
protected
SeekBar
progressBar
;
protected
ImageView
fullscreenButton
;
protected
TextView
currentTimeTextView
,
totalTimeTextView
;
protected
ViewGroup
textureViewContainer
;
protected
ViewGroup
topContainer
,
bottomContainer
;
protected
GSYTextureView
textureView
;
protected
Surface
mSurface
;
protected
Activity
activity
;
protected
String
mUrl
;
protected
Object
[]
mObjects
;
...
...
@@ -96,7 +97,7 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
protected
int
mScreenWidth
;
protected
int
mScreenHeight
;
protected
int
mThreshold
=
80
;
p
ublic
int
seekToInAdvance
=
-
1
;
p
rotected
int
seekToInAdvance
=
-
1
;
private
int
rotate
=
0
;
private
long
pauseTime
;
...
...
@@ -110,6 +111,7 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
protected
int
mSeekTimePosition
;
public
abstract
int
getLayoutId
();
public
GSYVideoPlayer
(
Context
context
)
{
super
(
context
);
...
...
@@ -149,10 +151,9 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
activity
=
(
Activity
)
context
;
}
public
abstract
int
getLayoutId
();
protected
static
void
setJcBuriedPoint
(
VideoAllCallBack
jcBuriedPoint
)
{
videoAllCallBack
=
jcBuriedPoint
;
protected
void
setVideoAllCallBack
(
VideoAllCallBack
videoAllCallBack
)
{
this
.
videoAllCallBack
=
videoAllCallBack
;
}
public
boolean
setUp
(
String
url
,
boolean
cacheWithPlay
,
Object
...
objects
)
{
...
...
@@ -215,7 +216,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
public
void
onClick
(
View
v
)
{
int
i
=
v
.
getId
();
if
(
i
==
R
.
id
.
start
)
{
Log
.
i
(
TAG
,
"onClick start ["
+
this
.
hashCode
()
+
"] "
);
if
(
TextUtils
.
isEmpty
(
mUrl
))
{
Toast
.
makeText
(
getContext
(),
getResources
().
getString
(
R
.
string
.
no_url
),
Toast
.
LENGTH_SHORT
).
show
();
return
;
...
...
@@ -227,7 +227,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
}
startButtonLogic
();
}
else
if
(
mCurrentState
==
CURRENT_STATE_PLAYING
)
{
Log
.
d
(
TAG
,
"pauseVideo ["
+
this
.
hashCode
()
+
"] "
);
GSYVideoManager
.
instance
().
getMediaPlayer
().
pause
();
setStateAndUi
(
CURRENT_STATE_PAUSE
);
if
(
videoAllCallBack
!=
null
&&
isCurrentMediaListener
())
{
...
...
@@ -250,25 +249,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
}
else
if
(
mCurrentState
==
CURRENT_STATE_AUTO_COMPLETE
)
{
startButtonLogic
();
}
}
else
if
(
i
==
R
.
id
.
fullscreen
)
{
/*Log.i(TAG, "onClick fullscreen [" + this.hashCode() + "] ");
if (mCurrentState == CURRENT_STATE_AUTO_COMPLETE) return;
if (mIfCurrentIsFullscreen) {
//quit fullscreen
backFullscreen();
} else {
Log.d(TAG, "toFullscreenActivity [" + this.hashCode() + "] ");
if (JC_BURIED_POINT != null && isCurrentMediaListener()) {
JC_BURIED_POINT.onEnterFullscreen(mUrl, mObjects);
}
//to fullscreen
GSYVideoManager.instance().setDisplay(null);
GSYVideoManager.instance().setLastListener(this);
GSYVideoManager.instance().setListener(null);
IF_FULLSCREEN_FROM_NORMAL = true;
IF_RELEASE_WHEN_ON_PAUSE = false;
JCFullScreenActivity.startActivityFromNormal(getContext(), mCurrentState, mUrl, JCVideoPlayer.this, rotate, JCVideoPlayer.this.getClass(), this.mObjects);
}*/
}
else
if
(
i
==
R
.
id
.
surface_container
&&
mCurrentState
==
CURRENT_STATE_ERROR
)
{
if
(
videoAllCallBack
!=
null
)
{
videoAllCallBack
.
onClickStartError
(
mUrl
,
mObjects
);
...
...
@@ -357,7 +337,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
protected
void
addTextureView
()
{
Log
.
d
(
TAG
,
"addTextureView ["
+
this
.
hashCode
()
+
"] "
);
if
(
textureViewContainer
.
getChildCount
()
>
0
)
{
textureViewContainer
.
removeAllViews
();
}
...
...
@@ -416,19 +395,16 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
if
(
id
==
R
.
id
.
surface_container
)
{
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
Log
.
i
(
TAG
,
"onTouch surfaceContainer actionDown ["
+
this
.
hashCode
()
+
"] "
);
mTouchingProgressBar
=
true
;
mDownX
=
x
;
mDownY
=
y
;
mChangeVolume
=
false
;
mChangePosition
=
false
;
mBrightness
=
false
;
firstTouch
=
true
;
/////////////////////
break
;
case
MotionEvent
.
ACTION_MOVE
:
Log
.
i
(
TAG
,
"onTouch surfaceContainer actionMove ["
+
this
.
hashCode
()
+
"] "
);
float
deltaX
=
x
-
mDownX
;
float
deltaY
=
y
-
mDownY
;
float
absDeltaX
=
Math
.
abs
(
deltaX
);
...
...
@@ -484,7 +460,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
break
;
case
MotionEvent
.
ACTION_UP
:
Log
.
i
(
TAG
,
"onTouch surfaceContainer actionUp ["
+
this
.
hashCode
()
+
"] "
);
mTouchingProgressBar
=
false
;
dismissProgressDialog
();
dismissVolumeDialog
();
...
...
@@ -495,7 +470,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
int
progress
=
mSeekTimePosition
*
100
/
(
duration
==
0
?
1
:
duration
);
progressBar
.
setProgress
(
progress
);
}
/////////////////////
startProgressTimer
();
if
(
videoAllCallBack
!=
null
&&
isCurrentMediaListener
())
{
if
(
mIfCurrentIsFullscreen
)
{
...
...
@@ -506,11 +480,10 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
}
break
;
}
}
else
if
(
id
==
R
.
id
.
progress
)
{
//if I am seeking bar,no mater whoever can not intercept my event
}
else
if
(
id
==
R
.
id
.
progress
)
{
switch
(
event
.
getAction
())
{
case
MotionEvent
.
ACTION_DOWN
:
case
MotionEvent
.
ACTION_MOVE
:
Log
.
i
(
TAG
,
"onTouch bottomProgress actionUp ["
+
this
.
hashCode
()
+
"] "
);
cancelProgressTimer
();
ViewParent
vpdown
=
getParent
();
while
(
vpdown
!=
null
)
{
...
...
@@ -519,7 +492,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
}
break
;
case
MotionEvent
.
ACTION_UP
:
Log
.
i
(
TAG
,
"onTouch bottomProgress actionDown ["
+
this
.
hashCode
()
+
"] "
);
startProgressTimer
();
ViewParent
vpup
=
getParent
();
while
(
vpup
!=
null
)
{
...
...
@@ -576,7 +548,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
if
(
GSYVideoManager
.
instance
().
getMediaPlayer
()
!=
null
&&
GSYVideoManager
.
instance
().
getMediaPlayer
().
isPlaying
())
{
int
time
=
seekBar
.
getProgress
()
*
getDuration
()
/
100
;
GSYVideoManager
.
instance
().
getMediaPlayer
().
seekTo
(
time
);
Log
.
i
(
TAG
,
"seekTo "
+
time
+
" ["
+
this
.
hashCode
()
+
"] "
);
}
}
...
...
@@ -594,7 +565,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
@Override
public
void
onAutoCompletion
()
{
//make me normal first
if
(
videoAllCallBack
!=
null
&&
isCurrentMediaListener
())
{
if
(
mIfCurrentIsFullscreen
)
{
videoAllCallBack
.
onAutoCompleteFullscreen
(
mUrl
,
mObjects
);
...
...
@@ -642,7 +612,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
@Override
public
void
onBufferingUpdate
(
int
percent
)
{
if
(
mCurrentState
!=
CURRENT_STATE_NORMAL
&&
mCurrentState
!=
CURRENT_STATE_PREPAREING
)
{
Log
.
v
(
TAG
,
"onBufferingUpdate "
+
percent
+
" ["
+
this
.
hashCode
()
+
"] "
);
setTextAndProgress
(
percent
);
}
}
...
...
@@ -654,7 +623,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
@Override
public
void
onError
(
int
what
,
int
extra
)
{
Log
.
e
(
TAG
,
"onError "
+
what
+
" - "
+
extra
+
" ["
+
this
.
hashCode
()
+
"] "
);
if
(
what
!=
38
&&
what
!=
-
38
)
{
setStateAndUi
(
CURRENT_STATE_ERROR
);
}
...
...
@@ -662,20 +630,16 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
@Override
public
void
onInfo
(
int
what
,
int
extra
)
{
Log
.
d
(
TAG
,
"onInfo what - "
+
what
+
" extra - "
+
extra
);
if
(
what
==
MediaPlayer
.
MEDIA_INFO_BUFFERING_START
)
{
BACKUP_PLAYING_BUFFERING_STATE
=
mCurrentState
;
setStateAndUi
(
CURRENT_STATE_PLAYING_BUFFERING_START
);
Log
.
d
(
TAG
,
"MEDIA_INFO_BUFFERING_START"
);
}
else
if
(
what
==
MediaPlayer
.
MEDIA_INFO_BUFFERING_END
)
{
if
(
BACKUP_PLAYING_BUFFERING_STATE
!=
-
1
)
{
setStateAndUi
(
BACKUP_PLAYING_BUFFERING_STATE
);
BACKUP_PLAYING_BUFFERING_STATE
=
-
1
;
}
Log
.
d
(
TAG
,
"MEDIA_INFO_BUFFERING_END"
);
}
else
if
(
what
==
IMediaPlayer
.
MEDIA_INFO_VIDEO_ROTATION_CHANGED
)
{
rotate
=
extra
;
Log
.
e
(
TAG
,
"MEDIA_INFO_VIDEO_ROTATION_CHANGED: "
+
rotate
);
if
(
textureView
!=
null
)
textureView
.
setRotation
(
rotate
);
}
...
...
@@ -718,9 +682,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
@Override
public
void
run
()
{
if
(
mCurrentState
==
CURRENT_STATE_PLAYING
||
mCurrentState
==
CURRENT_STATE_PAUSE
)
{
int
position
=
getCurrentPositionWhenPlaying
();
int
duration
=
getDuration
();
Log
.
v
(
TAG
,
"onProgressUpdate "
+
position
+
"/"
+
duration
+
" ["
+
this
.
hashCode
()
+
"] "
);
mHandler
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -758,7 +719,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
protected
void
setTextAndProgress
(
int
secProgress
)
{
int
position
=
getCurrentPositionWhenPlaying
();
int
duration
=
getDuration
();
// if duration == 0 (e.g. in HLS streams) avoids ArithmeticException
int
progress
=
position
*
100
/
(
duration
==
0
?
1
:
duration
);
setProgressAndTime
(
progress
,
secProgress
,
position
,
duration
);
}
...
...
@@ -780,34 +740,8 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
totalTimeTextView
.
setText
(
CommonUtil
.
stringForTime
(
0
));
}
protected
void
quitFullScreenGoToNormal
()
{
Log
.
d
(
TAG
,
"quitFullScreenGoToNormal ["
+
this
.
hashCode
()
+
"] "
);
if
(
videoAllCallBack
!=
null
&&
isCurrentMediaListener
())
{
videoAllCallBack
.
onQuitFullscreen
(
mUrl
,
mObjects
);
}
GSYVideoManager
.
instance
().
setDisplay
(
null
);
GSYVideoManager
.
instance
().
setListener
(
GSYVideoManager
.
instance
().
lastListener
());
GSYVideoManager
.
instance
().
setLastListener
(
null
);
GSYVideoManager
.
instance
().
setLastState
(
mCurrentState
);
//save state
if
(
GSYVideoManager
.
instance
().
listener
()
!=
null
)
GSYVideoManager
.
instance
().
listener
().
onBackFullscreen
();
if
(
mCurrentState
==
CURRENT_STATE_PAUSE
)
{
GSYVideoManager
.
instance
().
getMediaPlayer
().
seekTo
(
GSYVideoManager
.
instance
().
getMediaPlayer
().
getCurrentPosition
());
}
}
public
void
backFullscreen
()
{
Log
.
d
(
TAG
,
"quitFullscreen ["
+
this
.
hashCode
()
+
"] "
);
IF_FULLSCREEN_FROM_NORMAL
=
false
;
CLICK_QUIT_FULLSCREEN_TIME
=
System
.
currentTimeMillis
();
IF_RELEASE_WHEN_ON_PAUSE
=
false
;
quitFullScreenGoToNormal
();
}
public
static
void
releaseAllVideos
()
{
if
(
IF_RELEASE_WHEN_ON_PAUSE
)
{
Log
.
d
(
TAG
,
"releaseAllVideos"
);
if
(
GSYVideoManager
.
instance
().
listener
()
!=
null
)
{
GSYVideoManager
.
instance
().
listener
().
onCompletion
();
}
...
...
@@ -823,7 +757,6 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
public
void
release
()
{
if
(
isCurrentMediaListener
()
&&
(
System
.
currentTimeMillis
()
-
CLICK_QUIT_FULLSCREEN_TIME
)
>
FULL_SCREEN_NORMAL_DELAY
)
{
Log
.
d
(
TAG
,
"release ["
+
this
.
hashCode
()
+
"]"
);
releaseAllVideos
();
}
}
...
...
@@ -865,4 +798,12 @@ public abstract class GSYVideoPlayer extends FrameLayout implements View.OnClick
public
void
setIsTouchWiget
(
boolean
isTouchWiget
)
{
this
.
mIsTouchWiget
=
isTouchWiget
;
}
public
ImageView
getStartButton
()
{
return
startButton
;
}
public
ImageView
getFullscreenButton
()
{
return
fullscreenButton
;
}
}
\ No newline at end of file
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/utils/OrientationUtils.java
浏览文件 @
80421df8
...
...
@@ -9,6 +9,7 @@ import com.shuyu.gsyvideoplayer.GSYVideoPlayer;
import
com.shuyu.gsyvideoplayer.R
;
/**
* 处理屏幕旋转的的逻辑
* Created by shuyu on 2016/11/11.
*/
...
...
@@ -53,7 +54,7 @@ public class OrientationUtils {
if
(
mIsLand
>
0
)
{
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
;
activity
.
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
);
gsyVideoPlayer
.
fullscreenButton
.
setImageResource
(
R
.
drawable
.
video_enlarge
);
gsyVideoPlayer
.
getFullscreenButton
()
.
setImageResource
(
R
.
drawable
.
video_enlarge
);
mIsLand
=
0
;
mClick
=
false
;
}
...
...
@@ -73,7 +74,7 @@ public class OrientationUtils {
if
(!(
mIsLand
==
1
))
{
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
;
activity
.
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
);
gsyVideoPlayer
.
fullscreenButton
.
setImageResource
(
R
.
drawable
.
video_shrink
);
gsyVideoPlayer
.
getFullscreenButton
()
.
setImageResource
(
R
.
drawable
.
video_shrink
);
mIsLand
=
1
;
mClick
=
false
;
}
...
...
@@ -92,7 +93,7 @@ public class OrientationUtils {
}
else
if
(!(
mIsLand
==
2
))
{
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
;
activity
.
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_REVERSE_LANDSCAPE
);
gsyVideoPlayer
.
fullscreenButton
.
setImageResource
(
R
.
drawable
.
video_shrink
);
gsyVideoPlayer
.
getFullscreenButton
()
.
setImageResource
(
R
.
drawable
.
video_shrink
);
mIsLand
=
2
;
mClick
=
false
;
}
...
...
@@ -103,16 +104,17 @@ public class OrientationUtils {
}
public
void
resolveByClick
()
{
mClick
=
true
;
if
(
mIsLand
==
0
)
{
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
;
activity
.
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
);
gsyVideoPlayer
.
fullscreenButton
.
setImageResource
(
R
.
drawable
.
video_shrink
);
gsyVideoPlayer
.
getFullscreenButton
()
.
setImageResource
(
R
.
drawable
.
video_shrink
);
mIsLand
=
1
;
mClickLand
=
false
;
}
else
{
screenType
=
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
;
activity
.
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
);
gsyVideoPlayer
.
fullscreenButton
.
setImageResource
(
R
.
drawable
.
video_enlarge
);
gsyVideoPlayer
.
getFullscreenButton
()
.
setImageResource
(
R
.
drawable
.
video_enlarge
);
mIsLand
=
0
;
mClickPort
=
false
;
}
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/StandardGSYVideoPlayer.java
浏览文件 @
80421df8
...
...
@@ -35,21 +35,27 @@ import java.util.TimerTask;
public
class
StandardGSYVideoPlayer
extends
GSYVideoPlayer
{
protected
static
StandardVideoAllCallBack
JC_BURIED_POINT_STANDARD
;
protected
static
Timer
DISSMISS_CONTROL_VIEW_TIMER
;
public
ImageView
backButton
;
public
ProgressBar
bottomProgressBar
,
loadingProgressBar
;
public
TextView
titleTextView
;
public
ImageView
thumbImageView
;
public
ImageView
coverImageView
;
protected
ImageView
backButton
;
protected
ProgressBar
bottomProgressBar
,
loadingProgressBar
;
protected
TextView
titleTextView
;
protected
ImageView
thumbImageView
;
protected
ImageView
coverImageView
;
protected
Dialog
mBrightnessDialog
;
protected
TextView
mBrightnessDialogTv
;
protected
Dialog
mVolumeDialog
;
protected
ProgressBar
mDialogVolumeProgressBar
;
protected
StandardVideoAllCallBack
standardVideoAllCallBack
;
protected
DismissControlViewTimerTask
mDismissControlViewTimerTask
;
public
static
void
setJcBuriedPointStandard
(
StandardVideoAllCallBack
jcBuriedPointStandard
)
{
JC_BURIED_POINT_STANDARD
=
jcBuriedPointStandard
;
GSYVideoPlayer
.
setJcBuriedPoint
(
jcBuriedPointStandard
);
public
void
setStandardVideoAllCallBack
(
StandardVideoAllCallBack
standardVideoAllCallBack
)
{
this
.
standardVideoAllCallBack
=
standardVideoAllCallBack
;
setVideoAllCallBack
(
standardVideoAllCallBack
);
}
public
StandardGSYVideoPlayer
(
Context
context
)
{
...
...
@@ -177,21 +183,19 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
showWifiDialog
();
return
;
}
startPlayLo
c
ic
();
startPlayLo
g
ic
();
}
else
if
(
mCurrentState
==
CURRENT_STATE_AUTO_COMPLETE
)
{
onClickUiToggle
();
}
}
else
if
(
i
==
R
.
id
.
surface_container
)
{
if
(
JC_BURIED_POINT_STANDARD
!=
null
&&
isCurrentMediaListener
())
{
if
(
standardVideoAllCallBack
!=
null
&&
isCurrentMediaListener
())
{
if
(
mIfCurrentIsFullscreen
)
{
JC_BURIED_POINT_STANDARD
.
onClickBlankFullscreen
(
mUrl
,
mObjects
);
standardVideoAllCallBack
.
onClickBlankFullscreen
(
mUrl
,
mObjects
);
}
else
{
JC_BURIED_POINT_STANDARD
.
onClickBlank
(
mUrl
,
mObjects
);
standardVideoAllCallBack
.
onClickBlank
(
mUrl
,
mObjects
);
}
}
startDismissControlViewTimer
();
}
else
if
(
i
==
R
.
id
.
back
)
{
backFullscreen
();
}
}
...
...
@@ -204,7 +208,7 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
startPlayLo
c
ic
();
startPlayLo
g
ic
();
WIFI_TIP_DIALOG_SHOWED
=
true
;
}
});
...
...
@@ -217,9 +221,9 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
builder
.
create
().
show
();
}
public
void
startPlayLo
c
ic
()
{
if
(
JC_BURIED_POINT_STANDARD
!=
null
)
{
JC_BURIED_POINT_STANDARD
.
onClickStartThumb
(
mUrl
,
mObjects
);
public
void
startPlayLo
g
ic
()
{
if
(
standardVideoAllCallBack
!=
null
)
{
standardVideoAllCallBack
.
onClickStartThumb
(
mUrl
,
mObjects
);
}
prepareVideo
();
startDismissControlViewTimer
();
...
...
@@ -459,12 +463,6 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
}
}
protected
Dialog
mBrightnessDialog
;
protected
TextView
mBrightnessDialogTv
;
protected
Dialog
mVolumeDialog
;
protected
ProgressBar
mDialogVolumeProgressBar
;
@Override
protected
void
showVolumeDialog
(
float
deltaY
,
int
volumePercent
)
{
super
.
showVolumeDialog
(
deltaY
,
volumePercent
);
...
...
@@ -567,4 +565,12 @@ public class StandardGSYVideoPlayer extends GSYVideoPlayer {
}
}
}
public
TextView
getTitleTextView
()
{
return
titleTextView
;
}
public
ImageView
getBackButton
()
{
return
backButton
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录