setActivePlayer method
Set player as active, pausing previous one if needed.
Implementation
Future<void> setActivePlayer(AudioPlayer player, {required String id}) async {
if (_activePlayer != null && _activePlayer != player) {
try {
await _activePlayer!.pause();
} catch (_) {}
if (_activeId != null) {
// mark old one as stopped in its state
final oldState = _states[_activeId!];
if (oldState != null) oldState.isPlaying = false;
// and notify its UI
_notifyStop(_activeId!);
}
}
_activePlayer = player;
_activeId = id;
}