Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_26386469
GSYVideoPlayer
提交
7abe5476
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,发现更多精彩内容 >>
提交
7abe5476
编写于
12月 20, 2016
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.4.9 列表播放
上级
d7c1fdd4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
400 addition
and
1 deletion
+400
-1
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+4
-0
app/src/main/java/com/example/gsyvideoplayer/DetailListPlayer.java
...ain/java/com/example/gsyvideoplayer/DetailListPlayer.java
+196
-0
app/src/main/java/com/example/gsyvideoplayer/MainActivity.java
...rc/main/java/com/example/gsyvideoplayer/MainActivity.java
+5
-1
app/src/main/java/com/example/gsyvideoplayer/utils/JumpUtils.java
...main/java/com/example/gsyvideoplayer/utils/JumpUtils.java
+11
-0
app/src/main/res/layout/activity_deatil_list_player.xml
app/src/main/res/layout/activity_deatil_list_player.xml
+37
-0
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+7
-0
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/model/GSYVideoModel.java
...in/java/com/shuyu/gsyvideoplayer/model/GSYVideoModel.java
+32
-0
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/ListGSYVideoPlayer.java
...va/com/shuyu/gsyvideoplayer/video/ListGSYVideoPlayer.java
+108
-0
未找到文件。
app/src/main/AndroidManifest.xml
浏览文件 @
7abe5476
...
...
@@ -51,6 +51,10 @@
android:name=
".RecyclerView2Activity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".DetailListPlayer"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"portrait"
/>
</application>
</manifest>
\ No newline at end of file
app/src/main/java/com/example/gsyvideoplayer/DetailListPlayer.java
0 → 100644
浏览文件 @
7abe5476
package
com.example.gsyvideoplayer
;
import
android.content.pm.ActivityInfo
;
import
android.content.res.Configuration
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.support.v4.widget.NestedScrollView
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
com.example.gsyvideoplayer.listener.SampleListener
;
import
com.shuyu.gsyvideoplayer.GSYPreViewManager
;
import
com.shuyu.gsyvideoplayer.GSYVideoPlayer
;
import
com.shuyu.gsyvideoplayer.listener.LockClickListener
;
import
com.shuyu.gsyvideoplayer.model.GSYVideoModel
;
import
com.shuyu.gsyvideoplayer.utils.OrientationUtils
;
import
com.shuyu.gsyvideoplayer.video.ListGSYVideoPlayer
;
import
com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
;
import
java.util.ArrayList
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
/**
* Created by shuyu on 2016/12/20.
*/
public
class
DetailListPlayer
extends
AppCompatActivity
{
@BindView
(
R
.
id
.
post_detail_nested_scroll
)
NestedScrollView
postDetailNestedScroll
;
@BindView
(
R
.
id
.
detail_player
)
ListGSYVideoPlayer
detailPlayer
;
@BindView
(
R
.
id
.
activity_detail_player
)
RelativeLayout
activityDetailPlayer
;
private
boolean
isPlay
;
private
boolean
isPause
;
private
OrientationUtils
orientationUtils
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_deatil_list_player
);
ButterKnife
.
bind
(
this
);
//String url = "http://baobab.wd jcdn.com/14564977406580.mp4";
List
<
GSYVideoModel
>
urls
=
new
ArrayList
<>();
urls
.
add
(
new
GSYVideoModel
(
"http://baobab.wdjcdn.com/14564977406580.mp4"
,
"标题1"
));
urls
.
add
(
new
GSYVideoModel
(
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
,
"标题2"
));
urls
.
add
(
new
GSYVideoModel
(
"http://baobab.wdjcdn.com/14564977406580.mp4"
,
"标题3"
));
urls
.
add
(
new
GSYVideoModel
(
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
,
"标题4"
));
detailPlayer
.
setUp
(
urls
,
true
,
0
,
""
);
//增加封面
ImageView
imageView
=
new
ImageView
(
this
);
imageView
.
setScaleType
(
ImageView
.
ScaleType
.
CENTER_CROP
);
imageView
.
setImageResource
(
R
.
mipmap
.
xxx1
);
detailPlayer
.
setThumbImageView
(
imageView
);
resolveNormalVideoUI
();
//外部辅助的旋转,帮助全屏
orientationUtils
=
new
OrientationUtils
(
this
,
detailPlayer
);
//初始化不打开外部的旋转
orientationUtils
.
setEnable
(
false
);
detailPlayer
.
setIsTouchWiget
(
true
);
//关闭自动旋转
detailPlayer
.
setRotateViewAuto
(
false
);
detailPlayer
.
setLockLand
(
false
);
detailPlayer
.
setShowFullAnimation
(
false
);
detailPlayer
.
setNeedLockFull
(
true
);
detailPlayer
.
getFullscreenButton
().
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
//直接横屏
orientationUtils
.
resolveByClick
();
//第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar
detailPlayer
.
startWindowFullscreen
(
DetailListPlayer
.
this
,
true
,
true
);
}
});
detailPlayer
.
setStandardVideoAllCallBack
(
new
SampleListener
()
{
@Override
public
void
onPrepared
(
String
url
,
Object
...
objects
)
{
super
.
onPrepared
(
url
,
objects
);
//开始播放了才能旋转和全屏
orientationUtils
.
setEnable
(
true
);
isPlay
=
true
;
}
@Override
public
void
onAutoComplete
(
String
url
,
Object
...
objects
)
{
super
.
onAutoComplete
(
url
,
objects
);
}
@Override
public
void
onClickStartError
(
String
url
,
Object
...
objects
)
{
super
.
onClickStartError
(
url
,
objects
);
}
@Override
public
void
onQuitFullscreen
(
String
url
,
Object
...
objects
)
{
super
.
onQuitFullscreen
(
url
,
objects
);
if
(
orientationUtils
!=
null
)
{
orientationUtils
.
backToProtVideo
();
}
}
});
detailPlayer
.
setLockClickListener
(
new
LockClickListener
()
{
@Override
public
void
onClick
(
View
view
,
boolean
lock
)
{
if
(
orientationUtils
!=
null
)
{
//配合下方的onConfigurationChanged
orientationUtils
.
setEnable
(!
lock
);
}
}
});
}
@Override
public
void
onBackPressed
()
{
if
(
orientationUtils
!=
null
)
{
orientationUtils
.
backToProtVideo
();
}
if
(
StandardGSYVideoPlayer
.
backFromWindowFull
(
this
))
{
return
;
}
super
.
onBackPressed
();
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
isPause
=
true
;
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
isPause
=
false
;
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
GSYVideoPlayer
.
releaseAllVideos
();
GSYPreViewManager
.
instance
().
releaseMediaPlayer
();
if
(
orientationUtils
!=
null
)
orientationUtils
.
releaseListener
();
}
@Override
public
void
onConfigurationChanged
(
Configuration
newConfig
)
{
super
.
onConfigurationChanged
(
newConfig
);
//如果旋转了就全屏
if
(
isPlay
&&
!
isPause
)
{
if
(
newConfig
.
orientation
==
ActivityInfo
.
SCREEN_ORIENTATION_USER
)
{
if
(!
detailPlayer
.
isIfCurrentIsFullscreen
())
{
detailPlayer
.
startWindowFullscreen
(
DetailListPlayer
.
this
,
true
,
true
);
}
}
else
{
//新版本isIfCurrentIsFullscreen的标志位内部提前设置了,所以不会和手动点击冲突
if
(
detailPlayer
.
isIfCurrentIsFullscreen
())
{
StandardGSYVideoPlayer
.
backFromWindowFull
(
this
);
}
if
(
orientationUtils
!=
null
)
{
orientationUtils
.
setEnable
(
true
);
}
}
}
}
private
void
resolveNormalVideoUI
()
{
//增加title
detailPlayer
.
getTitleTextView
().
setVisibility
(
View
.
GONE
);
detailPlayer
.
getTitleTextView
().
setText
(
"测试视频"
);
detailPlayer
.
getBackButton
().
setVisibility
(
View
.
GONE
);
}
}
app/src/main/java/com/example/gsyvideoplayer/MainActivity.java
浏览文件 @
7abe5476
...
...
@@ -26,7 +26,7 @@ public class MainActivity extends AppCompatActivity {
ButterKnife
.
bind
(
this
);
}
@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_2
})
@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_2
,
R
.
id
.
list_detail_list
})
public
void
onClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
open_btn
:
...
...
@@ -48,6 +48,10 @@ public class MainActivity extends AppCompatActivity {
//支持全屏重力旋转的列表播放,滑动后不会被销毁
JumpUtils
.
goToDetailPlayer
(
this
);
break
;
case
R
.
id
.
list_detail_list
:
//支持全屏重力旋转的列表播放,滑动后不会被销毁
JumpUtils
.
goToDetailListPlayer
(
this
);
break
;
case
R
.
id
.
clear_cache
:
GSYVideoManager
.
clearAllDefaultCache
(
MainActivity
.
this
);
//String url = "http://baobab.wdjcdn.com/14564977406580.mp4";
...
...
app/src/main/java/com/example/gsyvideoplayer/utils/JumpUtils.java
浏览文件 @
7abe5476
...
...
@@ -7,6 +7,7 @@ import android.support.v4.app.ActivityOptionsCompat;
import
android.support.v4.util.Pair
;
import
android.view.View
;
import
com.example.gsyvideoplayer.DetailListPlayer
;
import
com.example.gsyvideoplayer.DetailPlayer
;
import
com.example.gsyvideoplayer.ListVideo2Activity
;
import
com.example.gsyvideoplayer.ListVideoActivity
;
...
...
@@ -82,4 +83,14 @@ public class JumpUtils {
Intent
intent
=
new
Intent
(
activity
,
DetailPlayer
.
class
);
activity
.
startActivity
(
intent
);
}
/**
* 跳转到详情播放
*
* @param activity
*/
public
static
void
goToDetailListPlayer
(
Activity
activity
)
{
Intent
intent
=
new
Intent
(
activity
,
DetailListPlayer
.
class
);
activity
.
startActivity
(
intent
);
}
}
app/src/main/res/layout/activity_deatil_list_player.xml
0 → 100644
浏览文件 @
7abe5476
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/activity_detail_player"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<android.support.v4.widget.NestedScrollView
android:id=
"@+id/post_detail_nested_scroll"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:fillViewport=
"true"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<View
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/post_media_height"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/detail_text"
android:textSize=
"16sp"
/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<com.shuyu.gsyvideoplayer.video.ListGSYVideoPlayer
android:id=
"@+id/detail_player"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/post_media_height"
/>
</RelativeLayout>
app/src/main/res/layout/activity_main.xml
浏览文件 @
7abe5476
...
...
@@ -49,6 +49,13 @@
android:layout_marginTop=
"20dp"
android:text=
"Detail Video2"
/>
<Button
android:id=
"@+id/list_detail_list"
android:layout_width=
"120dp"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:text=
"Detail List"
/>
<Button
android:id=
"@+id/clear_cache"
android:layout_width=
"120dp"
...
...
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/model/GSYVideoModel.java
0 → 100644
浏览文件 @
7abe5476
package
com.shuyu.gsyvideoplayer.model
;
/**
* Created by shuyu on 2016/12/20.
*/
public
class
GSYVideoModel
{
private
String
mUrl
;
private
String
mTitle
;
public
GSYVideoModel
(
String
url
,
String
title
)
{
mUrl
=
url
;
mTitle
=
title
;
}
public
String
getUrl
()
{
return
mUrl
;
}
public
void
setUrl
(
String
url
)
{
this
.
mUrl
=
url
;
}
public
String
getTitle
()
{
return
mTitle
;
}
public
void
setTitle
(
String
title
)
{
this
.
mTitle
=
title
;
}
}
gsyVideoPlayer/src/main/java/com/shuyu/gsyvideoplayer/video/ListGSYVideoPlayer.java
0 → 100644
浏览文件 @
7abe5476
package
com.shuyu.gsyvideoplayer.video
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.util.AttributeSet
;
import
com.shuyu.gsyvideoplayer.model.GSYVideoModel
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Created by shuyu on 2016/12/20.
*/
public
class
ListGSYVideoPlayer
extends
StandardGSYVideoPlayer
{
protected
List
<
GSYVideoModel
>
mUriList
=
new
ArrayList
<>();
protected
int
mPlayPosition
;
public
ListGSYVideoPlayer
(
Context
context
)
{
super
(
context
);
}
public
ListGSYVideoPlayer
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
/**
* 设置播放URL
*
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param objects object[0]目前为title
* @return
*/
public
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
boolean
cacheWithPlay
,
int
position
,
Object
...
objects
)
{
mUriList
=
url
;
mPlayPosition
=
position
;
GSYVideoModel
gsyVideoModel
=
url
.
get
(
position
);
boolean
set
=
setUp
(
gsyVideoModel
.
getUrl
(),
cacheWithPlay
,
objects
);
if
(!
TextUtils
.
isEmpty
(
gsyVideoModel
.
getTitle
()))
{
mTitleTextView
.
setText
(
gsyVideoModel
.
getTitle
());
}
return
set
;
}
/**
* 设置播放URL
*
* @param url 播放url
* @param cacheWithPlay 是否边播边缓存
* @param cachePath 缓存路径,如果是M3U8或者HLS,请设置为false
* @param objects object[0]目前为title
* @return
*/
public
boolean
setUp
(
List
<
GSYVideoModel
>
url
,
boolean
cacheWithPlay
,
int
position
,
File
cachePath
,
Object
...
objects
)
{
mUriList
=
url
;
mPlayPosition
=
position
;
GSYVideoModel
gsyVideoModel
=
url
.
get
(
position
);
boolean
set
=
setUp
(
gsyVideoModel
.
getUrl
(),
cacheWithPlay
,
cachePath
,
objects
);
if
(!
TextUtils
.
isEmpty
(
gsyVideoModel
.
getTitle
()))
{
mTitleTextView
.
setText
(
gsyVideoModel
.
getTitle
());
}
return
set
;
}
@Override
public
GSYBaseVideoPlayer
startWindowFullscreen
(
Context
context
,
boolean
actionBar
,
boolean
statusBar
)
{
GSYBaseVideoPlayer
gsyBaseVideoPlayer
=
super
.
startWindowFullscreen
(
context
,
actionBar
,
statusBar
);
if
(
gsyBaseVideoPlayer
!=
null
)
{
ListGSYVideoPlayer
listGSYVideoPlayer
=
(
ListGSYVideoPlayer
)
gsyBaseVideoPlayer
;
listGSYVideoPlayer
.
mPlayPosition
=
mPlayPosition
;
listGSYVideoPlayer
.
mUriList
=
mUriList
;
GSYVideoModel
gsyVideoModel
=
mUriList
.
get
(
mPlayPosition
);
if
(!
TextUtils
.
isEmpty
(
gsyVideoModel
.
getTitle
()))
{
listGSYVideoPlayer
.
mTitleTextView
.
setText
(
gsyVideoModel
.
getTitle
());
}
}
return
gsyBaseVideoPlayer
;
}
@Override
public
void
onCompletion
()
{
if
(
mPlayPosition
<
(
mUriList
.
size
()
-
1
))
{
return
;
}
super
.
onCompletion
();
}
@Override
public
void
onAutoCompletion
()
{
if
(
mPlayPosition
<
(
mUriList
.
size
()
-
1
))
{
mPlayPosition
++;
GSYVideoModel
gsyVideoModel
=
mUriList
.
get
(
mPlayPosition
);
setUp
(
gsyVideoModel
.
getUrl
(),
mCache
,
mCachePath
,
mObjects
);
if
(!
TextUtils
.
isEmpty
(
gsyVideoModel
.
getTitle
()))
{
mTitleTextView
.
setText
(
gsyVideoModel
.
getTitle
());
}
startPlayLogic
();
return
;
}
super
.
onAutoCompletion
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录