Is there a way to get control on the call audio of an android phone?

prabha_friend

Prabhakaran Karuppaih
Local time
Today, 19:41
Joined
Mar 22, 2009
Messages
1,026
Hi All,

Good Morning. I am Prabhakaran from India. I am building an Android app using .Net MAUI. The app I am trying to build is an IVR type of application. I am able to route calls and all, but I am not able to get into the call audio of an incoming call. Means, I am able to attend an incoming call but the audio file or Text-to-Speech (Welcome Message) is playing on the media audio but not into the call how to do it? Possible? Thanks.

With Hope,
Prabhakaran
 
I don't have an answer for you but I am "bumping" the request to keep it visible.
 
Hi All,

Good Morning. I am Prabhakaran from India. I am building an Android app using .Net MAUI. The app I am trying to build is an IVR type of application. I am able to route calls and all, but I am not able to get into the call audio of an incoming call. Means, I am able to attend an incoming call but the audio file or Text-to-Speech (Welcome Message) is playing on the media audio but not into the call how to do it? Possible? Thanks.

With Hope,
Prabhakaran

Are you writing about phone calls or calls that come in via external apps like whatsapp and the like?
And when you write "..is playing on the media audio but not into the call.." what exactly do you mean?
 
Controlling call audio on an Android phone directly from VBA (Visual Basic for Applications) is not feasible due to platform and permission limitations. VBA is designed for automating tasks within Microsoft Office applications and Windows environments, and it doesn't have native capabilities to interact with Android's telephony or audio subsystems.
 
Controlling call audio on an Android phone directly from VBA (Visual Basic for Applications) is not feasible due to platform and permission limitations. VBA is designed for automating tasks within Microsoft Office applications and Windows environments, and it doesn't have native capabilities to interact with Android's telephony or audio subsystems.
I'm not sure VBA was mentioned, or did I miss something? (quite likely!)
 
I'm not sure VBA was mentioned, or did I miss something? (quite likely!)
No; you didn't miss anything. Technically It could be done with VBA using a script with a bridge between the PC and Android device. Using Kotlin based HTTP server the code would look something like this: -

Code:
class CommandServer(private val context: Context) : NanoHTTPD(8080) {

    override fun serve(session: IHTTPSession): Response {
        val command = session.parameters["cmd"]?.firstOrNull()
        return when (command) {
            "play_audio" -> {
                playAudio()
                newFixedLengthResponse("Audio played")
            }
            "set_volume" -> {
                val levelStr = session.parameters["level"]?.firstOrNull()
                if (levelStr != null) {
                    val level = levelStr.toIntOrNull()
                    if (level != null) {
                        setVolume(level)
                        newFixedLengthResponse("Volume set to $level")
                    } else {
                        newFixedLengthResponse("Invalid volume level")
                    }
                } else {
                    newFixedLengthResponse("Missing volume level")
                }
            }
            else -> newFixedLengthResponse("Unknown command")
        }
    }

    private fun playAudio() {
        // Implement audio playback logic here
    }

    private fun setVolume(level: Int) {
        val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
        val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
        val safeLevel = level.coerceIn(0, maxVolume)
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, safeLevel, 0)
    }
}

Or Android accepts HTTP Requests therefore something like: -

Code:
Sub SetAndroidVolume()
    Dim http As Object
    Set http = CreateObject("MSXML2.XMLHTTP")
    
    Dim phoneIP As String
    Dim volumeLevel As Integer
    Dim url As String

    ' Set your Android device's IP address and desired volume level
    phoneIP = "192.168.1.100" ' Replace with your Android device's IP
    volumeLevel = 5           ' Replace with desired volume level (0 to max)

    url = "http://" & phoneIP & ":8080/?cmd=set_volume&level=" & volumeLevel

    On Error GoTo ErrorHandler
    http.Open "GET", url, False
    http.Send

    MsgBox "Response from Android: " & http.responseText
    Exit Sub

ErrorHandler:
    MsgBox "Error sending command: " & Err.Description
End Sub
 
Last edited:
Actually, reading back to original request; I've gone off topic, i think! I understood the question to be Is there any way to control the audio volume of an android device on playback using MS access...
 

Users who are viewing this thread

Back
Top Bottom