Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
gz_video_player
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
gz_video_player
Commits
c24d98cd
提交
c24d98cd
authored
9月 15, 2023
作者:
jungleiOS
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
loading 组件背景设为黑色,挡住亮度组件初始化时闪现问题,退出播放器恢复亮度
上级
2abe3aa0
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
69 行增加
和
21 行删除
+69
-21
main.dart
example/lib/main.dart
+55
-16
video.dart
lib/video.dart
+10
-4
video_loading_view.dart
lib/widget/video_loading_view.dart
+4
-1
没有找到文件。
example/lib/main.dart
浏览文件 @
c24d98cd
...
...
@@ -10,19 +10,60 @@ import 'package:gz_video_player/video_style.dart';
import
'package:gz_video_player/video_subtitles.dart'
;
import
'package:gz_video_player/video_top_bar_style.dart'
;
void
main
(
)
{
runApp
(
const
MyApp
());
}
class
MyApp
extends
State
ful
Widget
{
class
MyApp
extends
State
less
Widget
{
const
MyApp
({
super
.
key
});
@override
State
<
MyApp
>
createState
()
=>
_MyAppState
();
Widget
build
(
BuildContext
context
)
{
return
const
MaterialApp
(
home:
HomePage
(),
);
}
}
class
HomePage
extends
StatelessWidget
{
const
HomePage
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'HomePage'
),
),
body:
Center
(
child:
GestureDetector
(
onTap:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
BuildContext
context
)
{
return
const
VideoPlayerPage
();
}),
);
},
child:
Container
(
width:
120.0
,
height:
30.0
,
color:
Colors
.
blue
,
alignment:
Alignment
.
center
,
child:
const
Text
(
'to video player'
),
),
),
),
);
}
}
class
VideoPlayerPage
extends
StatefulWidget
{
const
VideoPlayerPage
({
super
.
key
});
@override
State
<
VideoPlayerPage
>
createState
()
=>
_VideoPlayerPageState
();
}
class
_
MyAppState
extends
State
<
MyApp
>
{
class
_
VideoPlayerPageState
extends
State
<
VideoPlayerPage
>
{
// String videoUrl = "https://www.runoob.com/try/demo_source/movie.mp4";
// String videoUrl = "https://yun.zxziyuan-yun.com/20180221/4C6ivf8O/index.m3u8";
...
...
@@ -65,15 +106,14 @@ class _MyAppState extends State<MyApp> {
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
home:
Scaffold
(
appBar:
!
_isFullscreen
?
AppBar
(
title:
const
Text
(
'video player'
))
:
null
,
return
Scaffold
(
appBar:
!
_isFullscreen
?
AppBar
(
title:
const
Text
(
'video player'
))
:
null
,
body:
Column
(
children:
<
Widget
>[
videoUrl
!=
""
?
GZVideoPlayer
(
dataSource:
videoUrl
,
sourceType:
DataSourceType
.
network
,
/// 视频播放配置
playOptions:
VideoPlayOptions
(
seekSeconds:
30
,
...
...
@@ -122,8 +162,8 @@ class _MyAppState extends State<MyApp> {
show:
true
,
//是否显示
height:
60
,
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8
,
horizontal:
10
),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8
,
horizontal:
10
),
barBackgroundColor:
const
Color
.
fromRGBO
(
0
,
0
,
0
,
0.5
),
popIcon:
const
Icon
(
Icons
.
arrow_back
,
...
...
@@ -136,8 +176,7 @@ class _MyAppState extends State<MyApp> {
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
10
),
child:
const
Text
(
'123'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
14
),
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
14
),
),
),
)
...
...
@@ -194,11 +233,12 @@ class _MyAppState extends State<MyApp> {
/// 自定义颜色
// barBackgroundColor: Colors.blue,
/// 自定义时间TextStyle
timeTextStyle:
const
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
white
),
timeTextStyle:
const
TextStyle
(
fontSize:
14.0
,
color:
Colors
.
white
),
///添加边距
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8
,
horizontal:
10
),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8
,
horizontal:
10
),
///设置控制拦的高度,默认为30,如果图标设置过大但是高度不够就会出现图标被裁剪的现象
height:
60
,
...
...
@@ -462,7 +502,6 @@ class _MyAppState extends State<MyApp> {
)
:
Container
(),
]),
),
);
}
}
...
...
lib/video.dart
浏览文件 @
c24d98cd
...
...
@@ -121,7 +121,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
bool
_initialized
=
false
;
/// 屏幕亮度
final
ValueNotifier
<
double
>
_brightness
=
ValueNotifier
(
0.5
);
final
ValueNotifier
<
double
>
_brightness
=
ValueNotifier
(
0.0
);
late
double
_originBrightness
;
/// 视频音量
final
ValueNotifier
<
double
>
_volume
=
ValueNotifier
(
0.5
);
...
...
@@ -221,14 +222,18 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
/// 常亮
Wakelock
.
toggle
(
enable:
true
);
/// 初始化亮度为系统亮度
ScreenBrightness
().
current
.
then
((
brightness
)
{
_brightness
.
value
=
brightness
;
});
initBrightness
();
/// 倍数按钮标题
_speedTitle
=
widget
.
videoStyle
.
videoSpeedButtonStyle
.
title
;
_initPlayer
();
}
void
initBrightness
()
async
{
double
brightness
=
await
ScreenBrightness
().
current
;
_brightness
.
value
=
brightness
;
_originBrightness
=
brightness
;
}
@override
void
didUpdateWidget
(
GZVideoPlayer
oldWidget
)
{
if
(
oldWidget
.
dataSource
!=
widget
.
dataSource
)
{
...
...
@@ -251,6 +256,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
_subscription
.
cancel
();
_brightness
.
dispose
();
_volume
.
dispose
();
ScreenBrightness
().
setScreenBrightness
(
_originBrightness
);
super
.
dispose
();
}
...
...
lib/widget/video_loading_view.dart
浏览文件 @
c24d98cd
...
...
@@ -8,7 +8,9 @@ class VideoLoadingView extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
Align
(
return
DecoratedBox
(
decoration:
const
BoxDecoration
(
color:
Colors
.
black
),
child:
Align
(
alignment:
Alignment
.
center
,
child:
Center
(
child:
Column
(
...
...
@@ -31,6 +33,7 @@ class VideoLoadingView extends StatelessWidget {
],
),
),
),
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论