Skip to content

Commit

Permalink
fix sustain playing state while skippink next/prev
Browse files Browse the repository at this point in the history
  • Loading branch information
HemantKArya committed Feb 2, 2024
1 parent bd89486 commit 827ee15
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/services/bloomeePlayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class BloomeeMusicPlayer extends BaseAudioHandler
BehaviorSubject<String> currentQueueName =
BehaviorSubject<String>.seeded("Empty");
int currentPlayingIdx = 0;
bool isPaused = false;

CancelableOperation<List<String>> getLinkOperation =
CancelableOperation.fromFuture(Future.value([]));
Expand Down Expand Up @@ -62,6 +63,7 @@ class BloomeeMusicPlayer extends BaseAudioHandler
@override
Future<void> play() async {
await audioPlayer.play();
isPaused = false;
// log("playing", name: "bloomeePlayer");
}

Expand All @@ -86,13 +88,14 @@ class BloomeeMusicPlayer extends BaseAudioHandler
@override
Future<void> pause() async {
await audioPlayer.pause();
isPaused = true;
log("paused", name: "bloomeePlayer");
}

@override
Future<void> playMediaItem(MediaItem mediaItem) async {
// log(mediaItem.extras?["url"], name: "bloomeePlayer");
bool isPlaying = audioPlayer.playing;
// bool isPlaying = audioPlayer.playing;
updateMediaItem(mediaItem);
if (mediaItem.extras?["source"] == "youtube") {
audioPlayer.seek(Duration.zero);
Expand All @@ -111,7 +114,7 @@ class BloomeeMusicPlayer extends BaseAudioHandler

getLinkOperation.then((tempStrmLinks) {
audioPlayer.setUrl(tempStrmLinks.first).then((value) {
if (super.mediaItem.value?.id == mediaItem.id && isPlaying) {
if (super.mediaItem.value?.id == mediaItem.id && !isPaused) {
audioPlayer.play();
}
});
Expand Down

0 comments on commit 827ee15

Please sign in to comment.