Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sound category and playback speed #26

Open
ameer-taghavi opened this issue Feb 19, 2025 · 9 comments
Open

Support sound category and playback speed #26

ameer-taghavi opened this issue Feb 19, 2025 · 9 comments

Comments

@ameer-taghavi
Copy link

please add

  1. AudioSession category(to support play in silence mode, background and ...)
  2. playback speed
@itsramiel
Copy link
Owner

Hi,

One seems easily doable, but still can you provide use cases where you would like to change it.
Two is more involved and not sure if I can do it with current architecture of library, but still just a question. Is your use case to increase or decrease the playback speed?

@ameer-taghavi
Copy link
Author

I am using react-native-sound which has the features I need but this package has not good performance. I have a messaging app that has audio messages and I need to play the audio at a faster speed (1.5x, 2x) and play the audio in silence mode.

@itsramiel
Copy link
Owner

Hey @ameer-taghavi

Following up on support sound category:

Can you tell me which category would you need to set to make it work for your use case? You mentioned

play the audio in silence mode.

Do you mean to play the audio when the phone is silenced because by default now the sound would play even if the phone is in silent mode. The audio is similar to a music app, not a notification which is silenced.

If I am misunderstanding your point, please clarify it by providing a reproducible where it doesnt work like you want and how you would like to to behave instead.

@ameer-taghavi
Copy link
Author

Do you mean to play the audio when the phone is silenced because by default now the sound would play even if the phone is in silent mode. The audio is similar to a music app, not a notification which is silenced.

Yes. Exactly

@ameer-taghavi
Copy link
Author

Can you tell me which category would you need to set to make it work for your use case? You mentioned

For iOS I used Playback category
And for Android I used Alarm category

@itsramiel
Copy link
Owner

Hi @ameer-taghavi

Please try 1.1.0-alpha.0 which allows you to pass in the audio session category for iOS and Usage for Android:

public setupAudioStream(options?: {
sampleRate?: number;
channelCount?: number;
ios?: {
audioSessionCategory?: IosAudioSessionCategory;
};
android?: {
usage?: AndroidAudioStreamUsage;
};
}) {

Supported categories for iOS:

export enum IosAudioSessionCategory {
Ambient,
MultiRoute,
PlayAndRecord,
Playback,
Record,
SoloAmbient,
}

Supported Usages on Android:

export enum AndroidAudioStreamUsage {
Media,
VoiceCommunication,
VoiceCommunicationSignalling,
Alarm,
Notification,
NotificationRingtone,
NotificationEvent,
AssistanceAccessibility,
AssistanceNavigationGuidance,
AssistanceSonification,
Game,
Assistant,
}

Let me know if this resolves your request for sound category

@ameer-taghavi
Copy link
Author

ameer-taghavi commented Feb 24, 2025

thanks @itsramiel
it's working 🙏🏻

@ameer-taghavi
Copy link
Author

thank you for add audio sessions and categories 🙏🏻
when will we have playback speed feature? 😁

@itsramiel
Copy link
Owner

Hi, playback speed feature requires lots of research and changes which I dont have the motivation for now, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants