@@ -145,7 +145,7 @@ class PlayerManager {
145145 await switchEngine (_defaultEngine! , isManual: false );
146146 }
147147 final player = _currentPlayer;
148- _isSwitchingDueToFallback = false ;
148+
149149 if (player == null ) {
150150 throw PlayerException (message: 'Current player is null' , type: PlayerErrorType .lifecycle);
151151 }
@@ -168,6 +168,8 @@ class PlayerManager {
168168 final exception = PlayerException (message: 'Play failed' , type: PlayerErrorType .unknown, error: e, stackTrace: s);
169169
170170 await _handleError (exception);
171+ } finally {
172+ _isSwitchingDueToFallback = false ;
171173 }
172174 }
173175
@@ -383,21 +385,14 @@ class PlayerManager {
383385 }
384386
385387 Future <void > hardDispose () async {
386- final player = _currentPlayer;
387- if (player != null ) {
388- await player.hardDispose ();
389- }
390- if (_runtimeEngine != null ) {
391- await playerPool.removeFromCache (_runtimeEngine! );
392- }
393-
394388 // 清空 Dart 引用
395389 _currentPlayer = null ;
396390 _runtimeEngine = null ;
397391
398392 // 重置状态
399393 _stateSubject.add (PlayerState .idle);
400394 _playingSubject.add (false );
395+ await dispose ();
401396 }
402397
403398 // =========================
@@ -490,6 +485,10 @@ class PlayerManager {
490485
491486 if (event) {
492487 _stateSubject.add (PlayerState .playing);
488+ if (_isSwitchingDueToFallback) {
489+ _errorCount = 0 ;
490+ _isSwitchingDueToFallback = false ;
491+ }
493492 } else {
494493 _stateSubject.add (PlayerState .paused);
495494 }
0 commit comments