Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
gz_video_player
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
gz_video_player
Commits
b6a651e9
提交
b6a651e9
authored
10月 17, 2023
作者:
jungleiOS
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
切换视频源 刷新清晰度
上级
43674456
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
42 行增加
和
9 行删除
+42
-9
main.dart
example/lib/main.dart
+24
-0
video.dart
lib/video.dart
+16
-9
video_definition_side_bar.dart
lib/widget/video_definition_side_bar.dart
+2
-0
没有找到文件。
example/lib/main.dart
浏览文件 @
b6a651e9
...
@@ -559,6 +559,30 @@ class _VideoPlayerPageState extends State<VideoPlayerPage> {
...
@@ -559,6 +559,30 @@ class _VideoPlayerPageState extends State<VideoPlayerPage> {
),
),
),
),
),
),
SliverToBoxAdapter
(
child:
Center
(
child:
CustomBtn
(
title:
'切换视频source'
,
onTap:
()
{
definitionList
=
[
VideoDefinitionItem
(
dataSource:
'https://mpv.videocc.net/8f38fa3352/0/8f38fa33525a64b20de46bb5271f5ba0_1.mp4'
,
title:
'LD'
,
),
VideoDefinitionItem
(
dataSource:
'https://mpv.videocc.net/8f38fa3352/0/8f38fa33525a64b20de46bb5271f5ba0_2.mp4'
,
title:
'SD'
,
),
];
videoUrl
=
'https://mpv.videocc.net/8f38fa3352/0/8f38fa33525a64b20de46bb5271f5ba0_1.mp4'
;
setState
(()
{});
},
),
),
),
],
],
),
),
)
)
...
...
lib/video.dart
浏览文件 @
b6a651e9
...
@@ -3,6 +3,7 @@ import 'dart:io';
...
@@ -3,6 +3,7 @@ import 'dart:io';
import
'package:connectivity/connectivity.dart'
;
import
'package:connectivity/connectivity.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:gz_orientation/gz_orientation.dart'
;
import
'package:gz_orientation/gz_orientation.dart'
;
import
'package:gz_video_player/video_definition.dart'
;
import
'package:gz_video_player/video_definition.dart'
;
...
@@ -224,17 +225,11 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
...
@@ -224,17 +225,11 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
/// 清晰度按钮标题
/// 清晰度按钮标题
_definitionTitle
=
widget
.
videoStyle
.
videoDefinitionButtonStyle
.
title
;
_definitionTitle
=
widget
.
videoStyle
.
videoDefinitionButtonStyle
.
title
;
if
(
widget
.
playOptions
.
definitionList
.
isNotEmpty
)
{
_resetDefinitionTitle
();
for
(
VideoDefinitionItem
item
in
widget
.
playOptions
.
definitionList
)
{
if
(
widget
.
dataSource
==
item
.
dataSource
)
{
_definitionTitle
=
item
.
title
;
break
;
}
}
}
_initPlayer
();
_initPlayer
();
}
}
Future
<
void
>
initBrightness
()
async
{
Future
<
void
>
initBrightness
()
async
{
double
brightness
=
await
ScreenBrightness
().
current
;
double
brightness
=
await
ScreenBrightness
().
current
;
_brightness
.
value
=
brightness
;
_brightness
.
value
=
brightness
;
...
@@ -245,6 +240,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
...
@@ -245,6 +240,7 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
void
didUpdateWidget
(
GZVideoPlayer
oldWidget
)
{
void
didUpdateWidget
(
GZVideoPlayer
oldWidget
)
{
if
(
oldWidget
.
dataSource
!=
widget
.
dataSource
||
if
(
oldWidget
.
dataSource
!=
widget
.
dataSource
||
oldWidget
.
sourceType
!=
widget
.
sourceType
)
{
oldWidget
.
sourceType
!=
widget
.
sourceType
)
{
_resetDefinitionTitle
();
_updateDataSource
(
type:
widget
.
sourceType
,
source
:
widget
.
dataSource
);
_updateDataSource
(
type:
widget
.
sourceType
,
source
:
widget
.
dataSource
);
}
}
super
.
didUpdateWidget
(
oldWidget
);
super
.
didUpdateWidget
(
oldWidget
);
...
@@ -336,13 +332,24 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
...
@@ -336,13 +332,24 @@ class GZVideoPlayerState extends State<GZVideoPlayer>
void
resetVideoPlayer
()
{
void
resetVideoPlayer
()
{
setState
(()
{
setState
(()
{
_isEnded
=
true
;
_isEnded
=
true
;
// _position = "--:--"
;
_position
=
_duration
;
// _duration = "--:--";
// _duration = "--:--";
_controller
.
value
=
_controller
.
value
=
const
VideoPlayerValue
(
duration:
Duration
(
seconds:
0
));
const
VideoPlayerValue
(
duration:
Duration
(
seconds:
0
));
});
});
}
}
void
_resetDefinitionTitle
()
{
if
(
widget
.
playOptions
.
definitionList
.
isNotEmpty
)
{
for
(
VideoDefinitionItem
item
in
widget
.
playOptions
.
definitionList
)
{
if
(
widget
.
dataSource
==
item
.
dataSource
)
{
_definitionTitle
=
item
.
title
;
break
;
}
}
}
}
void
_listener
()
{
void
_listener
()
{
if
(!
mounted
)
{
if
(!
mounted
)
{
return
;
return
;
...
...
lib/widget/video_definition_side_bar.dart
浏览文件 @
b6a651e9
...
@@ -74,6 +74,7 @@ class _VideoDefinitionSideBarState extends State<VideoDefinitionSideBar>
...
@@ -74,6 +74,7 @@ class _VideoDefinitionSideBarState extends State<VideoDefinitionSideBar>
VideoDefinitionItem
item
=
itemList
[
i
];
VideoDefinitionItem
item
=
itemList
[
i
];
if
(
defaultSource
==
item
.
dataSource
)
{
if
(
defaultSource
==
item
.
dataSource
)
{
_selectedIndex
=
i
;
_selectedIndex
=
i
;
break
;
}
}
}
}
}
}
...
@@ -83,6 +84,7 @@ class _VideoDefinitionSideBarState extends State<VideoDefinitionSideBar>
...
@@ -83,6 +84,7 @@ class _VideoDefinitionSideBarState extends State<VideoDefinitionSideBar>
super
.
didUpdateWidget
(
oldWidget
);
super
.
didUpdateWidget
(
oldWidget
);
if
(
oldWidget
.
defaultSource
!=
defaultSource
||
if
(
oldWidget
.
defaultSource
!=
defaultSource
||
oldWidget
.
itemList
!=
itemList
)
{
oldWidget
.
itemList
!=
itemList
)
{
_selectedIndex
=
0
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
timeStamp
)
{
SchedulerBinding
.
instance
.
addPostFrameCallback
((
timeStamp
)
{
changeDefaultIndex
();
changeDefaultIndex
();
setState
(()
{});
setState
(()
{});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论