Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ac13
GSYVideoPlayer
提交
18576d6c
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,发现更多精彩内容 >>
提交
18576d6c
编写于
11月 28, 2019
作者:
G
guoshuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化 ijk 模式的视频尺寸计算
上级
d9e82c56
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
16 deletion
+24
-16
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
...rc/main/java/com/example/gsyvideoplayer/DetailPlayer.java
+4
-3
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/MeasureHelper.java
...in/java/com/shuyu/gsyvideoplayer/utils/MeasureHelper.java
+20
-13
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
浏览文件 @
18576d6c
...
...
@@ -254,12 +254,12 @@ public class DetailPlayer extends AppCompatActivity {
private
String
getUrl
()
{
//
/
String url = "android.resource://" + getPackageName() + "/" + R.raw.test1;
//String url = "android.resource://" + getPackageName() + "/" + R.raw.test1;
//注意,用ijk模式播放raw视频,这个必须打开
//
/
GSYVideoManager.instance().enableRawPlay(getApplicationContext());
//GSYVideoManager.instance().enableRawPlay(getApplicationContext());
///exo raw 支持
//
/
String url = RawResourceDataSource.buildRawResourceUri(R.raw.test).toString();
//String url = RawResourceDataSource.buildRawResourceUri(R.raw.test).toString();
//断网自动重新链接,url前接上ijkhttphook:
//String url = "ijkhttphook:https://res.exexm.com/cw_145225549855002";
...
...
@@ -302,6 +302,7 @@ public class DetailPlayer extends AppCompatActivity {
//String url = "http://hls.ciguang.tv/hdtv/video.m3u8";
//String url = "https://res.exexm.com/cw_145225549855002";
//String url = "http://storage.gzstv.net/uploads/media/huangmeiyan/jr05-09.mp4";//mepg
//String url = "https://zh-files.oss-cn-qingdao.aliyuncs.com/20170808223928mJ1P3n57.mp4";//90度
return
url
;
}
}
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/utils/MeasureHelper.java
浏览文件 @
18576d6c
...
...
@@ -87,12 +87,19 @@ public final class MeasureHelper {
heightMeasureSpec
=
tempSpec
;
}
int
width
=
View
.
getDefaultSize
(
mVideoWidth
,
widthMeasureSpec
);
int
realWidth
=
mVideoWidth
;
if
(
mVideoSarNum
!=
0
&&
mVideoSarDen
!=
0
)
{
double
pixelWidthHeightRatio
=
mVideoSarNum
/
(
mVideoSarDen
/
1.0
);
realWidth
=
(
int
)
(
pixelWidthHeightRatio
*
mVideoWidth
);
}
int
width
=
View
.
getDefaultSize
(
realWidth
,
widthMeasureSpec
);
int
height
=
View
.
getDefaultSize
(
mVideoHeight
,
heightMeasureSpec
);
if
(
mCurrentAspectRatio
==
GSYVideoType
.
SCREEN_MATCH_FULL
)
{
width
=
widthMeasureSpec
;
height
=
heightMeasureSpec
;
}
else
if
(
mVideo
Width
>
0
&&
mVideoHeight
>
0
)
{
}
else
if
(
real
Width
>
0
&&
mVideoHeight
>
0
)
{
int
widthSpecMode
=
View
.
MeasureSpec
.
getMode
(
widthMeasureSpec
);
int
widthSpecSize
=
View
.
MeasureSpec
.
getSize
(
widthMeasureSpec
);
int
heightSpecMode
=
View
.
MeasureSpec
.
getMode
(
heightMeasureSpec
);
...
...
@@ -126,7 +133,7 @@ public final class MeasureHelper {
case
GSYVideoType
.
SCREEN_TYPE_FULL
:
//case GSYVideoType.AR_ASPECT_WRAP_CONTENT:
default
:
displayAspectRatio
=
(
float
)
mVideo
Width
/
(
float
)
mVideoHeight
;
displayAspectRatio
=
(
float
)
real
Width
/
(
float
)
mVideoHeight
;
if
(
mVideoSarNum
>
0
&&
mVideoSarDen
>
0
)
displayAspectRatio
=
displayAspectRatio
*
mVideoSarNum
/
mVideoSarDen
;
break
;
...
...
@@ -164,7 +171,7 @@ public final class MeasureHelper {
default
:
if
(
shouldBeWider
)
{
// too wide, fix width
width
=
Math
.
min
(
mVideo
Width
,
widthSpecSize
);
width
=
Math
.
min
(
real
Width
,
widthSpecSize
);
height
=
(
int
)
(
width
/
displayAspectRatio
);
}
else
{
// too high, fix height
...
...
@@ -179,17 +186,17 @@ public final class MeasureHelper {
height
=
heightSpecSize
;
// for compatibility, we adjust size based on aspect ratio
if
(
mVideo
Width
*
height
<
width
*
mVideoHeight
)
{
if
(
real
Width
*
height
<
width
*
mVideoHeight
)
{
//Log.i("@@@", "image too wide, correcting");
width
=
height
*
mVideo
Width
/
mVideoHeight
;
}
else
if
(
mVideo
Width
*
height
>
width
*
mVideoHeight
)
{
width
=
height
*
real
Width
/
mVideoHeight
;
}
else
if
(
real
Width
*
height
>
width
*
mVideoHeight
)
{
//Log.i("@@@", "image too tall, correcting");
height
=
width
*
mVideoHeight
/
mVideo
Width
;
height
=
width
*
mVideoHeight
/
real
Width
;
}
}
else
if
(
widthSpecMode
==
View
.
MeasureSpec
.
EXACTLY
)
{
// only the width is fixed, adjust the height to match aspect ratio if possible
width
=
widthSpecSize
;
height
=
width
*
mVideoHeight
/
mVideo
Width
;
height
=
width
*
mVideoHeight
/
real
Width
;
if
(
heightSpecMode
==
View
.
MeasureSpec
.
AT_MOST
&&
height
>
heightSpecSize
)
{
// couldn't match aspect ratio within the constraints
height
=
heightSpecSize
;
...
...
@@ -197,24 +204,24 @@ public final class MeasureHelper {
}
else
if
(
heightSpecMode
==
View
.
MeasureSpec
.
EXACTLY
)
{
// only the height is fixed, adjust the width to match aspect ratio if possible
height
=
heightSpecSize
;
width
=
height
*
mVideo
Width
/
mVideoHeight
;
width
=
height
*
real
Width
/
mVideoHeight
;
if
(
widthSpecMode
==
View
.
MeasureSpec
.
AT_MOST
&&
width
>
widthSpecSize
)
{
// couldn't match aspect ratio within the constraints
width
=
widthSpecSize
;
}
}
else
{
// neither the width nor the height are fixed, try to use actual video size
width
=
mVideo
Width
;
width
=
real
Width
;
height
=
mVideoHeight
;
if
(
heightSpecMode
==
View
.
MeasureSpec
.
AT_MOST
&&
height
>
heightSpecSize
)
{
// too tall, decrease both width and height
height
=
heightSpecSize
;
width
=
height
*
mVideo
Width
/
mVideoHeight
;
width
=
height
*
real
Width
/
mVideoHeight
;
}
if
(
widthSpecMode
==
View
.
MeasureSpec
.
AT_MOST
&&
width
>
widthSpecSize
)
{
// too wide, decrease both width and height
width
=
widthSpecSize
;
height
=
width
*
mVideoHeight
/
mVideo
Width
;
height
=
width
*
mVideoHeight
/
real
Width
;
}
}
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录