Skip to content

Commit

Permalink
[Chore] Add some comment and log.
Browse files Browse the repository at this point in the history
  • Loading branch information
canxin121 committed May 13, 2024
1 parent 51c19da commit c5f4dc2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/util/audio_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'package:toastification/toastification.dart';
// Windows 平台的just_audio实现存在bug
bool isWindowsFirstPlay = true;


late AudioHandler globalAudioHandler;
late AudioUiController globalAudioUiController;

Expand Down Expand Up @@ -165,6 +164,8 @@ class AudioHandler extends GetxController {

Future<void> clearReplaceMusicAll(
BuildContext context, List<DisplayMusic> musics) async {
// 这个函数功能无法承受并发,必须上锁
var startTime = DateTime.now();
if (_isClearReplaceMusicAllRunning) {
toast(context, "Music Player", "上一全部播放还未结束", ToastificationType.error);
return;
Expand Down Expand Up @@ -229,6 +230,9 @@ class AudioHandler extends GetxController {
globalFloatWidgetContoller.delMsg(index);
}
_isClearReplaceMusicAllRunning = false;
var endTime = DateTime.now();
talker.log(
"[Music Handler] 播放全部耗时: ${endTime.difference(startTime).inSeconds}s");
}
}

Expand Down Expand Up @@ -295,6 +299,7 @@ class AudioHandler extends GetxController {

Future<void> play() async {
try {
// 直接运行在某些平台会导致完全无理由的中断后续代码执行,甚至没有任何报错或者返回(当然也不是阻塞)
Future.microtask(() => _player.play());
// talker.info("[Music Handler] In play, succeed");
} catch (e) {
Expand Down

0 comments on commit c5f4dc2

Please sign in to comment.