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

get metadata crashes #3

Open
LucaCoduriV opened this issue Nov 20, 2023 · 3 comments
Open

get metadata crashes #3

LucaCoduriV opened this issue Nov 20, 2023 · 3 comments

Comments

@LucaCoduriV
Copy link

LucaCoduriV commented Nov 20, 2023

I'm attempting to retrieve metadata for all players. However, I've encountered instances where a player doesn't possess any metadata, rendering the plugin ineffective. Is there a method to verify its existence?

Here is the error message:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a
 subtype of type 'DBusUint32' in type cast
#0      new Metadata.fromMap (package:mpris/mpris.dart:238:41)
#1      MPRISPlayer.getMetadata (package:mpris/mpris.dart:130:16)
<asynchronous suspension>

dart-mpris/lib/mpris.dart

Lines 230 to 253 in 503ac62

factory Metadata.fromMap(Map<String, DBusValue> map) => Metadata(
(map['mpris:trackid'] as DBusString).value,
(map['xesam:title'] as DBusString).value,
((map['xesam:artist'] as DBusArray).children)
.map((e) => (e as DBusString).value)
.toList(),
map['xesam:trackNumber'] is DBusInt32
? (map['xesam:trackNumber'] as DBusInt32).value
: (map['xesam:trackNumber'] as DBusUint32).value,
(map['xesam:url'] as DBusString).value,
Duration(
microseconds: map['mpris:length'] is DBusUint64
? (map['mpris:length'] as DBusUint64).value
: (map['mpris:length'] as DBusInt64).value,
),
(map['mpris:artUrl'] as DBusString).value,
(map['xesam:album'] as DBusString).value,
((map['xesam:albumArtist'] as DBusArray).children)
.map((e) => (e as DBusString).value)
.toList(),
map['xesam:discNumber'] is DBusInt32
? (map['xesam:discNumber'] as DBusInt32).value
: (map['xesam:discNumber'] as DBusUint32).value,
);

I'll try to fix it by myself and will make a pull request.

@LucaCoduriV
Copy link
Author

Upon reviewing various forks of your repository, I came across the following one: https://github.com/FlafyDev/dart-mpris. It appears to address the issue I encountered. I recommend incorporating these changes into your main repository by merging them.

@provokateurin
Copy link
Owner

Can you open a pull request for it? I don't understand why people make the effort to fork a repo and upload a fix but then don't upstream it 🤷‍♀️

@LucaCoduriV
Copy link
Author

LucaCoduriV commented Nov 20, 2023

Yep it's weird..
But here is my pull request #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants