Closed sjorsroelofs closed 2 years ago
Thanks for the reply. I'm now getting a different error.
In index.js I added this:
TrackPlayer.registerPlaybackService(() => require('./service'));
And in App.js I added this:
import TrackPlayer from 'react-native-track-player';
await TrackPlayer.setupPlayer({});
The error i'm getting right now is:
Unexpected identifier '_reactNativeTrackPlayer' no stack
Am I doing something wrong in the setup? I followed the instructions, but it's not clear to me what's going wrong..
@sjorsroelofs did you also run a pod install
in your ios directory? Just realized thats not in the docs.
@sjorsroelofs did you also run a
pod install
in your ios directory? Just realized thats not in the docs.
Yeah I did, but the problem is also on Android
@sjorsroelofs can you take a look at the setup of the Example app and mirror what it's doing? Something seems to be wrong with how you've set it up and I'm not entirely sure what it is.
Also see this issue which might be related https://github.com/doublesymmetry/react-native-track-player/issues/719
Alright, that worked! Don't know exactly what did the trick in the end.. I tried a lot of things 😅 Think there is some important part missing in the example code in the documentation. Thanks for your help!
@sjorsroelofs what were the important things missing in the docs? If its the case we should get them updated.
@jspizziri Sorry, couldn't test on Android yesterday. Tried it now and getting a build error when running on an Android device:
FAILURE: Build failed with an exception. What went wrong: Could not determine the dependencies of task ':react-native-track-player:compileDebugAidl'. Could not resolve all task dependencies for configuration ':react-native-track-player:debugCompileClasspath'. Could not find com.google.android.exoplayer:exoplayer-dash:2.11.4. Searched in the following locations:
- file:/Users/sjors/Desktop/***/node_modules/react-native/android/com/google/android/exoplayer/exoplayer-dash/2.11.4/exoplayer-dash-2.11.4.pom
- file:/Users/sjors/Desktop/***/node_modules/jsc-android/dist/com/google/android/exoplayer/exoplayer-dash/2.11.4/exoplayer-dash-2.11.4.pom
- https://repo.maven.apache.org/maven2/com/google/android/exoplayer/exoplayer-dash/2.11.4/exoplayer-dash-2.11.4.pom
- https://dl.google.com/dl/android/maven2/com/google/android/exoplayer/exoplayer-dash/2.11.4/exoplayer-dash-2.11.4.pom
- https://www.jitpack.io/com/google/android/exoplayer/exoplayer-dash/2.11.4/exoplayer-dash-2.11.4.pom
- file:/Users/sjors/Desktop/***/node_modules/react-native-track-player/node_modules/react-native/android/com/google/android/exoplayer/exoplayer-dash/2.11.4/exoplayer-dash-2.11.4.pom Required by: project :react-native-track-player
By using this issue I figured out it was solved by adding jcenter() to the Android build.gradle file.
Now I see the media controls in Android, but no music is playing. After a few seconds the controls disapear. Works perfectly on iOS though.. I'm trying to play an HLS (m3u8) stream.
Are there any solutions to this problem?
I'm fairly sure this is still an issue using expo. It doesn't matter how well I follow the instructions, the error comes from this line in lib/interfaces.js:
var TrackPlayer = react_native_1.NativeModules.TrackPlayerModule;
NativeModules is:
Native Modules written in ObjectiveC/Swift/Java exposed via the RCTBridge Define lazy getters for each module. These will return the module if already loaded, or load it if not. See [https://reactnative.dev/docs/native-modules-ios](vscode-file://vscode-app/snap/code/104/usr/share/code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
RatingType[RatingType["Heart"] = TrackPlayer.RATING_HEART] = "Heart";
In the code above TrackPlayer is null
. The variable is not reassigned anywhere else in the file.
The documentation states that expo is supported.
I have the default expo setup as stated in the official react native docs, blank project. I can provide minimal code if needed @jspizziri .
Thank you for spending time on the issue.
EDIT:
I'm new to React Native and it shows. I was using expo go thinking this was the thing, this was clearly said that it's not in the documentation which makes me a complete retard. However, if putting a small warning "Will not work with expo go" above the expo section in the docs (even if it makes complete sense to me now) can prevent other people from figuring out what is happening like I did, maybe that could be a time saver for you. Thank you very much for your time and your work
Try this on all "Evaluting error" Ex: 'TrackPlayer.RATING_HEART' => 'TrackPlayer?.RATING_HEART'
Any solution of this in expo
Im also facing the error while using track player with my project in expo i tried so many solutions but did not work any for me now .. can anyone help us for this
Describe the Bug When adding react-native-track-player to a new React Native project (without Expo) I get the following error:
Steps To Reproduce
npx react-native init AwesomeProject
cd AwesomeProject
npm install --save react-native-track-player
import TrackPlayer from 'react-native-track-player';
npx react-native run-android
(same result on iOS)Code To Reproduce See steps to reproduce.
Environment Info: npx react-native info
react-native-track-player version
Real device? Or simulator? Both
What OS are you running? Android, iOS, iOS Simulator
Thanks a lot!