Fix audio player state access for conditional imports to ensure compatibility across platforms
This commit is contained in:
@@ -120,7 +120,9 @@ class _AudioPlayerBarState extends State<AudioPlayerBar>
|
||||
await _audioPlayer.play(); // Start playback automatically
|
||||
// For mobile, check playing state after a short delay
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
if (_audioPlayer.playerState.playing) {
|
||||
// Use dynamic access to avoid compilation issues with conditional imports
|
||||
final player = _audioPlayer as dynamic;
|
||||
if (player.playerState?.playing == true) {
|
||||
if (mounted) _iconController.forward();
|
||||
} else {
|
||||
setState(() {
|
||||
@@ -145,7 +147,9 @@ class _AudioPlayerBarState extends State<AudioPlayerBar>
|
||||
_position = pos;
|
||||
});
|
||||
});
|
||||
_audioPlayer.playerStateStream.listen((state) {
|
||||
// Use dynamic access to avoid compilation issues with conditional imports
|
||||
final player = _audioPlayer as dynamic;
|
||||
player.playerStateStream.listen((state) {
|
||||
setState(() {
|
||||
_isPlaying = state.playing;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user