System:
OS: Windows 10 10.0.18362
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Memory: 4.00 GB / 7.88 GB
Binaries:
Node: 10.16.0 - C:\Program Filesnodejsnode.EXE
Yarn: 1.21.1 - C:\Users\frank\AppData\Roamingnpm\yarn.CMD
npm: 6.9.0 - C:\Program Filesnodejsnpm.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
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.
i have some problem in 2.0.0-rc13 version, it work only android
Be sure to use the new Capability enum in v2. See here for more details.
(version 2.0.0-rc13) remote controls show when i send to TestFlight. But the controls not respond any actions.
import TrackPlayer, {Event} from 'react-native-track-player';
module.exports = async function playerService() {
TrackPlayer.addEventListener(Event.RemotePlay, () => TrackPlayer.play());
TrackPlayer.addEventListener(Event.RemotePause, () => TrackPlayer.pause());
TrackPlayer.addEventListener(Event.RemoteStop, () => TrackPlayer.destroy());
};
i麓m using Capability enum
capabilities: [Capability.Play, Capability.Pause, Capability.Stop],
I simplified my example - it used to have notificationCapabilities and compactCapability keys passed to updateOptions. Would you mind specifying those and report back?
@cwilby i set updateCapabilities
waitForBuffer: true,
stopWithApp: false,
capabilities: [Capability.Play, Capability.Pause, Capability.Stop],
compactCapabilities: [Capability.Play, Capability.Pause, Capability.Stop],
notificationCapabilities: [
Capability.Play,
Capability.Pause,
Capability.Stop,
],
the background controls appear but not work when i press some button
@fernando-pascoal Checkout the capabilities in this file and add the ones you need.
I think you might need Capability.SkipToNext and Capability.SkipToPrevious.
@cwilby i add all capabilities into service.js and updateCapability method, it still doesn't work.
it doesn't work on v1.1.6, v1.1.8, v1.2.0 & v1.2.2
831 helped me.
for me it does not help
@FrankFundel @sirakoff @bdcorps @cwilby The problem is solved for me.
enableRemoteCommands(forItem: item)
to this:
if (item is RemoteCommandable) {
enableRemoteCommands(forItem: item)
}
the remote controls only works on Testflight.
remember to use ENUMs from react-native-track-player to set Events, Capabilities and State:
look this:
import {Capability, Event, State} from "react-native-track-player"
Does not work for me not even on Testflight. Without editing AudioPlayer File it works even in debug, but only after refreshing two times and if i don鈥榯 call reset or stop.
TestFlight is not necessary. Although sometimes there are differences between debug and release build behavior. You can build and run a release build to a local device without the hassle of TestFlight.
@FrankFundel can you test my PR #895?
It is an alternate fix that does not modify the SwiftAudio submodule.
https://github.com/react-native-kit/react-native-track-player/commit/d3400a475d8be146aa25696b5f014dd538e2dd86 should resolve this. Will get this into v2 soon.
Most helpful comment
https://github.com/react-native-kit/react-native-track-player/commit/d3400a475d8be146aa25696b5f014dd538e2dd86 should resolve this. Will get this into v2 soon.