mod: playCount calc

This commit is contained in:
guozhigq
2024-04-27 15:32:05 +08:00
parent 1f1d4fe5e9
commit d8699c2985
4 changed files with 19 additions and 17 deletions

View File

@ -101,7 +101,7 @@ class PlPlayerController {
bool _isFirstTime = true;
Timer? _timer;
late Timer? _timerForSeek;
Timer? _timerForSeek;
Timer? _timerForVolume;
Timer? _timerForShowingVolume;
Timer? _timerForGettingVolume;
@ -335,8 +335,10 @@ class PlPlayerController {
}) {
// 如果实例尚未创建,则创建一个新实例
_instance ??= PlPlayerController._();
_instance!._playerCount.value += 1;
_videoType.value = videoType;
if (videoType != 'none') {
_instance!._playerCount.value += 1;
_videoType.value = videoType;
}
return _instance!;
}
@ -1120,9 +1122,6 @@ class PlPlayerController {
}
Future<void> dispose({String type = 'single'}) async {
print('dispose');
print('dispose: ${playerCount.value}');
// 每次减1最后销毁
if (type == 'single' && playerCount.value > 1) {
_playerCount.value -= 1;
@ -1132,7 +1131,6 @@ class PlPlayerController {
}
_playerCount.value = 0;
try {
print('dispose dispose ---------');
_timer?.cancel();
_timerForVolume?.cancel();
_timerForGettingVolume?.cancel();