audio_service icon indicating copy to clipboard operation
audio_service copied to clipboard

Uint8List support for arturi

Open HadiWannous opened this issue 1 year ago • 2 comments

Feature proposal

i need the mediaItem support for uint8list as audio artwork...there is no working way to parse it in uri form

Motivating use case(s)

supporting fetched data from audio file to make the artwork appear in the notification

HadiWannous avatar Aug 09 '24 15:08 HadiWannous

You can write the data to a file and then use a file URI.

ryanheise avatar Aug 09 '24 15:08 ryanheise

Currently working on an implementation using a file and the following error has occured:

D/HWUI    (12310): --- Failed to create image decoder with message 'unimplemented'
W/System.err(12310): java.lang.NullPointerException: key == null || value == null
W/System.err(12310): 	at android.util.LruCache.put(LruCache.java:171)
W/System.err(12310): 	at com.ryanheise.audioservice.AudioService.loadArtBitmap(AudioService.java:241)
W/System.err(12310): 	at com.ryanheise.audioservice.AudioService.setMetadata(AudioService.java:801)
W/System.err(12310): 	at com.ryanheise.audioservice.AudioServicePlugin$AudioHandlerInterface.lambda$onMethodCall$2$com-ryanheise-audioservice-AudioServicePlugin$AudioHandlerInterface(AudioServicePlugin.java:842)
W/System.err(12310): 	at com.ryanheise.audioservice.AudioServicePlugin$AudioHandlerInterface$$ExternalSyntheticLambda4.run(Unknown Source:6)
W/System.err(12310): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
W/System.err(12310): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
W/System.err(12310): 	at java.lang.Thread.run(Thread.java:1012)

My code looks like this:

final File file = File(path);
file.writeAsBytesSync(data.buffer.asUint8List());
MediaItem item = MediaItem(
      id: song.id.toString(),
      album: song.album,
      title: song.title,
      artist: song.artist,
      duration: Duration(milliseconds: song.duration ?? 0),
      artUri: file.uri,
);
mediaItem.add(item);

Any idea why this wouldn't work? Or why the error? The same thing works on Linux, but on Android it raises this error.

SDarius22 avatar Jan 05 '25 23:01 SDarius22