Closed watadarkstar closed 5 months ago
FYI I do not have this issue. I'm not setting iosCategoryOptions
and my scenes for CarPlay are set up roughly like this example: https://github.com/birkir/react-native-carplay/issues/132#issuecomment-1655803813 (I made a couple modifications to align with RN 0.73)
@uzegonemad What are you setting for iosCategoryMode
? I found that Carplay works for audio if I set that to IOSCategoryMode.SpokenAudio
instead of IOSCategoryMode.VideoRecording
However, our app has both audio and video content which led me create this PR because I need to switch the iosCategoryMode
at runtime:
https://github.com/doublesymmetry/react-native-track-player/pull/2259
@watadarkstar I'm not currently setting iosCategoryMode
but I've got a commented line that was setting it to SpokenAudio. I believe podverse is doing something similar to modify the category mode as needed.
There are certain category modes that are incompatible with CarPlay by design, so it makes sense that VideoRecording wouldn't work but SpokenAudio would.
For anyone who runs into this issue. To get Carplay working I had to do the following:
await TrackPlayer.setupPlayer({
// Important: CarPlay works with IOSCategory.Playback.
iosCategory: IOSCategory.Playback,
// We must set this to the empty array, otherwise the player will
// only play audio in airplane mode. AND it breaks lock screen controls if its not
// the empty array.
// https://react-native-track-player.js.org/docs/api/constants/ios-category-options#allowairplay
iosCategoryOptions: [],
// We must set this to SpokenAudio for lock screen controls to work with
// IOSCategory.Playback.
iosCategoryMode: IOSCategoryMode.SpokenAudio,
})
The combination of these iosCategory
settings are very important. Also, this library should probably have some documentation on how to get Carplay working.
Additionally, this library does not show the lock screen controls if you set:
iosCategory: IOSCategory.Playback,
iosCategoryOptions: [IOSCategoryOptions.AllowAirPlay],
Because IOSCategoryOptions.AllowAirPlay
cannot be set if you set iosCategory
to IOSCategory.Playback
. See the Apple docs:
Setting this option enables the audio session to route audio output to AirPlay devices. You can only explicitly set this option if the audio session’s category is set to playAndRecord. For most other audio session categories, the system sets this option implicitly.
Found here: https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1771736-allowairplay
This library should probably throw a warning or error if you try to set IOSCategoryOptions.AllowAirPlay
if you have:
iosCategory: IOSCategory.Playback,
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Describe the Bug I'm currently playing audio using track player but the audio does not play via the car speakers. Audio comes from the phone instead.
Steps To Reproduce
Code To Reproduce Please provide a simple code example that allows others to replicate the bug.
I'm using
mp3
files locally and via a url. Same issue.Replicable on Example App? Can you replicate this bug in the React Native Track Player Example App?
TBD
Environment Info: Paste the results of
npx react-native info
Paste the exact
react-native-track-player
version you are usingReal device? Or simulator?
Real device. iOS iPhone 12 mini
What OS are you running?
Mac OSX