Android Question SIP loud speaker OFF and ON

Tasyo28

Member
Licensed User
Hi All,

I'm doing a SIP calling app and i want to create a button that will trigger loud speaker ON or OFF, how to achieve this?

i created two subs is this how to code it in b4a? where i will just call SpeakerOFF if i want loud speaker off?
But i tried it not working still in loud speaker mode.

Please advise


B4X:
Sub SIP_CallEstablished
    'Check that we are not already in a call.
    'Seems like this event can be raised by the SIP service multiple times.
    If CurrentCall.IsInCall Then Return
    'Log("CallEstablished")
    SpeakerON 'this will turn ON loud speaker by default
    ToastMessageShow("Call established", True)
End Sub

Sub SpeakerOFF()
    CurrentCall.StartAudio 'Start the audio
    CurrentCall.SpeakerMode = False
End Sub

Sub SpeakerON()
    CurrentCall.StartAudio 'Start the audio
    CurrentCall.SpeakerMode = True
End Sub
 

Peter Simpson

Expert
Licensed User
Longtime User
@Tasyo28,
You should just add a switch to your latout, then you should add an click event sub for the switch by right clicking on the switch in the designer layout and going to generate.

Basically create a click event and put your code in that sub.

I also suggest that you watch these videos https://www.b4x.com/etp.html
 
Upvote 0

Tasyo28

Member
Licensed User
Hi Peter,

Thank you for your reply, i created a button to call the SpeakerOFF and SpeakerON sub but nothing happens still in loud speaker mode.

Is my code correct?
 
Upvote 0
Top