doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.32k stars 1.02k forks source link

TrackPlayer.seekTo broken on livestream with latest iOS 17.3 and iOS 17.4 #2268

Closed DennisdeWitNL closed 7 months ago

DennisdeWitNL commented 8 months ago

Describe the Bug When using TrackPlayer.seekTo(buffer) on a livestream, the stream restarts a few times and then the player eventually dies out.

Steps To Reproduce

Code To Reproduce

TrackPlayer.addEventListener(Event.RemotePlay, () => {
    console.log("Playing to:", buffered);
    TrackPlayer.seekTo(buffered);
    TrackPlayer.play();
  });

Replicable on Example App? Yes. And I see this issue too on all the other apps where I use the TrackPlayer.seekTo(buffer) command on.

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

info Fetching system and libraries information...
System:
  OS: macOS 14.4
  CPU: (14) arm64 Apple M3 Max
  Memory: 628.97 MB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.6.2
    path: /opt/homebrew/bin/node
  Yarn: Not Found
  npm:
    version: 10.2.4
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10227.8.2321.11479570
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false

Paste the exact react-native-track-player version you are using Error happens on the latest nightly 4.0.1-nightly-7628d4a89251f09ea88114a47927dd26b4c9dff1 and RC 4.0.0-rc09

Real device? Or simulator? Real device

What OS are you running? Tested against iOS 17.3 and iOS 17.4.

I have no experience with SwiftAudioEx, so I don't know exactly how to solve it. All I know is that seekTo() is bugged.

DennisdeWitNL commented 8 months ago

With 4.1.1, when using seekTo(buffered - 1), it works fine. With seekTo(buffered) it still dies on a livestream.

DennisdeWitNL commented 8 months ago

Closed. Do NOT use addEventListener inside of App.js, you should use it as a separate function! Otherwise it will fire in a loop and crash RNTP.