react-native-track-player: remote controls not working on iOS
Configuration
System: OS: Windows 10 10.0.18362 CPU: (4) x64 Intel® Core™ i5-7200U CPU @ 2.50GHz Memory: 4.00 GB / 7.88 GB Binaries: Node: 10.16.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.21.1 - C:\Users\frank\AppData\Roaming\npm\yarn.CMD npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5900203 npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5
react-native-track-player version: 2.0.0-rc10
Issue
Remote controls don’t work on iOS. I registerd the service:
TrackPlayer.registerPlaybackService(() => require('./service.js'));
I setup the TrackPlayer:
TrackPlayer.setupPlayer();
In componentDidMount I do:
TrackPlayer.updateOptions({
stopWithApp: false,
capabilities: [
TrackPlayer.CAPABILITY_PLAY,
TrackPlayer.CAPABILITY_PAUSE,
TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS,
],
compactCapabilities: [
TrackPlayer.CAPABILITY_PLAY,
TrackPlayer.CAPABILITY_PAUSE,
TrackPlayer.CAPABILITY_SKIP_TO_NEXT,
TrackPlayer.CAPABILITY_SKIP_TO_PREVIOUS,
]
});
And I start it with:
await TrackPlayer.reset();
await TrackPlayer.add({
id: id,
url: path,
title: title,
artist: artist,
artwork: artwork,
});
await TrackPlayer.play();
Service looks like:
// service.js
module.exports = async function() {
TrackPlayer.addEventListener('remote-play', () => {
console.log("play")
TrackPlayer.play()
});
But log and play do not fire. Everything else works. In the beginning remote controls also did work sometimes but only after multiple trys.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (3 by maintainers)
Commits related to this issue
- [iOS] Override SwiftAudio enableRemoteCommands behavior. Related: #746 #747 #775 #820 #831 #834 #881 — committed to doublesymmetry/react-native-track-player by curiousdustin 4 years ago
https://github.com/react-native-kit/react-native-track-player/commit/d3400a475d8be146aa25696b5f014dd538e2dd86 should resolve this. Will get this into v2 soon.
Does not work for me not even on Testflight. Without editing
AudioPlayerFile it works even in debug, but only after refreshing two times and if i don‘t callresetorstop.