Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
GSYVideoPlayer
提交
44f39e7e
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 搜索 >>
提交
44f39e7e
编写于
4月 02, 2020
作者:
G
guoshuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持 Android 10 上的本地文件播放
上级
05f7e469
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
86 addition
and
11 deletion
+86
-11
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
...rc/main/java/com/example/gsyvideoplayer/DetailPlayer.java
+64
-8
app/src/main/res/layout/activity_detail_player.xml
app/src/main/res/layout/activity_detail_player.xml
+8
-0
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/player/IjkPlayerManager.java
...ava/com/shuyu/gsyvideoplayer/player/IjkPlayerManager.java
+14
-3
未找到文件。
app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
浏览文件 @
44f39e7e
package
com.example.gsyvideoplayer
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.res.Configuration
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
androidx.annotation.Nullable
;
import
androidx.core.widget.NestedScrollView
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.os.ParcelFileDescriptor
;
import
android.provider.DocumentsContract
;
import
android.provider.MediaStore
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
...
...
@@ -24,6 +34,8 @@ import com.shuyu.gsyvideoplayer.utils.Debuger;
import
com.shuyu.gsyvideoplayer.utils.OrientationUtils
;
import
java.io.FileDescriptor
;
import
java.io.FileNotFoundException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -48,6 +60,10 @@ public class DetailPlayer extends AppCompatActivity {
@BindView
(
R
.
id
.
activity_detail_player
)
RelativeLayout
activityDetailPlayer
;
@BindView
(
R
.
id
.
open_btn
)
Button
button
;
private
boolean
isPlay
;
private
boolean
isPause
;
...
...
@@ -59,7 +75,7 @@ public class DetailPlayer extends AppCompatActivity {
setContentView
(
R
.
layout
.
activity_detail_player
);
ButterKnife
.
bind
(
this
);
String
url
=
getUrl
();
String
url
=
getUrl
();
//detailPlayer.setUp(url, false, null, "测试视频");
//detailPlayer.setLooping(true);
...
...
@@ -128,7 +144,7 @@ public class DetailPlayer extends AppCompatActivity {
isPlay
=
true
;
//设置 seek 的临近帧。
if
(
detailPlayer
.
getGSYVideoManager
().
getPlayer
()
instanceof
Exo2PlayerManager
)
{
if
(
detailPlayer
.
getGSYVideoManager
().
getPlayer
()
instanceof
Exo2PlayerManager
)
{
((
Exo2PlayerManager
)
detailPlayer
.
getGSYVideoManager
().
getPlayer
()).
setSeekParameter
(
SeekParameters
.
NEXT_SYNC
);
Debuger
.
printfError
(
"***** setSeekParameter **** "
);
}
...
...
@@ -188,6 +204,13 @@ public class DetailPlayer extends AppCompatActivity {
detailPlayer
.
startWindowFullscreen
(
DetailPlayer
.
this
,
true
,
true
);
}
});
button
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
fileSearch
();
}
});
}
@Override
...
...
@@ -230,7 +253,6 @@ public class DetailPlayer extends AppCompatActivity {
}
@Override
public
void
onConfigurationChanged
(
Configuration
newConfig
)
{
super
.
onConfigurationChanged
(
newConfig
);
...
...
@@ -249,19 +271,17 @@ public class DetailPlayer extends AppCompatActivity {
private
GSYVideoPlayer
getCurPlay
()
{
if
(
detailPlayer
.
getFullWindowPlayer
()
!=
null
)
{
return
detailPlayer
.
getFullWindowPlayer
();
return
detailPlayer
.
getFullWindowPlayer
();
}
return
detailPlayer
;
}
private
String
getUrl
()
{
//String url = "android.resource://" + getPackageName() + "/" + R.raw.test;
//注意,用ijk模式播放raw视频,这个必须打开
//
GSYVideoManager.instance().enableRawPlay(getApplicationContext());
GSYVideoManager
.
instance
().
enableRawPlay
(
getApplicationContext
());
///exo raw 支持
//String url = RawResourceDataSource.buildRawResourceUri(R.raw.test).toString();
...
...
@@ -284,7 +304,7 @@ public class DetailPlayer extends AppCompatActivity {
//String url = "http://video.7k.cn/app_video/20171202/6c8cf3ea/v.m3u8.mp4";
//String url = "http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8";
String
url
=
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
;
String
url
=
"http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"
;
//ssl error
//String url = "https://file.shftz.cn:8443/filesystem/download/10/2019/3/26/ce2c7c66-e9eb-42be-adf6-f9008385ea8c.mov/play";
//String url = "https://us-4.wl-cdn.com/hls/20200225/fde4f8ef394731f38d68fe6d601cfd56/index.m3u8";
...
...
@@ -313,4 +333,40 @@ public class DetailPlayer extends AppCompatActivity {
//String url = "https://zh-files.oss-cn-qingdao.aliyuncs.com/20170808223928mJ1P3n57.mp4";//90度
return
url
;
}
private
static
final
int
READ_REQUEST_CODE
=
42
;
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
data
==
null
||
resultCode
!=
Activity
.
RESULT_OK
)
return
;
if
(
requestCode
==
READ_REQUEST_CODE
)
{
getPathForSearch
(
data
.
getData
());
}
}
private
void
getPathForSearch
(
Uri
uri
)
{
String
[]
selectionArgs
=
new
String
[]{
DocumentsContract
.
getDocumentId
(
uri
).
split
(
":"
)[
1
]};
Cursor
cursor
=
getContentResolver
().
query
(
MediaStore
.
Video
.
Media
.
EXTERNAL_CONTENT_URI
,
null
,
MediaStore
.
Images
.
Media
.
_ID
+
"=?"
,
selectionArgs
,
null
);
if
(
null
!=
cursor
)
{
if
(
cursor
.
moveToFirst
())
{
int
index
=
cursor
.
getColumnIndex
(
MediaStore
.
Video
.
Media
.
DATA
);
if
(
index
>
-
1
)
{
detailPlayer
.
setUp
(
uri
.
toString
(),
false
,
"File"
);
detailPlayer
.
startPlayLogic
();
}
}
cursor
.
close
();
}
}
protected
void
fileSearch
()
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_OPEN_DOCUMENT
);
intent
.
addCategory
(
Intent
.
CATEGORY_OPENABLE
);
intent
.
setType
(
"video/*"
);
startActivityForResult
(
intent
,
READ_REQUEST_CODE
);
}
}
app/src/main/res/layout/activity_detail_player.xml
浏览文件 @
44f39e7e
...
...
@@ -34,4 +34,12 @@
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/post_media_height"
/>
<Button
android:id=
"@+id/open_btn"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/detail_player"
android:layout_margin=
"10dp"
android:text=
"open"
/>
</RelativeLayout>
gsyVideoPlayer-java/src/main/java/com/shuyu/gsyvideoplayer/player/IjkPlayerManager.java
浏览文件 @
44f39e7e
...
...
@@ -6,6 +6,7 @@ import android.media.AudioManager;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Message
;
import
android.os.ParcelFileDescriptor
;
import
android.text.TextUtils
;
import
android.view.Surface
;
...
...
@@ -16,6 +17,7 @@ import com.shuyu.gsyvideoplayer.utils.Debuger;
import
com.shuyu.gsyvideoplayer.utils.GSYVideoType
;
import
com.shuyu.gsyvideoplayer.utils.RawDataSourceProvider
;
import
java.io.FileDescriptor
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -25,14 +27,14 @@ import tv.danmaku.ijk.media.player.IjkLibLoader;
import
tv.danmaku.ijk.media.player.IjkMediaPlayer
;
/**
IJKPLayer
Created by guoshuyu on 2018/1/11.
*
IJKPLayer
*
Created by guoshuyu on 2018/1/11.
*/
public
class
IjkPlayerManager
extends
BasePlayerManager
{
/**
log level
*
log level
*/
private
static
int
logLevel
=
IjkMediaPlayer
.
IJK_LOG_DEFAULT
;
...
...
@@ -82,6 +84,15 @@ public class IjkPlayerManager extends BasePlayerManager {
if
(
uri
.
getScheme
().
equals
(
ContentResolver
.
SCHEME_ANDROID_RESOURCE
))
{
RawDataSourceProvider
rawDataSourceProvider
=
RawDataSourceProvider
.
create
(
context
,
uri
);
mediaPlayer
.
setDataSource
(
rawDataSourceProvider
);
}
else
if
(
uri
.
getScheme
().
equals
(
ContentResolver
.
SCHEME_CONTENT
))
{
ParcelFileDescriptor
descriptor
;
try
{
descriptor
=
context
.
getContentResolver
().
openFileDescriptor
(
uri
,
"r"
);
FileDescriptor
fileDescriptor
=
descriptor
.
getFileDescriptor
();
mediaPlayer
.
setDataSource
(
fileDescriptor
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
else
{
mediaPlayer
.
setDataSource
(
url
,
gsyModel
.
getMapHeadData
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录