rxlabz / audioplayer

A flutter plugin to play audio files iOS / Android / MacOS / Web ( Swift/Java )
https://pub.dartlang.org/packages/audioplayer
494 stars 189 forks source link

how receive Bluetooth headset control cmd? #147

Open gateshibill opened 3 years ago

gateshibill commented 3 years ago

the phone is connected Bluetooth headset,headset can play and pause,but i don't kown audioplayer how to work

gateshibill commented 2 years ago

I hava the same question, other player can receice bluetooth cmd.

moda20 commented 2 years ago

For bluetooth commands and any other media commands ( controllers, wire headphones, ...) you can check my fork of this library. https://github.com/moda20/audioplayer It is outdated a little bit compared to this one especially for the iOS side, but for android the command listeners are well implemented.

gateshibill commented 2 years ago

For bluetooth commands and any other media commands ( controllers, wire headphones, ...) you can check my fork of this library. https://github.com/moda20/audioplayer It is outdated a little bit compared to this one especially for the iOS side, but for android the command listeners are well implemented.

thank moda20, you provide audioplayer is different to rxlabz/audioplayer,it has no the audioPlayer.onPlaybackKeyEvent(). if I use your audioplayer ,will I do more code to adapt it?

moda20 commented 2 years ago

it has onPlaybackKeyEvent. check the docs on the repo. my version shouldn't be much different from this repo.

gateshibill commented 2 years ago

rxlabz/audioplayer doesn't have onPlaybackKeyEvent,

gateshibill commented 2 years ago

it has onPlaybackKeyEvent. check the docs on the repo. my version shouldn't be much different from this repo. moda20/audioplayer is very good,has the onPlaybackKeyEvent. i am using it instead of rxlabz/audioplayer. i don't know it whether include all featrues rxlabz/audioplayer has.

gateshibill commented 2 years ago

W/Choreographer(15953): Frame time is 17.409424 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase. W/Choreographer(15953): Frame time is 16.27997 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase. D/ViewRootImpl(15953): DisplayId = 0 I/MediaBrowserService(15953): No root for client com.android.bluetooth from service android.service.media.MediaBrowserService$ServiceBinder$1 D/AndroidRuntime(15953): Shutting down VM E/AndroidRuntime(15953): FATAL EXCEPTION: main E/AndroidRuntime(15953): Process: com.freejoy.music, PID: 15953 E/AndroidRuntime(15953): java.lang.RuntimeException: Unable to stop service bz.rxla.audioplayer.AudioplayerPlugin@40c9b0d: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.session.MediaSession.release()' on a null object reference E/AndroidRuntime(15953): at android.app.ActivityThread.handleStopService(ActivityThread.java:4048) E/AndroidRuntime(15953): at android.app.ActivityThread.access$1900(ActivityThread.java:233) E/AndroidRuntime(15953): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1917) E/AndroidRuntime(15953): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(15953): at android.os.Looper.loop(Looper.java:233) E/AndroidRuntime(15953): at android.app.ActivityThread.main(ActivityThread.java:7225) E/AndroidRuntime(15953): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(15953): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499) E/AndroidRuntime(15953): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:962) E/AndroidRuntime(15953): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.session.MediaSession.release()' on a null object reference E/AndroidRuntime(15953): at bz.rxla.audioplayer.AudioplayerPlugin.onDestroy(AudioplayerPlugin.java:199) E/AndroidRuntime(15953): at android.app.ActivityThread.handleStopService(ActivityThread.java:4028) E/AndroidRuntime(15953): ... 8 more I/Process (15953): Sending signal. PID: 15953 SIG: 9 Lost connection to device.

gateshibill commented 2 years ago

it has onPlaybackKeyEvent. check the docs on the repo. my version shouldn't be much different from this repo.

with moda20/audioplayer ,app collapse when the Bluetooth switch of the mobile phone is switched,from close to open. if with rxlabz/audioplayer,it it normal.

log as the following: W/Choreographer(15953): Frame time is 17.409424 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase. W/Choreographer(15953): Frame time is 16.27997 ms in the future! Check that graphics HAL is generating vsync timestamps using the correct timebase. D/ViewRootImpl(15953): DisplayId = 0 I/MediaBrowserService(15953): No root for client com.android.bluetooth from service android.service.media.MediaBrowserService$ServiceBinder$1 D/AndroidRuntime(15953): Shutting down VM E/AndroidRuntime(15953): FATAL EXCEPTION: main E/AndroidRuntime(15953): Process: com.freejoy.music, PID: 15953 E/AndroidRuntime(15953): java.lang.RuntimeException: Unable to stop service bz.rxla.audioplayer.AudioplayerPlugin@40c9b0d: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.session.MediaSession.release()' on a null object reference E/AndroidRuntime(15953): at android.app.ActivityThread.handleStopService(ActivityThread.java:4048) E/AndroidRuntime(15953): at android.app.ActivityThread.access$1900(ActivityThread.java:233) E/AndroidRuntime(15953): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1917) E/AndroidRuntime(15953): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(15953): at android.os.Looper.loop(Looper.java:233) E/AndroidRuntime(15953): at android.app.ActivityThread.main(ActivityThread.java:7225) E/AndroidRuntime(15953): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(15953): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499) E/AndroidRuntime(15953): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:962) E/AndroidRuntime(15953): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.session.MediaSession.release()' on a null object reference E/AndroidRuntime(15953): at bz.rxla.audioplayer.AudioplayerPlugin.onDestroy(AudioplayerPlugin.java:199) E/AndroidRuntime(15953): at android.app.ActivityThread.handleStopService(ActivityThread.java:4028) E/AndroidRuntime(15953): ... 8 more I/Process (15953): Sending signal. PID: 15953 SIG: 9 Lost connection to device.