|
|
@@ -9,7 +9,6 @@ import 'package:location/base/base_controller.dart';
|
|
|
import 'package:location/data/bean/user_info.dart';
|
|
|
import 'package:location/data/repositories/track_repository.dart';
|
|
|
import 'package:location/sdk/map/map_helper.dart';
|
|
|
-import 'package:location/utils/atmob_log.dart';
|
|
|
import 'package:lottie/lottie.dart';
|
|
|
import 'package:video_player/video_player.dart';
|
|
|
import '../../data/bean/stream_chat_origin_data.dart';
|
|
|
@@ -69,12 +68,9 @@ class LocationAnalyseController extends BaseController
|
|
|
AnimationController(vsync: this);
|
|
|
|
|
|
Timer? _loopTimer;
|
|
|
- bool _triggerFinalLoop = false;
|
|
|
|
|
|
- //视频播放总长度 8175毫秒
|
|
|
- Duration videoTotalDuration = const Duration(milliseconds: 8175);
|
|
|
- Duration loopStart = const Duration(milliseconds: 5670);
|
|
|
- Duration loopEnd = const Duration(milliseconds: 6570);
|
|
|
+ Duration loopStart = const Duration(milliseconds: 0);
|
|
|
+ Duration loopEnd = const Duration(milliseconds: 5032);
|
|
|
|
|
|
LocationAnalyseController(this.trackRepository);
|
|
|
|
|
|
@@ -86,7 +82,6 @@ class LocationAnalyseController extends BaseController
|
|
|
_getErrorAddr();
|
|
|
|
|
|
graduallyController.setGraduallyFinishedListener(() {
|
|
|
- _isRequestedAnalyse.value = true;
|
|
|
_isRequestingStream = false;
|
|
|
});
|
|
|
|
|
|
@@ -96,8 +91,6 @@ class LocationAnalyseController extends BaseController
|
|
|
..setVolume(0.0)
|
|
|
..initialize().then((_) {
|
|
|
_videoReady.value = true;
|
|
|
- locaController.play();
|
|
|
- AtmobLog.d('zk', "duration:${locaController.value.duration}");
|
|
|
_startMonitorLoop();
|
|
|
}).catchError((error) {
|
|
|
debugPrint('Error initializing video: $error');
|
|
|
@@ -105,26 +98,13 @@ class LocationAnalyseController extends BaseController
|
|
|
}
|
|
|
|
|
|
void _startMonitorLoop() {
|
|
|
+ locaController.play();
|
|
|
_loopTimer =
|
|
|
Timer.periodic(const Duration(milliseconds: 100), (timer) async {
|
|
|
final position = await locaController.position;
|
|
|
if (position == null) return;
|
|
|
-
|
|
|
- // 第一阶段:0~6s,播放完成后进入循环
|
|
|
- if (!_triggerFinalLoop) {
|
|
|
- if (position >= loopEnd) {
|
|
|
- // 循环 4~6s
|
|
|
- locaController.seekTo(loopStart);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 第二阶段:触发后进入 6~8s 循环
|
|
|
- if (loopStart != const Duration(seconds: 6)) {
|
|
|
- loopStart = const Duration(seconds: 6);
|
|
|
- loopEnd = videoTotalDuration;
|
|
|
- }
|
|
|
- if (position >= loopEnd) {
|
|
|
- locaController.seekTo(loopStart);
|
|
|
- }
|
|
|
+ if (position >= loopEnd) {
|
|
|
+ locaController.seekTo(loopStart);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -171,6 +151,11 @@ class LocationAnalyseController extends BaseController
|
|
|
}
|
|
|
|
|
|
void onTrackRefreshClick() {
|
|
|
+ if (_isRequestingStream) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _startMonitorLoop();
|
|
|
+ _startKeywordLottieAnimation();
|
|
|
_analyseErrorAddr();
|
|
|
}
|
|
|
|
|
|
@@ -255,18 +240,25 @@ class LocationAnalyseController extends BaseController
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- void locationKeywordLottieLoad(LottieComposition composition) async {
|
|
|
+ void locationKeywordLottieLoad(LottieComposition composition) {
|
|
|
keywordLottieController.duration = composition.duration;
|
|
|
+ _startKeywordLottieAnimation();
|
|
|
+ }
|
|
|
+
|
|
|
+ void _startKeywordLottieAnimation() async {
|
|
|
await keywordLottieController.animateTo(0.84);
|
|
|
keywordLottieController.repeat(min: 0, max: 0.84, reverse: true);
|
|
|
}
|
|
|
|
|
|
- void _setAnalyseSuccess() {
|
|
|
- keywordLottieController.animateTo(1);
|
|
|
+ void _setAnalyseSuccess() async {
|
|
|
+ _loopTimer?.cancel();
|
|
|
+ await keywordLottieController.animateTo(1);
|
|
|
+ _isRequestedAnalyse.value = true;
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
void onClose() {
|
|
|
+ _loopTimer?.cancel();
|
|
|
_streamSubscription?.cancel();
|
|
|
keywordLottieController.dispose();
|
|
|
super.onClose();
|