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.3k stars 1.01k forks source link

Example project for android needs update? (HLS related) #1644

Closed Knufle closed 2 years ago

Knufle commented 2 years ago

System: OS: Windows 10 10.0.19044 CPU: (8) x64 Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz Memory: 899.71 MB / 15.94 GB Binaries: Node: 14.19.3 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.14.17 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: Not Found IDEs: Android Studio: AI-212.5712.43.2112.8815526 Visual Studio: Not Found Languages: Java: 17.0.3 - C:\Program Files\Java\jdk-17.0.3\bin\javac.EXE Python: 3.10.4 - C:\Python310\python.EXE npmPackages: @react-native-community/cli: ^4.14.0 => 4.14.0 react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-windows: Not Found npmGlobalPackages: react-native: Not Found

I was using the example project to set up a basic player that can play hls streams, but for some reason the example project was not playing these streams and also everytime I updated the hls stream object to have "type": "hls" the app would open and crash.

After reading some issues and the docs, I managed to fix this by adding a JSON file named track-player.json to my root folder just like the docs recommend https://react-native-track-player.js.org/docs/basics/build-preferences, its content being:

{
  "dash": true,
  "hls": true,
  "smoothstreaming": true
}

I enabled everything just in case but I'll most likely disable dash I guess.

After doing that, reinstalling the app (it wasn't working before a new installation) and updating the object with the new property "type": "hls" the stream finally worked on android, here's the object for reference btw:

{
    "url": "https://react-native-track-player.js.org/example/hls/whip/playlist.m3u8",
    "title": "Whip",
    "artist": "prazkhanal",
    "artwork": "https://react-native-track-player.js.org/example/hls/whip/whip.jpeg",
    "type": "hls"
}

Anyways, the example project on android didn't work for me out of the box and that's why I'm opening this issue, and also to help anyone else who might come across this scenario.

jspizziri commented 2 years ago

@Knufle thanks for reporting this issue! Just submitted a PR for the fix.