no message
This commit is contained in:
parent
3666bea6bd
commit
919f71f28b
|
|
@ -408,15 +408,14 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
toGoPlay();
|
toGoPlay();
|
||||||
} else {
|
} else {
|
||||||
// 暂停
|
// 暂停
|
||||||
toGoPause();
|
toGoPause(_val.recalculate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PlaybackSpeedBus:
|
case PlaybackSpeedBus:
|
||||||
// 播放速度
|
// 播放速度
|
||||||
var _model = (e as PlaybackSpeedBus);
|
var _model = (e as PlaybackSpeedBus);
|
||||||
speed = _model.speed;
|
speed = _model.speed;
|
||||||
toGoPause(); // 先暂停再重新播放
|
dragProgressBarInitData(handwritingDuration - handwritingTime, handwritingDuration);
|
||||||
dragProgressBarInitData(handwritingTime, handwritingDuration);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
@ -449,12 +448,13 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
}
|
}
|
||||||
|
|
||||||
// 暂停播放
|
// 暂停播放
|
||||||
Future<void> toGoPause() async {
|
Future<void> toGoPause(bool recalculate) async {
|
||||||
timers.forEach((e) {
|
timers.forEach((e) {
|
||||||
if (e.isActive) e.cancel();
|
if (e.isActive) e.cancel();
|
||||||
});
|
});
|
||||||
timers = [];
|
timers = [];
|
||||||
if (pendingData.isNotEmpty && handwritingTime > 0 && (handwritingDuration - handwritingTime > 0)) {
|
// 总时间-剩余时间=已经执行时间
|
||||||
|
if (recalculate && pendingData.isNotEmpty && handwritingTime > 0 && (handwritingDuration - handwritingTime > 0)) {
|
||||||
// 待执行的数据不等于空 每个数据都需要减去当前暂停已经执行的时间
|
// 待执行的数据不等于空 每个数据都需要减去当前暂停已经执行的时间
|
||||||
pendingData = pendingData.map((e) {
|
pendingData = pendingData.map((e) {
|
||||||
return GestureHandwritingRecording(
|
return GestureHandwritingRecording(
|
||||||
|
|
@ -470,7 +470,7 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
/// 拖动进度条后重新初始化数据
|
/// 拖动进度条后重新初始化数据
|
||||||
/// @param startTime 起始时间 单位秒
|
/// @param startTime 起始时间 单位秒
|
||||||
Future<void> dragProgressBarInitData(int startTime, int totalDuration) async {
|
Future<void> dragProgressBarInitData(int startTime, int totalDuration) async {
|
||||||
eventFire(model: JobHandwritingPlaybarBus(false));
|
eventFire(model: JobHandwritingPlaybarBus(false, false));
|
||||||
timers.forEach((e) {
|
timers.forEach((e) {
|
||||||
if (e.isActive) e.cancel();
|
if (e.isActive) e.cancel();
|
||||||
});
|
});
|
||||||
|
|
@ -489,7 +489,7 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
for (var i = 0; i < _packagedHandwritingDataAll.length; i++) {
|
for (var i = 0; i < _packagedHandwritingDataAll.length; i++) {
|
||||||
var item = _packagedHandwritingDataAll[i];
|
var item = _packagedHandwritingDataAll[i];
|
||||||
|
|
||||||
if (item.intervalTime < startTime) {
|
if (item.intervalTime <= startTime) {
|
||||||
// 需要直接装配到直接打印的容器
|
// 需要直接装配到直接打印的容器
|
||||||
executeImmediately.add(item);
|
executeImmediately.add(item);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -515,29 +515,30 @@ class _HandwritingDrawBoxState extends ConsumerState<HandwritingDrawBox> with Ev
|
||||||
List<GestureHandwritingRecording> trajectorys = ref.read(jobHandwritingDrawingTrajectoryProvider)..add(e);
|
List<GestureHandwritingRecording> trajectorys = ref.read(jobHandwritingDrawingTrajectoryProvider)..add(e);
|
||||||
ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).setVal(List.from(trajectorys));
|
ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).setVal(List.from(trajectorys));
|
||||||
pendingData.remove(e); // 执行后删除容器中的当前动作
|
pendingData.remove(e); // 执行后删除容器中的当前动作
|
||||||
|
print('正在执行播放.............');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 开始播放
|
/// 开始播放
|
||||||
Future<void> toGoPlay() async {
|
Future<void> toGoPlay() async {
|
||||||
handwritingTime = 0;
|
try {
|
||||||
var executableData = _packagedHandwritingDataAll;
|
handwritingTime = 0;
|
||||||
if (pendingData.isNotEmpty) {
|
var executableData = _packagedHandwritingDataAll;
|
||||||
// 待执行的数据没有执行完成 就继续执行待执行数据
|
if (pendingData.isNotEmpty) {
|
||||||
executableData = pendingData;
|
// 待执行的数据没有执行完成 就继续执行待执行数据
|
||||||
} else {
|
executableData = pendingData;
|
||||||
pendingData.addAll(_packagedHandwritingDataAll);
|
|
||||||
ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).setVal([]);
|
|
||||||
}
|
|
||||||
|
|
||||||
executableData.forEach((e) {
|
|
||||||
if (e.intervalTime == 0) {
|
|
||||||
zhixinCall(e);
|
|
||||||
} else {
|
} else {
|
||||||
|
pendingData.addAll(_packagedHandwritingDataAll);
|
||||||
|
ref.read(jobHandwritingDrawingTrajectoryProvider.notifier).setVal([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
executableData.forEach((e) {
|
||||||
var ter = Timer(Duration(milliseconds: e.intervalTime ~/ speed), () => zhixinCall(e));
|
var ter = Timer(Duration(milliseconds: e.intervalTime ~/ speed), () => zhixinCall(e));
|
||||||
timers.add(ter);
|
timers.add(ter);
|
||||||
}
|
});
|
||||||
});
|
} catch (e) {
|
||||||
|
print('播放报错:$e');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算尺寸
|
// 计算尺寸
|
||||||
|
|
@ -761,7 +762,7 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
||||||
width: unitScale * (item.apart ?? 0),
|
width: unitScale * (item.apart ?? 0),
|
||||||
height: 8.h,
|
height: 8.h,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Color.fromRGBO(202, 201, 201, 1),
|
||||||
borderRadius: isFirst
|
borderRadius: isFirst
|
||||||
? BorderRadius.only(topLeft: Radius.circular(8.r), bottomLeft: Radius.circular(10.r))
|
? BorderRadius.only(topLeft: Radius.circular(8.r), bottomLeft: Radius.circular(10.r))
|
||||||
: (isLast ? BorderRadius.only(topRight: Radius.circular(8.r), bottomRight: Radius.circular(10.r)) : null),
|
: (isLast ? BorderRadius.only(topRight: Radius.circular(8.r), bottomRight: Radius.circular(10.r)) : null),
|
||||||
|
|
@ -780,7 +781,7 @@ Widget $bottomPlaybar(BuildContext context, int timeConsuming, int pauseCount, L
|
||||||
width: containerWidth,
|
width: containerWidth,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
// color: Color.fromRGBO(146, 146, 146, 1),
|
// color: Color.fromRGBO(146, 146, 146, 1),
|
||||||
color: Color.fromRGBO(202, 201, 201, 1),
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(50.r),
|
borderRadius: BorderRadius.circular(50.r),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -920,7 +921,8 @@ class UseBottomPlaybar with EventBusMixin {
|
||||||
// 播放按钮
|
// 播放按钮
|
||||||
class JobHandwritingPlaybarBus {
|
class JobHandwritingPlaybarBus {
|
||||||
bool play;
|
bool play;
|
||||||
JobHandwritingPlaybarBus(this.play);
|
bool recalculate;
|
||||||
|
JobHandwritingPlaybarBus(this.play, [this.recalculate = true]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 笔迹是否已经准备好(笔迹计算好坐标后通知通知栏可以开始播放)
|
// 笔迹是否已经准备好(笔迹计算好坐标后通知通知栏可以开始播放)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue