-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added listenbrainz scrobbling support
- Loading branch information
1 parent
ece6b6d
commit a724eae
Showing
12 changed files
with
239 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:listenbrainz_dart/listenbrainz_dart.dart'; | ||
|
||
import '../common/logging.dart'; | ||
import '../settings/settings_service.dart'; | ||
|
||
class ListenBrainzService { | ||
ListenBrainzService({required SettingsService settingsService}) | ||
: _settingsService = settingsService; | ||
|
||
final SettingsService _settingsService; | ||
ListenBrainz? _listenBrainz; | ||
|
||
void init() { | ||
final apiKey = _settingsService.listenBrainzApiKey; | ||
if (apiKey != null) { | ||
_listenBrainz = ListenBrainz(apiKey); | ||
} | ||
} | ||
|
||
Future<void> exposeTrackToListenBrainz({ | ||
required String title, | ||
required String artist, | ||
}) async { | ||
try { | ||
if (_listenBrainz != null && | ||
_settingsService.enableListenBrainzScrobbling) { | ||
await _listenBrainz!.submitSingle( | ||
Track(title: title, artist: artist), | ||
DateTime.now(), | ||
); | ||
} | ||
} on Exception catch (e) { | ||
printMessageInDebugMode(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.