-
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.
feat: add listenbrainz scrobbling support (#1047)
* Added listenbrainz scrobbling support
- Loading branch information
1 parent
ece6b6d
commit 6ff4723
Showing
13 changed files
with
246 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
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,38 @@ | ||
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) { | ||
final track = Track(title: title, artist: artist); | ||
await _listenBrainz!.submitSingle( | ||
track, | ||
DateTime.now(), | ||
); | ||
await _listenBrainz!.submitPlayingNow(track); | ||
} | ||
} 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.