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

[4.0.0-rc05] Inconsistent behavior for the PlaybackActiveTrackChanged and deprecated PlaybackTrackChanged events #2059

Closed
TobiDevloft opened this issue Jul 13, 2023 · 2 comments
Labels

Comments

@TobiDevloft
Copy link

TobiDevloft commented Jul 13, 2023

Describe the Bug
In versions <4.0.0, the PlaybackTrackChanged was fired every time a track started, even if repeat mode was enabled and the same track got played again. In 4.0.0-rc5, the same thing can still be observed on android, but not anymore on iOS. While this might be intended behavior since the track does not change, both platforms behave differently. The same behavior can be observed for the newly introduced PlaybackActiveTrackChanged. This is discussed further in issue #1995.

We used this event for a feature which allows a user to repeat a track once, twice, or infinite times.

Steps To Reproduce
On iOS, Set repeat mode to RepeatMode.Track by calling await TrackPlayer.setRepeatMode(RepeatMode.Track). Then finish a track. The PlaybackTrackChanged is not fired. On android with the same setup, it is fired. Same thing can be observerd for the PlaybackActiveTrackChanged event.

Code To Reproduce

export const SetupService = async () => {
     await TrackPlayer.setupPlayer();
     await TrackPlayer.setRepeatMode(RepeatMode.Track)
}

Replicable on Example App?
Yes

Environment Info:
Paste the results of npx react-native info

System:
    OS: macOS 13.2.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 255.80 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.10.0 - ~/.nvm/versions/node/v16.10.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.10.0/bin/yarn
    npm: 7.24.0 - ~/.nvm/versions/node/v16.10.0/bin/npm
    Watchman: 2023.05.22.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.12.0 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
    Android SDK:
      Android NDK: 25.2.9519653
  IDEs:
    Android Studio: Not Found
    Xcode: 14.3/14E222b - /usr/bin/xcodebuild
  Languages:
    Java: 16.0.2 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.7 => 0.71.7
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Paste the exact react-native-track-player version you are using

4.0.0-rc5

Real device? Or simulator?

Both

What OS are you running?

iOS 16.4.1

How I can Help
If you point me in the right direction, I'll try my best but I only have very limited swift experience.

@puckey
Copy link
Collaborator

puckey commented Jul 13, 2023

So I have adjusted the android behavior to not emit the track changed event when a track repeats: puckey@6a551f6 which is a part of the following pull request: #2058

dcvz pushed a commit that referenced this issue Jul 26, 2023
* fix(ios): fix emitting of EventType.PlaybackQueueEnded (fixes #2038)
* fix(android): avoid emitting track changed when replaying the same track

see #2059
@dcvz
Copy link
Contributor

dcvz commented Jul 26, 2023

As mentioned, new functionality also stops Android from emitting this event. Now both platforms will behave the same. Since I know there's a request for having a way to track repeat plays in #2061, I'll close this issue (where platforms are inconsistent) as it was resolved by #2058 .

@dcvz dcvz closed this as completed Jul 26, 2023
hlieb53 added a commit to hlieb53/react-native-track-player that referenced this issue Nov 9, 2023
* fix(ios): fix emitting of EventType.PlaybackQueueEnded (fixes #2038)
* fix(android): avoid emitting track changed when replaying the same track

see doublesymmetry/react-native-track-player#2059
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants