ryanheise / audio_service

Flutter plugin to play audio in the background while the screen is off.
796 stars 476 forks source link

Codec exception when artUri is defined for MediaItem #6

Closed alexantenna closed 5 years ago

alexantenna commented 5 years ago

Hello.

In my app I have cover art files stored for each album, they're accessible via url, for example: http://antennaria.rocks/music/artwork/ecovillage/sacred_world_1d00e34d24e43b4b9bfc1c241f45300a_250x250.jpg

Trying to use setMediaItem(item) method with artUri set to such url (actually, any url I've tried) results in the following exception:

D/AndroidRuntime( 9000): Shutting down VM
E/AndroidRuntime( 9000): FATAL EXCEPTION: main
E/AndroidRuntime( 9000): Process: com.antennaria.gimpobox, PID: 9000
E/AndroidRuntime( 9000): java.lang.IllegalArgumentException: Unsupported value: http://antennaria.rocks/music/artwork/ecovillage/sacred_world_1d00e34d24e43b4b9bfc1c241f45300a_250x250.jpg
E/AndroidRuntime( 9000):    at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:293)
E/AndroidRuntime( 9000):    at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:290)
E/AndroidRuntime( 9000):    at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:282)
E/AndroidRuntime( 9000):    at io.flutter.plugin.common.StandardMethodCodec.encodeMethodCall(StandardMethodCodec.java:36)
E/AndroidRuntime( 9000):    at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:83)
E/AndroidRuntime( 9000):    at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:70)
E/AndroidRuntime( 9000):    at com.ryanheise.audioservice.AudioServicePlugin$ClientHandler.invokeMethod(AudioServicePlugin.java:417)
E/AndroidRuntime( 9000):    at com.ryanheise.audioservice.AudioServicePlugin$ClientHandler$1.onMetadataChanged(AudioServicePlugin.java:71)
E/AndroidRuntime( 9000):    at android.support.v4.media.session.MediaControllerCompat$Callback$StubApi21.onMetadataChanged(MediaControllerCompat.java:832)
E/AndroidRuntime( 9000):    at android.support.v4.media.session.MediaControllerCompatApi21$CallbackProxy.onMetadataChanged(MediaControllerCompatApi21.java:297)
E/AndroidRuntime( 9000):    at android.media.session.MediaController$MessageHandler.handleMessage(MediaController.java:1089)
E/AndroidRuntime( 9000):    at android.os.Handler.dispatchMessage(Handler.java:108)
E/AndroidRuntime( 9000):    at android.os.Looper.loop(Looper.java:166)
E/AndroidRuntime( 9000):    at android.app.ActivityThread.main(ActivityThread.java:7425)
E/AndroidRuntime( 9000):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9000):    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
E/AndroidRuntime( 9000):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
I/Process ( 9000): Sending signal. PID: 9000 SIG: 9
Lost connection to device.

To be sure that url is valid I've used Uri.encodeFull() but no avail. Also I've tried to put hard-coded urls to various images from the internet to no avail as well.

Did you try artUri functionality by yourself? Did it work at all? What I do wrong?

ryanheise commented 5 years ago

I did break it accidentally in 0.0.7 but it should be working again in 0.0.8. Let me know how it goes.

alexantenna commented 5 years ago

Still doesn't work :-(

ryanheise commented 5 years ago

Hmm, are you definitely running the latest release? i.e. If you're getting it from the package server, update pubspec.yaml and run flutter packages upgrade.

That is definitely the same error message I fixed and it has to do with the supported types of data that can be sent over the method channel. II was sending a Uri object rather than a String in 0.0.7 and now it sends a String in 0.0.8.

alexantenna commented 5 years ago

Looks like plugin was cached or something... Upgrading from 0.0.8 to 0.0.10, deleting .dart-tool and build folders when recompiling fixed the issue. Thanks. Closing.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.