Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assetsAudioPlayer has error #834

Open
NegarTavakol opened this issue May 20, 2024 · 0 comments
Open

assetsAudioPlayer has error #834

NegarTavakol opened this issue May 20, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@NegarTavakol
Copy link

class AudioPlayer extends StatefulWidget {
final String audioPath;

const AudioPlayer({Key? key, required this.audioPath}) : super(key: key);

@OverRide
AudioPlayerState createState() => AudioPlayerState();
}

class AudioPlayerState extends State {
final AssetsAudioPlayer _assetsAudioPlayer = AssetsAudioPlayer();
bool _isPlaying = false;

@OverRide
void initState() {
super.initState();
_initAudioPlayer();
}

@OverRide
void dispose() {
_assetsAudioPlayer.dispose();
super.dispose();
}

Future _initAudioPlayer() async {
await _assetsAudioPlayer.open(Audio.file(widget.audioPath), autoStart: false);
_assetsAudioPlayer.isPlaying.listen((isPlaying) {
setState(() {
_isPlaying = isPlaying;
});
});
}

@OverRide
Widget build(BuildContext context) {
return ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.indigoAccent),
shape: MaterialStateProperty.all(
CircleBorder(),
),
),
onPressed: () {
if (_isPlaying) {
_assetsAudioPlayer.pause();
} else {
_assetsAudioPlayer.play();
}
},
child: Icon(
_isPlaying ? Icons.pause : Icons.play_arrow,
size: 32,
color:Colors.orangeAccent,
),
);
}
} I try to play some audio file with mp3. format , some of them can be played some others can not be played. And these errors in console appear. is there anybody to help me for fixing it?

V/MediaPlayer-JNI(23734): native_setup
V/MediaPlayerNative(23734): constructor
V/MediaPlayerNative(23734): setListener
V/MediaPlayer-JNI(23734): reset
V/MediaPlayerNative(23734): reset
V/MediaPlayer(23734): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(23734): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer(23734): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(23734): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer-JNI(23734): release
V/MediaPlayerNative(23734): setListener
V/MediaPlayerNative(23734): disconnect
V/MediaPlayerNative(23734): destructor
V/MediaPlayerNative(23734): disconnect
W/System.err(23734): com.github.florent37.assets_audio_player.playerimplem.PlayerFinder$NoPlayerFoundException
W/System.err(23734): at com.github.florent37.assets_audio_player.playerimplem.PlayerFinder._findWorkingPlayer(PlayerFinder.kt:70)
W/System.err(23734): at com.github.florent37.assets_audio_player.playerimplem.PlayerFinder._findWorkingPlayer(PlayerFinder.kt:88)
W/System.err(23734): at com.github.florent37.assets_audio_player.playerimplem.PlayerFinder.access$_findWorkingPlayer(PlayerFinder.kt:26)
W/System.err(23734): at com.github.florent37.assets_audio_player.playerimplem.PlayerFinder$_findWorkingPlayer$1.invokeSuspend(Unknown Source:15)
W/System.err(23734): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
W/System.err(23734): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
W/System.err(23734): at android.os.Handler.handleCallback(Handler.java:938)
W/System.err(23734): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(23734): at android.os.Looper.loop(Looper.java:246)
W/System.err(23734): at android.app.ActivityThread.main(ActivityThread.java:8653)
W/System.err(23734): at java.lang.reflect.Method.invoke(Native Method)
W/System.err(23734): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
W/System.err(23734): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
I/flutter (23734):
@NegarTavakol NegarTavakol added the bug Something isn't working label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants