fix:issues #26; mod: 部分样式
This commit is contained in:
@ -46,6 +46,7 @@ class PlPlayerController {
|
|||||||
// 播放位置
|
// 播放位置
|
||||||
final Rx<Duration> _position = Rx(Duration.zero);
|
final Rx<Duration> _position = Rx(Duration.zero);
|
||||||
final Rx<Duration> _sliderPosition = Rx(Duration.zero);
|
final Rx<Duration> _sliderPosition = Rx(Duration.zero);
|
||||||
|
// 展示使用
|
||||||
final Rx<Duration> _sliderTempPosition = Rx(Duration.zero);
|
final Rx<Duration> _sliderTempPosition = Rx(Duration.zero);
|
||||||
final Rx<Duration> _duration = Rx(Duration.zero);
|
final Rx<Duration> _duration = Rx(Duration.zero);
|
||||||
final Rx<Duration> _buffered = Rx(Duration.zero);
|
final Rx<Duration> _buffered = Rx(Duration.zero);
|
||||||
@ -450,7 +451,7 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 跳转至指定位置
|
/// 跳转至指定位置
|
||||||
Future<void> seekTo(Duration position) async {
|
Future<void> seekTo(Duration position, {type = 'seek'}) async {
|
||||||
// if (position >= duration.value) {
|
// if (position >= duration.value) {
|
||||||
// position = duration.value - const Duration(milliseconds: 100);
|
// position = duration.value - const Duration(milliseconds: 100);
|
||||||
// }
|
// }
|
||||||
@ -459,7 +460,10 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
_position.value = position;
|
_position.value = position;
|
||||||
if (duration.value.inSeconds != 0) {
|
if (duration.value.inSeconds != 0) {
|
||||||
|
if (type != 'slider') {
|
||||||
|
/// 拖动进度条调节时,不等待第一帧,防止抖动
|
||||||
await _videoPlayerController!.stream.buffer.first;
|
await _videoPlayerController!.stream.buffer.first;
|
||||||
|
}
|
||||||
await _videoPlayerController?.seek(position);
|
await _videoPlayerController?.seek(position);
|
||||||
// if (playerStatus.stopped) {
|
// if (playerStatus.stopped) {
|
||||||
// play();
|
// play();
|
||||||
|
|||||||
@ -253,7 +253,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
fit: StackFit.passthrough,
|
fit: StackFit.passthrough,
|
||||||
children: [
|
children: [
|
||||||
Video(
|
Obx(
|
||||||
|
() => Video(
|
||||||
controller: videoController,
|
controller: videoController,
|
||||||
controls: NoVideoControls,
|
controls: NoVideoControls,
|
||||||
subtitleViewConfiguration: SubtitleViewConfiguration(
|
subtitleViewConfiguration: SubtitleViewConfiguration(
|
||||||
@ -261,6 +262,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
padding: const EdgeInsets.all(24.0),
|
padding: const EdgeInsets.all(24.0),
|
||||||
),
|
),
|
||||||
|
fit: _.videoFit.value,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
/// 长按倍速 toast
|
/// 长按倍速 toast
|
||||||
@ -312,6 +315,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
opacity: _.isSliderMoving.value ? 1.0 : 0.0,
|
opacity: _.isSliderMoving.value ? 1.0 : 0.0,
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
|
child: IntrinsicWidth(
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -319,7 +323,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
borderRadius: BorderRadius.circular(64.0),
|
borderRadius: BorderRadius.circular(64.0),
|
||||||
),
|
),
|
||||||
height: 34.0,
|
height: 34.0,
|
||||||
width: 100.0,
|
padding: const EdgeInsets.only(left: 10, right: 10),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -350,6 +354,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
/// 音量🔊 控制条展示
|
/// 音量🔊 控制条展示
|
||||||
Align(
|
Align(
|
||||||
@ -539,7 +544,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_.onChangedSliderEnd();
|
_.onChangedSliderEnd();
|
||||||
_.seekTo(_.sliderPosition.value);
|
_.seekTo(_.sliderPosition.value, type: 'slider');
|
||||||
},
|
},
|
||||||
// 垂直方向 音量/亮度调节
|
// 垂直方向 音量/亮度调节
|
||||||
onVerticalDragUpdate: (DragUpdateDetails details) async {
|
onVerticalDragUpdate: (DragUpdateDetails details) async {
|
||||||
@ -695,10 +700,20 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
Obx(() {
|
Obx(() {
|
||||||
if (_.dataStatus.loading || _.isBuffering.value) {
|
if (_.dataStatus.loading || _.isBuffering.value) {
|
||||||
return Center(
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(30),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: RadialGradient(
|
||||||
|
center: Alignment.center,
|
||||||
|
colors: [Colors.black26, Colors.transparent],
|
||||||
|
),
|
||||||
|
),
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/images/loading.gif',
|
'assets/images/loading.gif',
|
||||||
height: 25,
|
height: 25,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Container();
|
return Container();
|
||||||
|
|||||||
@ -44,7 +44,9 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
if (value > max || max <= 0) {
|
if (value > max || max <= 0) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
return ProgressBar(
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 5, right: 5, bottom: 5),
|
||||||
|
child: ProgressBar(
|
||||||
progress: Duration(seconds: value),
|
progress: Duration(seconds: value),
|
||||||
buffered: Duration(seconds: buffer),
|
buffered: Duration(seconds: buffer),
|
||||||
total: Duration(seconds: max),
|
total: Duration(seconds: max),
|
||||||
@ -65,8 +67,10 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
onSeek: (duration) {
|
onSeek: (duration) {
|
||||||
_.onChangedSliderEnd();
|
_.onChangedSliderEnd();
|
||||||
_.onChangedSlider(duration.inSeconds.toDouble());
|
_.onChangedSlider(duration.inSeconds.toDouble());
|
||||||
_.seekTo(Duration(seconds: duration.inSeconds));
|
_.seekTo(Duration(seconds: duration.inSeconds),
|
||||||
|
type: 'slider');
|
||||||
},
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user