-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: add audio usage type so it's possible to force audio from earpiece speaker #105
base: main
Are you sure you want to change the base?
Conversation
* The audio usage type. | ||
*/ | ||
var audioUsageType: AudioUsageType = AudioUsageType.MEDIA | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a newline at the end of the file.
} | ||
} | ||
|
||
private fun setAudioAttributes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't personally love the function overloading here. Perhaps we could name this function something like applyAudioAttribute()
.
@@ -274,6 +263,53 @@ abstract class BaseAudioPlayer internal constructor( | |||
playerEventHolder.updateAudioPlayerState(AudioPlayerState.IDLE) | |||
} | |||
|
|||
fun setAudioAttributes(audioAttributeConfig: AudioAttributeConfig) { | |||
scope.launch { | |||
playerConfig = PlayerConfig( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps handleAudioFocus
, audioUsageType
, audioContentType
should be updated to var
's so that they could simply be mutated rather than replacing the entire PlayerConfig
object. Not sure.
@@ -0,0 +1,18 @@ | |||
package com.doublesymmetry.kotlinaudio.models | |||
|
|||
data class AudioAttributeConfig( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit on the fence about introducing this intermediate class just to encapsulate the arguments passed to the setAudio function. @dcvz will need to weigh in on it.
Makes it possible to set the audio usage attribute. By doing this it is possible to force the audio to come from the earpiece speaker. A useful use case is listening to voice messages.