Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
gz_video_player
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
gz_video_player
Commits
993eb30c
提交
993eb30c
authored
9月 11, 2023
作者:
jungleiOS
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dispose 时销毁动画控制器 重置按钮不根据结束回调是否实现而显示
上级
6abf309a
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
147 行增加
和
138 行删除
+147
-138
video.dart
lib/video.dart
+147
-138
没有找到文件。
lib/video.dart
浏览文件 @
993eb30c
...
...
@@ -213,6 +213,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
]);
// 常亮
Wakelock
.
toggle
(
enable:
true
);
/// 倍数按钮标题
_speedTitle
=
widget
.
videoStyle
.
videoSpeedButtonStyle
.
title
;
_initPlayer
();
...
...
@@ -230,6 +231,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
void
dispose
()
{
_clearHideControlBarTimer
();
_controller
.
dispose
();
_controlBarAnimationController
.
dispose
();
///竖屏
SystemChrome
.
setPreferredOrientations
([
...
...
@@ -308,8 +310,8 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
});
}
else
{
if
(
oPosition
>=
oDuration
)
{
resetVideoPlayer
();
if
(
widget
.
onEnded
!=
null
)
{
resetVideoPlayer
();
widget
.
onEnded
!(
_controller
.
value
);
}
}
...
...
@@ -638,36 +640,38 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
:
const
Text
(
""
),
/// 主字幕
widget
.
videoStyle
.
videoSubtitlesStyle
.
mainTitle
??
Align
(
alignment:
Alignment
.
bottomCenter
,
child:
Container
(
padding:
const
EdgeInsets
.
fromLTRB
(
10
,
0
,
10
,
30
),
child:
Text
(
""
,
maxLines:
2
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
color:
widget
.
videoStyle
.
videoSubtitlesStyle
.
mainTitleColor
,
fontSize:
widget
.
videoStyle
.
videoSubtitlesStyle
.
mainTitleFontSize
)),
),
widget
.
videoStyle
.
videoSubtitlesStyle
.
mainTitle
??
Align
(
alignment:
Alignment
.
bottomCenter
,
child:
Container
(
padding:
const
EdgeInsets
.
fromLTRB
(
10
,
0
,
10
,
30
)
,
child:
Text
(
""
,
maxLines:
2
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
color:
widget
.
videoStyle
.
videoSubtitlesStyle
.
mainTitleColor
,
fontSize:
widget
.
videoStyle
.
videoSubtitlesStyle
.
mainTitleFontSize
)
),
),
),
/// 辅字幕
widget
.
videoStyle
.
videoSubtitlesStyle
.
subTitle
??
Align
(
alignment:
Alignment
.
bottomCenter
,
child:
Container
(
padding:
const
EdgeInsets
.
all
(
10
),
child:
Text
(
""
,
maxLines:
2
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
color:
widget
.
videoStyle
.
videoSubtitlesStyle
.
subTitleColor
,
fontSize:
widget
.
videoStyle
.
videoSubtitlesStyle
.
subTitleFontSize
)),
),
widget
.
videoStyle
.
videoSubtitlesStyle
.
subTitle
??
Align
(
alignment:
Alignment
.
bottomCenter
,
child:
Container
(
padding:
const
EdgeInsets
.
all
(
10
)
,
child:
Text
(
""
,
maxLines:
2
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
color:
widget
.
videoStyle
.
videoSubtitlesStyle
.
subTitleColor
,
fontSize:
widget
.
videoStyle
.
videoSubtitlesStyle
.
subTitleFontSize
)
),
),
),
/// 底部控制拦
VideoBottomBar
(
...
...
@@ -690,15 +694,17 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
},
),
widget
.
brightnessWidget
??
BrightnessWidget
(
brightness:
_brightness
,
videoBrightnessStyle:
widget
.
videoStyle
.
videoBrightnessStyle
,
),
widget
.
brightnessWidget
??
BrightnessWidget
(
brightness:
_brightness
,
videoBrightnessStyle:
widget
.
videoStyle
.
videoBrightnessStyle
,
),
widget
.
volumeWidget
??
VolumeWidget
(
volume:
_volume
,
videoVolumeStyle:
widget
.
videoStyle
.
videoVolumeStyle
,
),
widget
.
volumeWidget
??
VolumeWidget
(
volume:
_volume
,
videoVolumeStyle:
widget
.
videoStyle
.
videoVolumeStyle
,
),
/// Loading
!
_initialized
||
_isBuffing
...
...
@@ -713,120 +719,123 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
final
videoChildrens
=
<
Widget
>[
/// 视频区域
GestureDetector
(
//点击
onTap:
()
{
//显示或隐藏菜单栏和进度条
toggleControls
();
},
//双击
onDoubleTap:
()
{
if
(!
_controller
.
value
.
isInitialized
)
return
;
togglePlay
();
},
//点击
onTap:
()
{
//显示或隐藏菜单栏和进度条
toggleControls
();
},
//双击
onDoubleTap:
()
{
if
(!
_controller
.
value
.
isInitialized
)
return
;
togglePlay
();
},
/// 水平滑动 - 调节视频进度
onHorizontalDragStart:
(
DragStartDetails
details
)
{
if
(!
_controller
.
value
.
isInitialized
)
return
;
if
(
_controller
.
value
.
isPlaying
)
{
_controller
.
pause
();
}
},
onHorizontalDragUpdate:
(
DragUpdateDetails
details
)
{
if
(!
_controller
.
value
.
isInitialized
)
return
;
if
(!
_showMenu
)
{
setState
(()
{
_showMenu
=
true
;
});
_createHideControlBarTimer
();
}
var
currentPosition
=
_controller
.
value
.
position
;
if
(
details
.
primaryDelta
!=
null
)
{
_controller
.
seekTo
(
Duration
(
milliseconds:
details
.
primaryDelta
!
>
0
?
currentPosition
.
inMilliseconds
+
widget
.
playOptions
.
progressGestureUnit
:
currentPosition
.
inMilliseconds
-
widget
.
playOptions
.
progressGestureUnit
));
}
},
onHorizontalDragEnd:
(
DragEndDetails
details
)
{
if
(!
_controller
.
value
.
isPlaying
)
{
_controller
.
play
();
}
},
/// 水平滑动 - 调节视频进度
onHorizontalDragStart:
(
DragStartDetails
details
)
{
if
(!
_controller
.
value
.
isInitialized
)
return
;
if
(
_controller
.
value
.
isPlaying
)
{
_controller
.
pause
();
}
},
onHorizontalDragUpdate:
(
DragUpdateDetails
details
)
{
if
(!
_controller
.
value
.
isInitialized
)
return
;
if
(!
_showMenu
)
{
setState
(()
{
_showMenu
=
true
;
});
_createHideControlBarTimer
();
}
var
currentPosition
=
_controller
.
value
.
position
;
if
(
details
.
primaryDelta
!=
null
)
{
_controller
.
seekTo
(
Duration
(
milliseconds:
details
.
primaryDelta
!
>
0
?
currentPosition
.
inMilliseconds
+
widget
.
playOptions
.
progressGestureUnit
:
currentPosition
.
inMilliseconds
-
widget
.
playOptions
.
progressGestureUnit
));
}
},
onHorizontalDragEnd:
(
DragEndDetails
details
)
{
if
(!
_controller
.
value
.
isPlaying
)
{
_controller
.
play
();
}
},
/// 垂直滑动 - 调节亮度以及音量
onVerticalDragStart:
(
DragStartDetails
details
)
{
if
(!
_controller
.
value
.
isInitialized
)
return
;
},
onVerticalDragUpdate:
(
DragUpdateDetails
details
)
async
{
if
(!
_controller
.
value
.
isInitialized
||
details
.
primaryDelta
==
null
)
return
;
// 右侧垂直滑动 - 音量调节
if
(
details
.
globalPosition
.
dx
>=
(
screenSize
.
width
/
2
))
{
_volume
.
value
=
_controller
.
value
.
volume
;
if
(
details
.
primaryDelta
!
>
0
)
{
//往下滑动
_volume
.
value
=
_controller
.
value
.
volume
-
widget
.
playOptions
.
volumeGestureUnit
;
widget
.
onVolume
?.
call
(
_volume
.
value
);
if
(
_volume
.
value
<=
0
)
{
_volume
.
value
=
0.0
;
}
widget
.
onVolume
?.
call
(
_volume
.
value
);
_controller
.
setVolume
(
_volume
.
value
);
}
else
{
//往上滑动
_volume
.
value
=
_controller
.
value
.
volume
+
widget
.
playOptions
.
volumeGestureUnit
;
widget
.
onVolume
?.
call
(
_volume
.
value
);
if
(
_volume
.
value
>=
1
)
{
_volume
.
value
=
1.0
;
}
widget
.
onVolume
?.
call
(
_volume
.
value
);
_controller
.
setVolume
(
_volume
.
value
);
/// 垂直滑动 - 调节亮度以及音量
onVerticalDragStart:
(
DragStartDetails
details
)
{
if
(!
_controller
.
value
.
isInitialized
)
return
;
},
onVerticalDragUpdate:
(
DragUpdateDetails
details
)
async
{
if
(!
_controller
.
value
.
isInitialized
||
details
.
primaryDelta
==
null
)
return
;
// 右侧垂直滑动 - 音量调节
if
(
details
.
globalPosition
.
dx
>=
(
screenSize
.
width
/
2
))
{
_volume
.
value
=
_controller
.
value
.
volume
;
if
(
details
.
primaryDelta
!
>
0
)
{
//往下滑动
_volume
.
value
=
_controller
.
value
.
volume
-
widget
.
playOptions
.
volumeGestureUnit
;
widget
.
onVolume
?.
call
(
_volume
.
value
);
if
(
_volume
.
value
<=
0
)
{
_volume
.
value
=
0.0
;
}
_volume
.
value
=
_controller
.
value
.
volume
;
widget
.
onVolume
?.
call
(
_volume
.
value
);
_controller
.
setVolume
(
_volume
.
value
);
}
else
{
// 左侧垂直滑动 - 亮度调节
_brightness
.
value
=
await
ScreenBrightness
().
current
;
if
(
details
.
primaryDelta
!
>
0
)
{
//往下滑动
_brightness
.
value
-=
widget
.
playOptions
.
brightnessGestureUnit
;
widget
.
onBrightness
?.
call
(
_brightness
.
value
);
if
(
_brightness
.
value
<=
0
)
{
_brightness
.
value
=
0.0
;
}
widget
.
onBrightness
?.
call
(
_brightness
.
value
);
await
ScreenBrightness
().
setScreenBrightness
(
_brightness
.
value
);
}
else
{
//往上滑动
_brightness
.
value
+=
widget
.
playOptions
.
brightnessGestureUnit
;
widget
.
onBrightness
?.
call
(
_brightness
.
value
);
if
(
_brightness
.
value
>=
1
)
{
_brightness
.
value
=
1.0
;
}
widget
.
onBrightness
?.
call
(
_brightness
.
value
);
await
ScreenBrightness
().
setScreenBrightness
(
_brightness
.
value
);
//往上滑动
_volume
.
value
=
_controller
.
value
.
volume
+
widget
.
playOptions
.
volumeGestureUnit
;
widget
.
onVolume
?.
call
(
_volume
.
value
);
if
(
_volume
.
value
>=
1
)
{
_volume
.
value
=
1.0
;
}
// Screen.setBrightness(brightness
);
widget
.
onVolume
?.
call
(
_volume
.
value
);
_controller
.
setVolume
(
_volume
.
value
);
}
},
onVerticalDragEnd:
(
DragEndDetails
details
)
{},
_volume
.
value
=
_controller
.
value
.
volume
;
}
else
{
// 左侧垂直滑动 - 亮度调节
_brightness
.
value
=
await
ScreenBrightness
().
current
;
if
(
details
.
primaryDelta
!
>
0
)
{
//往下滑动
_brightness
.
value
-=
widget
.
playOptions
.
brightnessGestureUnit
;
widget
.
onBrightness
?.
call
(
_brightness
.
value
);
if
(
_brightness
.
value
<=
0
)
{
_brightness
.
value
=
0.0
;
}
widget
.
onBrightness
?.
call
(
_brightness
.
value
);
await
ScreenBrightness
().
setScreenBrightness
(
_brightness
.
value
);
}
else
{
//往上滑动
_brightness
.
value
+=
widget
.
playOptions
.
brightnessGestureUnit
;
widget
.
onBrightness
?.
call
(
_brightness
.
value
);
if
(
_brightness
.
value
>=
1
)
{
_brightness
.
value
=
1.0
;
}
widget
.
onBrightness
?.
call
(
_brightness
.
value
);
await
ScreenBrightness
().
setScreenBrightness
(
_brightness
.
value
);
}
// Screen.setBrightness(brightness);
}
},
onVerticalDragEnd:
(
DragEndDetails
details
)
{},
///视频播放器
child:
ClipRect
(
child:
Container
(
///视频播放器
child:
ClipRect
(
child:
Container
(
width:
double
.
infinity
,
height:
double
.
infinity
,
color:
Colors
.
black
,
child:
Center
(
child:
AspectRatio
(
aspectRatio:
_controller
.
value
.
aspectRatio
,
child:
VideoPlayer
(
_controller
),
)),
))),
child:
AspectRatio
(
aspectRatio:
_controller
.
value
.
aspectRatio
,
child:
VideoPlayer
(
_controller
),
),
),
),
),
),
///控制拦以及(可拓展)元素
];
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论