Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ac13
GSYVideoPlayer
提交
57f68e73
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,发现更多精彩内容 >>
提交
57f68e73
编写于
9月 04, 2017
作者:
S
shuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
进度条预览的另类实现 (2017-09-04)
上级
3e04b3c3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
371 addition
and
2 deletion
+371
-2
app/src/main/java/com/example/gsyvideoplayer/WebDetailActivity.java
...in/java/com/example/gsyvideoplayer/WebDetailActivity.java
+2
-1
app/src/main/java/com/example/gsyvideoplayer/video/PreViewGSYVideoPlayer.java
...m/example/gsyvideoplayer/video/PreViewGSYVideoPlayer.java
+186
-0
app/src/main/res/layout/activity_web_detail.xml
app/src/main/res/layout/activity_web_detail.xml
+1
-1
app/src/main/res/layout/video_layout_preview.xml
app/src/main/res/layout/video_layout_preview.xml
+182
-0
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/WebDetailActivity.java
浏览文件 @
57f68e73
...
...
@@ -12,6 +12,7 @@ import android.widget.ImageView;
import
android.widget.RelativeLayout
;
import
com.example.gsyvideoplayer.listener.SampleListener
;
import
com.example.gsyvideoplayer.video.PreViewGSYVideoPlayer
;
import
com.example.gsyvideoplayer.view.ScrollWebView
;
import
com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
;
import
com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer
;
...
...
@@ -33,7 +34,7 @@ public class WebDetailActivity extends AppCompatActivity {
@BindView
(
R
.
id
.
scroll_webView
)
ScrollWebView
webView
;
@BindView
(
R
.
id
.
web_player
)
Normal
GSYVideoPlayer
webPlayer
;
PreView
GSYVideoPlayer
webPlayer
;
@BindView
(
R
.
id
.
web_top_layout
)
NestedScrollView
webTopLayout
;
@BindView
(
R
.
id
.
web_top_layout_video
)
...
...
app/src/main/java/com/example/gsyvideoplayer/video/PreViewGSYVideoPlayer.java
0 → 100644
浏览文件 @
57f68e73
package
com.example.gsyvideoplayer.video
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.SeekBar
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.request.RequestOptions
;
import
com.example.gsyvideoplayer.R
;
import
com.shuyu.gsyvideoplayer.GSYVideoManager
;
import
com.shuyu.gsyvideoplayer.utils.CommonUtil
;
import
com.shuyu.gsyvideoplayer.utils.Debuger
;
import
com.shuyu.gsyvideoplayer.video.NormalGSYVideoPlayer
;
import
com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer
;
/**
* 进度图小图预览的另类实现
* Created by shuyu on 2016/12/10.
*/
public
class
PreViewGSYVideoPlayer
extends
NormalGSYVideoPlayer
{
private
RelativeLayout
mPreviewLayout
;
private
ImageView
mPreView
;
//是否因为用户点击
private
boolean
mIsFromUser
;
//是否打开滑动预览
private
boolean
mOpenPreView
=
true
;
private
int
mPreProgress
=
-
2
;
/**
* 1.5.0开始加入,如果需要不同布局区分功能,需要重载
*/
public
PreViewGSYVideoPlayer
(
Context
context
,
Boolean
fullFlag
)
{
super
(
context
,
fullFlag
);
}
public
PreViewGSYVideoPlayer
(
Context
context
)
{
super
(
context
);
}
public
PreViewGSYVideoPlayer
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
@Override
protected
void
init
(
Context
context
)
{
super
.
init
(
context
);
initView
();
}
private
void
initView
()
{
mPreviewLayout
=
(
RelativeLayout
)
findViewById
(
R
.
id
.
preview_layout
);
mPreView
=
(
ImageView
)
findViewById
(
R
.
id
.
preview_image
);
}
@Override
public
int
getLayoutId
()
{
return
R
.
layout
.
video_layout_preview
;
}
@Override
protected
void
prepareVideo
()
{
super
.
prepareVideo
();
}
@Override
public
void
onProgressChanged
(
SeekBar
seekBar
,
final
int
progress
,
boolean
fromUser
)
{
super
.
onProgressChanged
(
seekBar
,
progress
,
fromUser
);
if
(
fromUser
&&
mOpenPreView
)
{
int
width
=
seekBar
.
getWidth
();
int
time
=
progress
*
getDuration
()
/
100
;
int
offset
=
(
int
)
(
width
-
(
getResources
().
getDimension
(
R
.
dimen
.
seek_bar_image
)
/
2
))
/
100
*
progress
;
Debuger
.
printfError
(
"***************** "
+
progress
);
Debuger
.
printfError
(
"***************** "
+
time
);
showPreView
(
mOriginUrl
,
time
);
RelativeLayout
.
LayoutParams
layoutParams
=
(
RelativeLayout
.
LayoutParams
)
mPreviewLayout
.
getLayoutParams
();
layoutParams
.
leftMargin
=
offset
;
//设置帧预览图的显示位置
mPreviewLayout
.
setLayoutParams
(
layoutParams
);
if
(
GSYVideoManager
.
instance
().
getMediaPlayer
()
!=
null
&&
mHadPlay
&&
(
mOpenPreView
))
{
mPreProgress
=
progress
;
}
}
}
@Override
public
void
onStartTrackingTouch
(
SeekBar
seekBar
)
{
super
.
onStartTrackingTouch
(
seekBar
);
if
(
mOpenPreView
)
{
mIsFromUser
=
true
;
mPreviewLayout
.
setVisibility
(
VISIBLE
);
mPreProgress
=
-
2
;
}
}
@Override
public
void
onStopTrackingTouch
(
SeekBar
seekBar
)
{
if
(
mOpenPreView
)
{
if
(
mPreProgress
>=
0
)
{
seekBar
.
setProgress
(
mPreProgress
);
}
super
.
onStopTrackingTouch
(
seekBar
);
mIsFromUser
=
false
;
mPreviewLayout
.
setVisibility
(
GONE
);
}
else
{
super
.
onStopTrackingTouch
(
seekBar
);
}
}
@Override
protected
void
setTextAndProgress
(
int
secProgress
)
{
if
(
mIsFromUser
)
{
return
;
}
super
.
setTextAndProgress
(
secProgress
);
}
@Override
public
GSYBaseVideoPlayer
startWindowFullscreen
(
Context
context
,
boolean
actionBar
,
boolean
statusBar
)
{
GSYBaseVideoPlayer
gsyBaseVideoPlayer
=
super
.
startWindowFullscreen
(
context
,
actionBar
,
statusBar
);
PreViewGSYVideoPlayer
customGSYVideoPlayer
=
(
PreViewGSYVideoPlayer
)
gsyBaseVideoPlayer
;
customGSYVideoPlayer
.
mOpenPreView
=
mOpenPreView
;
return
gsyBaseVideoPlayer
;
}
@Override
public
void
onPrepared
()
{
super
.
onPrepared
();
startDownFrame
(
mOriginUrl
);
}
public
boolean
isOpenPreView
()
{
return
mOpenPreView
;
}
/**
* 如果是需要进度条预览的设置打开,默认关闭
*/
public
void
setOpenPreView
(
boolean
localFile
)
{
this
.
mOpenPreView
=
localFile
;
}
private
void
showPreView
(
String
url
,
long
time
)
{
int
width
=
CommonUtil
.
dip2px
(
getContext
(),
150
);
int
height
=
CommonUtil
.
dip2px
(
getContext
(),
100
);
Glide
.
with
(
getContext
().
getApplicationContext
())
.
setDefaultRequestOptions
(
new
RequestOptions
()
//这里限制了只从缓存读取
.
onlyRetrieveFromCache
(
true
)
.
frame
(
1000
*
time
)
.
override
(
width
,
height
)
.
dontAnimate
()
.
centerCrop
())
.
load
(
url
)
.
into
(
mPreView
);
}
private
void
startDownFrame
(
String
url
)
{
for
(
int
i
=
1
;
i
<=
100
;
i
++)
{
int
time
=
i
*
getDuration
()
/
100
;
int
width
=
CommonUtil
.
dip2px
(
getContext
(),
150
);
int
height
=
CommonUtil
.
dip2px
(
getContext
(),
100
);
Glide
.
with
(
getContext
().
getApplicationContext
())
.
setDefaultRequestOptions
(
new
RequestOptions
()
.
frame
(
1000
*
time
)
.
override
(
width
,
height
)
.
centerCrop
())
.
load
(
url
).
preload
(
width
,
height
);
}
}
}
app/src/main/res/layout/activity_web_detail.xml
浏览文件 @
57f68e73
...
...
@@ -30,7 +30,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<com.
shuyu.gsyvideoplayer.video.Normal
GSYVideoPlayer
<com.
example.gsyvideoplayer.video.PreView
GSYVideoPlayer
android:id=
"@+id/web_player"
android:layout_width=
"match_parent"
android:layout_height=
"200dp"
/>
...
...
app/src/main/res/layout/video_layout_preview.xml
0 → 100644
浏览文件 @
57f68e73
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@android:color/black"
>
<RelativeLayout
android:id=
"@+id/surface_container"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center"
>
</RelativeLayout>
<RelativeLayout
android:id=
"@+id/thumb"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_alignParentBottom=
"true"
android:layout_alignParentEnd=
"true"
android:layout_alignParentLeft=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentTop=
"true"
android:background=
"#000000"
android:scaleType=
"fitCenter"
/>
<LinearLayout
android:id=
"@+id/layout_bottom"
android:layout_width=
"match_parent"
android:layout_height=
"40dp"
android:layout_alignParentBottom=
"true"
android:background=
"#99000000"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
android:visibility=
"invisible"
>
<TextView
android:id=
"@+id/current"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"16dp"
android:text=
"00:00"
android:textColor=
"#ffffff"
/>
<SeekBar
android:id=
"@+id/progress"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1.0"
android:background=
"@null"
android:max=
"100"
android:maxHeight=
"4dp"
android:minHeight=
"4dp"
android:paddingBottom=
"8dp"
android:paddingTop=
"8dp"
android:progressDrawable=
"@drawable/video_seek_progress"
android:thumb=
"@drawable/video_seek_thumb"
/>
<TextView
android:id=
"@+id/total"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginRight=
"16dp"
android:text=
"00:00"
android:textColor=
"#ffffff"
/>
<ImageView
android:id=
"@+id/fullscreen"
android:layout_width=
"wrap_content"
android:layout_height=
"fill_parent"
android:paddingRight=
"16dp"
android:scaleType=
"center"
android:src=
"@drawable/video_enlarge"
/>
</LinearLayout>
<ProgressBar
android:id=
"@+id/bottom_progressbar"
style=
"?android:attr/progressBarStyleHorizontal"
android:layout_width=
"match_parent"
android:layout_height=
"1.5dp"
android:layout_alignParentBottom=
"true"
android:max=
"100"
android:progressDrawable=
"@drawable/video_progress"
/>
<ImageView
android:id=
"@+id/back_tiny"
android:layout_width=
"24dp"
android:layout_height=
"24dp"
android:layout_marginLeft=
"6dp"
android:layout_marginTop=
"6dp"
android:visibility=
"gone"
/>
<ProgressBar
android:id=
"@+id/loading"
style=
"?android:attr/progressBarStyleLarge"
android:layout_width=
"28dp"
android:layout_height=
"28dp"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:visibility=
"invisible"
/>
<ImageView
android:id=
"@+id/start"
android:layout_width=
"60dp"
android:layout_height=
"60dp"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:layout_gravity=
"center_vertical"
android:src=
"@drawable/video_click_play_selector"
/>
<ImageView
android:id=
"@+id/small_close"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:paddingLeft=
"10dp"
android:paddingTop=
"10dp"
android:scaleType=
"centerInside"
android:src=
"@drawable/video_small_close"
android:visibility=
"gone"
/>
<ImageView
android:id=
"@+id/lock_screen"
android:layout_width=
"30dp"
android:layout_height=
"30dp"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"50dp"
android:scaleType=
"centerInside"
android:src=
"@drawable/unlock"
android:visibility=
"gone"
/>
<LinearLayout
android:id=
"@+id/layout_top"
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:layout_alignParentTop=
"true"
android:layout_toEndOf=
"@+id/back_tiny"
android:layout_toRightOf=
"@+id/back_tiny"
android:background=
"@drawable/video_title_bg"
android:gravity=
"center_vertical"
>
<ImageView
android:id=
"@+id/back"
android:layout_width=
"48dp"
android:layout_height=
"48dp"
android:paddingLeft=
"10dp"
android:scaleType=
"centerInside"
android:src=
"@drawable/video_back"
/>
<TextView
android:id=
"@+id/title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:paddingLeft=
"10dp"
android:textColor=
"@android:color/white"
android:textSize=
"18sp"
/>
</LinearLayout>
<RelativeLayout
android:id=
"@+id/preview_layout"
android:layout_width=
"@dimen/seek_bar_image"
android:layout_height=
"100dp"
android:layout_above=
"@+id/layout_bottom"
android:layout_alignParentBottom=
"true"
android:layout_marginBottom=
"30dp"
android:visibility=
"gone"
>
<ImageView
android:id=
"@+id/preview_image"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#000000"
/>
</RelativeLayout>
</RelativeLayout>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录