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.18k stars 981 forks source link

Lost duration after adding tracks to queue #2192

Closed jimluo123 closed 8 months ago

jimluo123 commented 8 months ago

Describe the Bug The duration of tracks are exited, but after adding to track and I found that the value of duration in Event.PlaybackProgressUpdated was still zero. And the duration value from useProgress() hook was zero too.

Steps To Reproduce Add track to player, and keep playing. Then look at the logs from event listener.

Code To Reproduce

// add to player code
        let FormatQueue: Track[] = [];
        for (let i = 0; i < props.Queues.length; i++) {
          FormatQueue.push({
            id: props.Queues[i].id,
            title: props.Queues[i].title,
            artist: "",
            url: `${API_URL}/app/v1/music/play?id=${
              props.Queues[i].id
            }&streaming_type=${
              netWork.type === "WIFI" ? "wifi_streaming" : "data_streaming"
            }`,
            duration: Number(props.Queues[i].length),
            artwork: props.Queues[i].album_cover,
            genre: props.Queues[i].genre,
          });
        }
        setCurrentPlayList(FormatQueue);
        await TrackPlayer.reset();
        await TrackPlayer.add(FormatQueue);

Replicable on Example App? Can you replicate this bug in the [React Native Track Player Example App] (https://github.com/doublesymmetry/react-native-track-player/tree/main/example)? No.

Environment Info:

System:
  OS: Windows 10 10.0.22621
  CPU: (8) x64 Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
  Memory: 1.66 GB / 15.67 GB
Binaries:
  Node:
    version: 16.18.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 9.7.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.6.33829.357 (Visual Studio Community 2022)
Languages:
  Java:
    version: javac 11
    path: /d/java/jdk-11/bin/javac
  Ruby: Not Found
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-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
 "react-native-track-player": "^4.0.0",

both in simulator and real device Windows

How I can Help I can provide some codes and screen shot to illustrate the problem

jimluo123 commented 8 months ago

my problem seems like the last song of the example playlist. Does it play have a specific format of songs?

lovegaoshi commented 8 months ago

disclosure i have no idea waht happened what platform is this? could you repurpose the example app's button to this addQueue function you pasted, and once pressed the progress bar should go funky according to your description? please share the repo i guess

jimluo123 commented 8 months ago

I know what's happened. There are problems about some songs of mine when I fetched them from backend, they became live stream and can not get any duration when I played them on web browser. Sorry about the time.