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) {
|
||||||
await _videoPlayerController!.stream.buffer.first;
|
if (type != 'slider') {
|
||||||
|
/// 拖动进度条调节时,不等待第一帧,防止抖动
|
||||||
|
await _videoPlayerController!.stream.buffer.first;
|
||||||
|
}
|
||||||
await _videoPlayerController?.seek(position);
|
await _videoPlayerController?.seek(position);
|
||||||
// if (playerStatus.stopped) {
|
// if (playerStatus.stopped) {
|
||||||
// play();
|
// play();
|
||||||
|
@ -253,13 +253,16 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
fit: StackFit.passthrough,
|
fit: StackFit.passthrough,
|
||||||
children: [
|
children: [
|
||||||
Video(
|
Obx(
|
||||||
controller: videoController,
|
() => Video(
|
||||||
controls: NoVideoControls,
|
controller: videoController,
|
||||||
subtitleViewConfiguration: SubtitleViewConfiguration(
|
controls: NoVideoControls,
|
||||||
style: subTitleStyle,
|
subtitleViewConfiguration: SubtitleViewConfiguration(
|
||||||
textAlign: TextAlign.center,
|
style: subTitleStyle,
|
||||||
padding: const EdgeInsets.all(24.0),
|
textAlign: TextAlign.center,
|
||||||
|
padding: const EdgeInsets.all(24.0),
|
||||||
|
),
|
||||||
|
fit: _.videoFit.value,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -312,38 +315,40 @@ 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: Container(
|
child: IntrinsicWidth(
|
||||||
alignment: Alignment.center,
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
alignment: Alignment.center,
|
||||||
color: const Color(0x88000000),
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(64.0),
|
color: const Color(0x88000000),
|
||||||
),
|
borderRadius: BorderRadius.circular(64.0),
|
||||||
height: 34.0,
|
),
|
||||||
width: 100.0,
|
height: 34.0,
|
||||||
child: Row(
|
padding: const EdgeInsets.only(left: 10, right: 10),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
Obx(() {
|
children: [
|
||||||
return Text(
|
Obx(() {
|
||||||
_.sliderTempPosition.value.inMinutes >= 60
|
return Text(
|
||||||
? printDurationWithHours(
|
_.sliderTempPosition.value.inMinutes >= 60
|
||||||
_.sliderTempPosition.value)
|
? printDurationWithHours(
|
||||||
: printDuration(_.sliderTempPosition.value),
|
_.sliderTempPosition.value)
|
||||||
style: textStyle,
|
: printDuration(_.sliderTempPosition.value),
|
||||||
);
|
style: textStyle,
|
||||||
}),
|
);
|
||||||
const SizedBox(width: 2),
|
}),
|
||||||
const Text('/', style: textStyle),
|
const SizedBox(width: 2),
|
||||||
const SizedBox(width: 2),
|
const Text('/', style: textStyle),
|
||||||
Obx(
|
const SizedBox(width: 2),
|
||||||
() => Text(
|
Obx(
|
||||||
_.duration.value.inMinutes >= 60
|
() => Text(
|
||||||
? printDurationWithHours(_.duration.value)
|
_.duration.value.inMinutes >= 60
|
||||||
: printDuration(_.duration.value),
|
? printDurationWithHours(_.duration.value)
|
||||||
style: textStyle,
|
: printDuration(_.duration.value),
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -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,9 +700,19 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
Obx(() {
|
Obx(() {
|
||||||
if (_.dataStatus.loading || _.isBuffering.value) {
|
if (_.dataStatus.loading || _.isBuffering.value) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Image.asset(
|
child: Container(
|
||||||
'assets/images/loading.gif',
|
padding: const EdgeInsets.all(30),
|
||||||
height: 25,
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: RadialGradient(
|
||||||
|
center: Alignment.center,
|
||||||
|
colors: [Colors.black26, Colors.transparent],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/loading.gif',
|
||||||
|
height: 25,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,29 +44,33 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
if (value > max || max <= 0) {
|
if (value > max || max <= 0) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
return ProgressBar(
|
return Padding(
|
||||||
progress: Duration(seconds: value),
|
padding: const EdgeInsets.only(left: 5, right: 5, bottom: 5),
|
||||||
buffered: Duration(seconds: buffer),
|
child: ProgressBar(
|
||||||
total: Duration(seconds: max),
|
progress: Duration(seconds: value),
|
||||||
progressBarColor: colorTheme,
|
buffered: Duration(seconds: buffer),
|
||||||
baseBarColor: Colors.white.withOpacity(0.2),
|
total: Duration(seconds: max),
|
||||||
bufferedBarColor: colorTheme.withOpacity(0.4),
|
progressBarColor: colorTheme,
|
||||||
timeLabelLocation: TimeLabelLocation.none,
|
baseBarColor: Colors.white.withOpacity(0.2),
|
||||||
thumbColor: colorTheme,
|
bufferedBarColor: colorTheme.withOpacity(0.4),
|
||||||
barHeight: 3.0,
|
timeLabelLocation: TimeLabelLocation.none,
|
||||||
thumbRadius: 5.5,
|
thumbColor: colorTheme,
|
||||||
onDragStart: (duration) {
|
barHeight: 3.0,
|
||||||
feedBack();
|
thumbRadius: 5.5,
|
||||||
_.onChangedSliderStart();
|
onDragStart: (duration) {
|
||||||
},
|
feedBack();
|
||||||
onDragUpdate: (duration) {
|
_.onChangedSliderStart();
|
||||||
_.onUodatedSliderProgress(duration.timeStamp);
|
},
|
||||||
},
|
onDragUpdate: (duration) {
|
||||||
onSeek: (duration) {
|
_.onUodatedSliderProgress(duration.timeStamp);
|
||||||
_.onChangedSliderEnd();
|
},
|
||||||
_.onChangedSlider(duration.inSeconds.toDouble());
|
onSeek: (duration) {
|
||||||
_.seekTo(Duration(seconds: duration.inSeconds));
|
_.onChangedSliderEnd();
|
||||||
},
|
_.onChangedSlider(duration.inSeconds.toDouble());
|
||||||
|
_.seekTo(Duration(seconds: duration.inSeconds),
|
||||||
|
type: 'slider');
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user