Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
tx_player_fork
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蒋俊
tx_player_fork
Commits
b38f99ed
提交
b38f99ed
authored
9月 16, 2022
作者:
kongdywang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.fix component status conduction error
2.fix slider range error by dart precision problem 3.fix slider buffered progress display error
上级
6a00fe8f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
28 行增加
和
43 行删除
+28
-43
superplayer_bottom_view.dart
...r/example/lib/superplayer/ui/superplayer_bottom_view.dart
+2
-19
superplayer_video_slider.dart
.../example/lib/superplayer/ui/superplayer_video_slider.dart
+24
-22
superplayer_widget.dart
Flutter/example/lib/superplayer/ui/superplayer_widget.dart
+2
-2
没有找到文件。
Flutter/example/lib/superplayer/ui/superplayer_bottom_view.dart
浏览文件 @
b38f99ed
...
...
@@ -43,7 +43,6 @@ class _VideoBottomViewState extends State<VideoBottomView> {
_isShowQuality
=
isFullScreen
;
_currentQuality
=
widget
.
_playerController
.
currentQuality
;
_playerType
=
widget
.
_playerController
.
playerType
;
_fixProgress
();
super
.
initState
();
}
...
...
@@ -132,7 +131,7 @@ class _VideoBottomViewState extends State<VideoBottomView> {
min:
0
,
max:
_videoDuration
,
value:
_currentDuration
,
bufferedValue:
_
playableProgress
,
bufferedValue:
_
bufferedDuration
,
activeColor:
Color
(
ColorResource
.
COLOR_MAIN_THEME
),
inactiveColor:
Color
(
ColorResource
.
COLOR_GRAY
),
sliderColor:
Color
(
ColorResource
.
COLOR_MAIN_THEME
),
...
...
@@ -180,27 +179,11 @@ class _VideoBottomViewState extends State<VideoBottomView> {
_currentDuration
=
duration
;
_videoDuration
=
videoDuration
;
_bufferedDuration
=
bufferedDration
;
_fixProgress
();
});
}
}
}
void
_fixProgress
()
{
if
(
_bufferedDuration
==
0
)
{
_playableProgress
=
0
;
}
else
{
_playableProgress
=
_bufferedDuration
/
_videoDuration
;
}
if
(
_playableProgress
<
0
)
{
_playableProgress
=
0
;
}
if
(
_playableProgress
>
1
)
{
_playableProgress
=
1
;
}
}
void
updatePlayState
(
bool
playing
)
{
if
(
_isPlayMode
!=
playing
)
{
setState
(()
{
...
...
@@ -219,7 +202,7 @@ class _VideoBottomViewState extends State<VideoBottomView> {
void
updateUIStatus
(
int
status
)
{
setState
(()
{
bool
isFullScreen
=
widget
.
_playerController
.
_playerUIS
tatus
==
SuperPlayerUIStatus
.
FULLSCREEN_MODE
;
bool
isFullScreen
=
s
tatus
==
SuperPlayerUIStatus
.
FULLSCREEN_MODE
;
_showFullScreenBtn
=
!
isFullScreen
;
_isShowQuality
=
isFullScreen
;
});
...
...
Flutter/example/lib/superplayer/ui/superplayer_video_slider.dart
浏览文件 @
b38f99ed
...
...
@@ -42,15 +42,21 @@ class VideoSlider extends StatefulWidget {
this
.
onDragEnd
,
this
.
canDrag
})
{
double
range
=
(
max
-
min
);
if
(
range
<=
0
)
{
if
(
range
<=
0
)
{
controller
=
_VideoSliderController
(
1
,
bufferedProgress:
1
);
}
else
{
double
currentProgress
=
value
/
range
;
double
?
bufferedProgress
=
bufferedValue
!=
null
?
bufferedValue
!
/
range
:
null
;
double
currentProgress
=
remainTwoFixed
(
value
/
range
)
;
double
?
bufferedProgress
=
bufferedValue
!=
null
?
remainTwoFixed
(
bufferedValue
!
/
range
)
:
null
;
controller
=
_VideoSliderController
(
currentProgress
,
bufferedProgress:
bufferedProgress
);
}
}
/// remain two fixed,avoid double precision problem
double
remainTwoFixed
(
double
value
)
{
int
valueInt
=
(
value
*
100
).
toInt
();
return
valueInt
/
100
;
}
@override
State
<
StatefulWidget
>
createState
()
=>
VideoSliderState
();
}
...
...
@@ -82,29 +88,32 @@ class VideoSliderState extends State<VideoSlider> {
double
rightPadding
=
overlayRadius
;
return
GestureDetector
(
onHorizontalDragStart:
(
DragStartDetails
details
)
{
if
(
widget
.
canDrag
!)
{
if
(
widget
.
canDrag
!)
{
isDraging
=
true
;
widget
.
onDragStart
?.
call
();
}
},
onHorizontalDragUpdate:
(
DragUpdateDetails
details
)
{
if
(
widget
.
canDrag
!)
{
if
(
widget
.
canDrag
!)
{
isDraging
=
true
;
_seekToPosition
(
details
.
globalPosition
);
widget
.
onDragUpdate
?.
call
(
widget
.
controller
.
progress
);}
widget
.
onDragUpdate
?.
call
(
widget
.
controller
.
progress
);
}
},
onHorizontalDragEnd:
(
DragEndDetails
details
)
{
if
(
widget
.
canDrag
!)
{
if
(
widget
.
canDrag
!)
{
isDraging
=
false
;
widget
.
onDragEnd
?.
call
(
widget
.
controller
.
progress
);}
widget
.
onDragEnd
?.
call
(
widget
.
controller
.
progress
);
}
},
onHorizontalDragCancel:
()
{
if
(
widget
.
canDrag
!)
{
if
(
widget
.
canDrag
!)
{
isDraging
=
false
;
widget
.
onDragEnd
?.
call
(
widget
.
controller
.
progress
);}
widget
.
onDragEnd
?.
call
(
widget
.
controller
.
progress
);
}
},
onTapDown:
(
TapDownDetails
details
)
{
if
(
widget
.
canDrag
!)
{
if
(
widget
.
canDrag
!)
{
_seekToPosition
(
details
.
globalPosition
);
}
},
...
...
@@ -174,8 +183,7 @@ class _VideoSliderPainter extends CustomPainter {
// draw background
canvas
.
drawRRect
(
RRect
.
fromRectAndRadius
(
Rect
.
fromPoints
(
Offset
(
start
,
baseVerticalOffset
),
Offset
(
end
,
baseVerticalOffset
+
progressHeight
)),
RRect
.
fromRectAndRadius
(
Rect
.
fromPoints
(
Offset
(
start
,
baseVerticalOffset
),
Offset
(
end
,
baseVerticalOffset
+
progressHeight
)),
Radius
.
circular
(
sliderRadius
)),
shaders
.
backgroundPaint
);
...
...
@@ -186,8 +194,7 @@ class _VideoSliderPainter extends CustomPainter {
double
bufferedEndless
=
start
+
(
width
*
bPercent
);
canvas
.
drawRRect
(
RRect
.
fromRectAndRadius
(
Rect
.
fromPoints
(
Offset
(
start
,
baseVerticalOffset
),
Offset
(
bufferedEndless
,
baseVerticalOffset
+
progressHeight
)),
Rect
.
fromPoints
(
Offset
(
start
,
baseVerticalOffset
),
Offset
(
bufferedEndless
,
baseVerticalOffset
+
progressHeight
)),
Radius
.
circular
(
sliderRadius
)),
shaders
.
bufferedPaint
);
}
...
...
@@ -198,8 +205,7 @@ class _VideoSliderPainter extends CustomPainter {
double
progressEndless
=
start
+
(
width
*
ppercent
);
canvas
.
drawRRect
(
RRect
.
fromRectAndRadius
(
Rect
.
fromPoints
(
Offset
(
start
,
baseVerticalOffset
),
Offset
(
progressEndless
,
baseVerticalOffset
+
progressHeight
)),
Rect
.
fromPoints
(
Offset
(
start
,
baseVerticalOffset
),
Offset
(
progressEndless
,
baseVerticalOffset
+
progressHeight
)),
Radius
.
circular
(
sliderRadius
)),
shaders
.
progressPaint
);
...
...
@@ -225,11 +231,7 @@ class _VideoSliderShaders {
Paint
dragSliderOverlayPaint
=
Paint
();
_VideoSliderShaders
(
{
Color
?
backgroundColor
,
Color
?
progressColor
,
Color
?
dragSliderColor
,
Color
?
bufferedColor
,
Color
?
drawSliderOverlayColor
})
{
{
Color
?
backgroundColor
,
Color
?
progressColor
,
Color
?
dragSliderColor
,
Color
?
bufferedColor
,
Color
?
drawSliderOverlayColor
})
{
backgroundPaint
.
color
=
backgroundColor
??
Colors
.
grey
;
bufferedPaint
.
color
=
bufferedColor
??
Colors
.
blueGrey
;
progressPaint
.
color
=
progressColor
??
Colors
.
blueAccent
;
...
...
Flutter/example/lib/superplayer/ui/superplayer_widget.dart
浏览文件 @
b38f99ed
...
...
@@ -222,16 +222,16 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
return
SuperPlayerFullScreenView
(
_playController
,
_superPlayerFullUIController
);
}));
WidgetsBinding
.
instance
.
removeObserver
(
this
);
_playController
.
_updatePlayerUIStatus
(
SuperPlayerUIStatus
.
FULLSCREEN_MODE
);
_videoBottomKey
.
currentState
?.
updateUIStatus
(
SuperPlayerUIStatus
.
FULLSCREEN_MODE
);
_videoTitleKey
.
currentState
?.
updateUIStatus
(
SuperPlayerUIStatus
.
FULLSCREEN_MODE
);
_playController
.
_updatePlayerUIStatus
(
SuperPlayerUIStatus
.
FULLSCREEN_MODE
);
hideControlView
();
},
()
{
Navigator
.
of
(
context
).
pop
();
_playController
.
_updatePlayerUIStatus
(
SuperPlayerUIStatus
.
WINDOW_MODE
);
_videoBottomKey
.
currentState
?.
updateUIStatus
(
SuperPlayerUIStatus
.
WINDOW_MODE
);
_videoTitleKey
.
currentState
?.
updateUIStatus
(
SuperPlayerUIStatus
.
WINDOW_MODE
);
_playController
.
_updatePlayerUIStatus
(
SuperPlayerUIStatus
.
WINDOW_MODE
);
hideControlView
();
});
WidgetsBinding
.
instance
.
addObserver
(
this
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论