Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ac13
GSYVideoPlayer
提交
aabfa204
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,发现更多精彩内容 >>
提交
aabfa204
编写于
4月 13, 2018
作者:
G
guoshuyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
简单实现弹幕获取
上级
77af0b89
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
116 addition
and
2 deletion
+116
-2
app/build.gradle
app/build.gradle
+4
-0
app/src/main/java/com/example/gsyvideoplayer/DanmkuVideoActivity.java
.../java/com/example/gsyvideoplayer/DanmkuVideoActivity.java
+57
-0
app/src/main/java/com/example/gsyvideoplayer/video/DanmakuVideoPlayer.java
.../com/example/gsyvideoplayer/video/DanmakuVideoPlayer.java
+55
-2
未找到文件。
app/build.gradle
浏览文件 @
aabfa204
...
...
@@ -65,6 +65,10 @@ dependencies {
implementation
androidDependencies
.
design
implementation
project
(
':gsyVideoPlayer'
)
implementation
'com.squareup.okhttp3:okhttp:3.2.0'
implementation
'com.zhy:okhttputils:2.6.2'
//jcenter
//implementation "com.shuyu:GSYVideoPlayer:$gsyVideoVersion"
...
...
app/src/main/java/com/example/gsyvideoplayer/DanmkuVideoActivity.java
浏览文件 @
aabfa204
...
...
@@ -3,8 +3,11 @@ package com.example.gsyvideoplayer;
import
android.content.pm.ActivityInfo
;
import
android.content.res.Configuration
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.support.v4.widget.NestedScrollView
;
import
android.support.v7.app.AppCompatActivity
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
...
...
@@ -16,9 +19,20 @@ import com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer;
import
com.shuyu.gsyvideoplayer.listener.LockClickListener
;
import
com.shuyu.gsyvideoplayer.utils.OrientationUtils
;
import
com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
;
import
com.zhy.http.okhttp.OkHttpUtils
;
import
com.zhy.http.okhttp.callback.FileCallBack
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
okhttp3.Call
;
/**
* Created by guoshuyu on 2017/2/19.
...
...
@@ -39,6 +53,7 @@ public class DanmkuVideoActivity extends AppCompatActivity {
private
boolean
isPlay
;
private
boolean
isPause
;
private
boolean
isDestory
;
private
OrientationUtils
orientationUtils
;
...
...
@@ -98,6 +113,7 @@ public class DanmkuVideoActivity extends AppCompatActivity {
//开始播放了才能旋转和全屏
orientationUtils
.
setEnable
(
true
);
isPlay
=
true
;
getDanmu
();
}
@Override
...
...
@@ -168,6 +184,8 @@ public class DanmkuVideoActivity extends AppCompatActivity {
//GSYPreViewManager.instance().releaseMediaPlayer();
if
(
orientationUtils
!=
null
)
orientationUtils
.
releaseListener
();
isDestory
=
true
;
}
...
...
@@ -181,6 +199,45 @@ public class DanmkuVideoActivity extends AppCompatActivity {
}
private
void
getDanmu
()
{
OkHttpUtils
.
get
().
url
(
TextUtils
.
concat
(
"http://xingyuyou.com/Public/app/barragefile/"
,
"608"
,
"barrage.txt"
).
toString
())
.
build
()
.
execute
(
new
FileCallBack
(
getApplication
().
getCacheDir
().
getAbsolutePath
(),
"barrage.txt"
)
//
{
@Override
public
void
onError
(
Call
call
,
Exception
e
,
int
id
)
{
}
@Override
public
void
onResponse
(
File
response
,
int
id
)
{
try
{
InputStream
instream
=
new
FileInputStream
(
response
);
InputStreamReader
inputreader
=
new
InputStreamReader
(
instream
);
BufferedReader
buffreader
=
new
BufferedReader
(
inputreader
);
String
line
;
StringBuilder
sb1
=
new
StringBuilder
();
sb1
.
append
(
"<i>"
);
//分行读取
while
((
line
=
buffreader
.
readLine
())
!=
null
)
{
sb1
.
append
(
line
);
}
sb1
.
append
(
"</i>"
);
Log
.
e
(
"3333333"
,
sb1
.
toString
());
instream
.
close
();
if
(!
isDestory
)
{
((
DanmakuVideoPlayer
)
danmakuVideoPlayer
.
getCurrentPlayer
()).
setDanmaKuStream
(
response
);
}
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
Log
.
d
(
"TestFile"
,
"The File doesn't not exist."
);
}
catch
(
IOException
e
)
{
Log
.
d
(
"TestFile"
,
e
.
getMessage
());
}
}
});
}
private
void
resolveNormalVideoUI
()
{
//增加title
danmakuVideoPlayer
.
getTitleTextView
().
setVisibility
(
View
.
GONE
);
...
...
app/src/main/java/com/example/gsyvideoplayer/video/DanmakuVideoPlayer.java
浏览文件 @
aabfa204
...
...
@@ -3,6 +3,7 @@ package com.example.gsyvideoplayer.video;
import
android.content.Context
;
import
android.graphics.Color
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.TextView
;
...
...
@@ -15,7 +16,13 @@ import com.shuyu.gsyvideoplayer.utils.Debuger;
import
com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer
;
import
com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.util.HashMap
;
import
master.flame.danmaku.controller.IDanmakuView
;
...
...
@@ -55,6 +62,8 @@ public class DanmakuVideoPlayer extends StandardGSYVideoPlayer {
private
boolean
mDanmaKuShow
=
true
;
private
File
mIs
;
public
DanmakuVideoPlayer
(
Context
context
,
Boolean
fullFlag
)
{
super
(
context
,
fullFlag
);
}
...
...
@@ -145,6 +154,12 @@ public class DanmakuVideoPlayer extends StandardGSYVideoPlayer {
}
}
@Override
protected
void
cloneParams
(
GSYBaseVideoPlayer
from
,
GSYBaseVideoPlayer
to
)
{
((
DanmakuVideoPlayer
)
to
).
mIs
=
((
DanmakuVideoPlayer
)
from
).
mIs
;
super
.
cloneParams
(
from
,
to
);
}
/**
* 处理播放器在全屏切换时,弹幕显示的逻辑
* 需要格外注意的是,因为全屏和小屏,是切换了播放器,所以需要同步之间的弹幕状态
...
...
@@ -181,6 +196,13 @@ public class DanmakuVideoPlayer extends StandardGSYVideoPlayer {
}
}
public
void
setDanmaKuStream
(
File
is
)
{
mIs
=
is
;
if
(!
getDanmakuView
().
isPrepared
())
{
onPrepareDanmaku
((
DanmakuVideoPlayer
)
getCurrentPlayer
());
}
}
private
void
initDanmaku
()
{
// 设置最大显示行数
...
...
@@ -199,7 +221,9 @@ public class DanmakuVideoPlayer extends StandardGSYVideoPlayer {
.
preventOverlapping
(
overlappingEnablePair
);
if
(
mDanmakuView
!=
null
)
{
//todo 替换成你的数据流
mParser
=
createParser
(
this
.
getResources
().
openRawResource
(
R
.
raw
.
comments
));
if
(
mIs
!=
null
)
{
mParser
=
createParser
(
getIsStream
(
mIs
));
}
mDanmakuView
.
setCallback
(
new
master
.
flame
.
danmaku
.
controller
.
DrawHandler
.
Callback
()
{
@Override
public
void
updateTimer
(
DanmakuTimer
timer
)
{
...
...
@@ -230,6 +254,30 @@ public class DanmakuVideoPlayer extends StandardGSYVideoPlayer {
}
}
private
InputStream
getIsStream
(
File
file
)
{
try
{
InputStream
instream
=
new
FileInputStream
(
file
);
InputStreamReader
inputreader
=
new
InputStreamReader
(
instream
);
BufferedReader
buffreader
=
new
BufferedReader
(
inputreader
);
String
line
;
StringBuilder
sb1
=
new
StringBuilder
();
sb1
.
append
(
"<i>"
);
//分行读取
while
((
line
=
buffreader
.
readLine
())
!=
null
)
{
sb1
.
append
(
line
);
}
sb1
.
append
(
"</i>"
);
Log
.
e
(
"3333333"
,
sb1
.
toString
());
instream
.
close
();
return
new
ByteArrayInputStream
(
sb1
.
toString
().
getBytes
());
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
Log
.
d
(
"TestFile"
,
"The File doesn't not exist."
);
}
catch
(
IOException
e
)
{
Log
.
d
(
"TestFile"
,
e
.
getMessage
());
}
return
null
;
}
/**
* 弹幕的显示与关闭
*/
...
...
@@ -255,7 +303,7 @@ public class DanmakuVideoPlayer extends StandardGSYVideoPlayer {
* 开始播放弹幕
*/
private
void
onPrepareDanmaku
(
DanmakuVideoPlayer
gsyVideoPlayer
)
{
if
(
gsyVideoPlayer
.
getDanmakuView
()
!=
null
&&
!
gsyVideoPlayer
.
getDanmakuView
().
isPrepared
())
{
if
(
gsyVideoPlayer
.
getDanmakuView
()
!=
null
&&
!
gsyVideoPlayer
.
getDanmakuView
().
isPrepared
()
&&
gsyVideoPlayer
.
getParser
()
!=
null
)
{
gsyVideoPlayer
.
getDanmakuView
().
prepare
(
gsyVideoPlayer
.
getParser
(),
gsyVideoPlayer
.
getDanmakuContext
());
}
...
...
@@ -314,6 +362,11 @@ public class DanmakuVideoPlayer extends StandardGSYVideoPlayer {
}
public
BaseDanmakuParser
getParser
()
{
if
(
mParser
==
null
)
{
if
(
mIs
!=
null
)
{
mParser
=
createParser
(
getIsStream
(
mIs
));
}
}
return
mParser
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录