bluefireteam / audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
https://pub.dartlang.org/packages/audioplayers
MIT License
1.98k stars 843 forks source link

Audioplayer doesn't start #28

Closed klinki closed 3 years ago

klinki commented 6 years ago

Hello,

I have a problem with audioplayer. It doesn't start playing and calls onComplete callback right away.

Here is log, if it helps:

Launching lib\main.dart on GT I9195 in debug mode... C:\Users\david\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\audioplayers-0.7.3\android\src\main\java\xyz\luan\audioplayers\WrappedMediaPlayer.java:204: warning: [deprecation] setAudioStreamType(int) in MediaPlayer has been deprecated player.setAudioStreamType(AudioManager.STREAM_MUSIC); ^ 1 warning Built build\app\outputs\apk\debug\app-debug.apk. I/FlutterActivityDelegate(25121): onResume setting current activity to this I/Choreographer(25121): Skipped 94 frames! The application may be doing too much work on its main thread. E/dalvikvm(25121): Could not find class 'android.media.AudioAttributes$Builder', referenced from method xyz.luan.audioplayers.WrappedMediaPlayer.createPlayer W/dalvikvm(25121): VFY: unable to resolve new-instance 38 (Landroid/media/AudioAttributes$Builder;) in Lxyz/luan/audioplayers/WrappedMediaPlayer; D/dalvikvm(25121): VFY: replacing opcode 0x22 at 0x0012 D/dalvikvm(25121): DexOpt: unable to opt direct call 0x004e at 0x14 in Lxyz/luan/audioplayers/WrappedMediaPlayer;.createPlayer V/MediaPlayer-JNI(25121): native_setup V/MediaPlayer(25121): constructor V/MediaPlayer(25121): setListener V/MediaPlayer-JNI(25121): setAudioStreamType: 3 V/MediaPlayer(25121): MediaPlayer::setAudioStreamType V/MediaPlayer-JNI(25121): setVolume: left 1.000000 right 1.000000 V/MediaPlayer(25121): MediaPlayer::setVolume(1.000000, 1.000000) V/MediaPlayer-JNI(25121): setLooping: 0 V/MediaPlayer(25121): MediaPlayer::setLooping V/MediaPlayer(25121): message received msg=8, ext1=0, ext2=0 V/MediaPlayer(25121): notify(8, 0, 0) callback on disconnected mediaplayer V/MediaPlayer-JNI(25121): setVolume: left 1.000000 right 1.000000 V/MediaPlayer(25121): MediaPlayer::setVolume(1.000000, 1.000000) V/MediaPlayer-JNI(25121): setLooping: 0 V/MediaPlayer(25121): MediaPlayer::setLooping V/MediaPlayer(25121): setVideoSurfaceTexture V/MediaPlayer(25121): prepareAsync V/MediaPlayer(25121): message received msg=100, ext1=1, ext2=-1004 E/MediaPlayer(25121): error (1, -1004) V/MediaPlayer(25121): callback application V/MediaPlayer(25121): back from callback E/MediaPlayer(25121): Error (1,-1004) V/MediaPlayer-JNI(25121): stop V/MediaPlayer(25121): stop E/MediaPlayer(25121): stop called in state 0 V/MediaPlayer(25121): message received msg=100, ext1=-38, ext2=0 E/MediaPlayer(25121): error (-38, 0) V/MediaPlayer(25121): callback application V/MediaPlayer(25121): back from callback V/MediaPlayer-JNI(25121): reset V/MediaPlayer(25121): reset V/MediaPlayer(25121): message received msg=8, ext1=0, ext2=0 V/MediaPlayer(25121): notify(8, 0, 0) callback on disconnected mediaplayer V/MediaPlayer-JNI(25121): release V/MediaPlayer(25121): setListener V/MediaPlayer(25121): disconnect V/MediaPlayer(25121): destructor V/MediaPlayer(25121): disconnect I/flutter (25121): _platformCallHandler call audio.onComplete {value: true, playerId: 4e53b7f9-5f74-4001-bce7-bb3e666b6332} V/MediaPlayer-JNI(25121): native_setup V/MediaPlayer(25121): constructor V/MediaPlayer(25121): setListener V/MediaPlayer-JNI(25121): setAudioStreamType: 3 V/MediaPlayer(25121): MediaPlayer::setAudioStreamType V/MediaPlayer-JNI(25121): setVolume: left 1.000000 right 1.000000 V/MediaPlayer(25121): MediaPlayer::setVolume(1.000000, 1.000000) V/MediaPlayer-JNI(25121): setLooping: 0 V/MediaPlayer(25121): MediaPlayer::setLooping V/MediaPlayer(25121): message received msg=8, ext1=0, ext2=0 V/MediaPlayer(25121): notify(8, 0, 0) callback on disconnected mediaplayer V/MediaPlayer(25121): setVideoSurfaceTexture V/MediaPlayer(25121): prepareAsync V/MediaPlayer(25121): message received msg=100, ext1=1, ext2=-1004 E/MediaPlayer(25121): error (1, -1004) V/MediaPlayer(25121): callback application V/MediaPlayer(25121): back from callback E/MediaPlayer(25121): Error (1,-1004) V/MediaPlayer-JNI(25121): stop V/MediaPlayer(25121): stop E/MediaPlayer(25121): stop called in state 0 V/MediaPlayer(25121): message received msg=100, ext1=-38, ext2=0 E/MediaPlayer(25121): error (-38, 0) V/MediaPlayer(25121): callback application V/MediaPlayer(25121): back from callback V/MediaPlayer-JNI(25121): reset V/MediaPlayer(25121): reset V/MediaPlayer(25121): message received msg=8, ext1=0, ext2=0 V/MediaPlayer(25121): notify(8, 0, 0) callback on disconnected mediaplayer V/MediaPlayer-JNI(25121): release V/MediaPlayer(25121): setListener V/MediaPlayer(25121): disconnect V/MediaPlayer(25121): destructor V/MediaPlayer(25121): disconnect I/flutter (25121): _platformCallHandler call audio.onComplete {value: true, playerId: 4e53b7f9-5f74-4001-bce7-bb3e666b6332}

luanpotter commented 6 years ago

This is on Android, correct? So not the iOS/headphone problem. Other audio sources work? Did you try with different files and options? Is it Local file mode?

klinki commented 6 years ago

Hello, yes, it is Android. I think I found out what was the problem - playing a remote file with disabled internet connectivity. But I think it should not call onComplete but rather throw some exception or call onError.

luanpotter commented 6 years ago

Agreed, maybe there is an exception being catch somewhere and then the player thinks it's completed, when in reality it should throw an error. If you'd like to take a look and contribute with a PR, it'll be very appreciated! Otherwise I might take a look at this soon-ish :)

klinki commented 6 years ago

Sure, I will have a look and try to come with some PR. Probably this or next weekend, I hope.

amenski commented 4 years ago

Hi guys, did you have success patching this issue? In my case it happens even with working internet. printing " _platformCallHandler call audio.onComplete {value: true, playerId: ef1abaca-5980-4b65-8b3f-0c58a71985b2}" immediately. I don't know if it is the file type(wma), since it is not happening for mp3. I know that it is supported in android. Thank you.

erickzanardo commented 3 years ago

Closing due inactivity