Skip to content

Commit

Permalink
fix(android): avoid emitting track changed when replaying the same track
Browse files Browse the repository at this point in the history
  • Loading branch information
puckey committed Jul 13, 2023
1 parent c40e889 commit 6a551f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,13 @@ class MusicService : HeadlessJsTaskService() {

scope.launch {
event.audioItemTransition.collect {
var lastIndex: Int? = null
if (it is AudioItemTransitionReason.REPEAT) {
lastIndex = player.currentIndex
} else if (player.previousItem != null) {
lastIndex = player.previousIndex
if (!(it is AudioItemTransitionReason.REPEAT)) {
emitPlaybackTrackChangedEvents(
player.currentIndex,
player.previousIndex,
(it?.oldPosition ?: 0).toSeconds()
)
}
var lastPosition = (it?.oldPosition ?: 0).toSeconds();
emitPlaybackTrackChangedEvents(player.currentIndex, lastIndex, lastPosition)
}
}

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/v4-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ instead of `null`
1. `getPosition()` - Please use the `position` property returned by [`getProgress()`](./api/functions/player.md#getprogress).
1. `getBufferedPosition()` - Please use the `buffered` property returned by [`getProgress()`](./api/functions/player.md#getprogress).
1. `getCurrentTrack()` - Please use [`getActiveTrackIndex()`](./api/functions/queue.md#getactivetrackindex).
1. `Event.PlaybackTrackChanged` - Please use [`Event.PlaybackActiveTrackChanged`](./api/events.md#playbackactivetrackchanged).
1. `Event.PlaybackTrackChanged` - Please use [`Event.PlaybackActiveTrackChanged`](./api/events.md#playbackactivetrackchanged). Also note that in 4.0 `Event.PlaybackTrackChanged` is no longer emitted when a track repeats.

### Typescript Imports

Expand Down

0 comments on commit 6a551f6

Please sign in to comment.