enable speaker internal only

fifiddu70

Well-Known Member
Licensed User
Longtime User
I would like to play a wave file, or just listening to mp3 with the internal speaker of the phone, without enabling the external speaker, you can?
 

fifiddu70

Well-Known Member
Licensed User
Longtime User
i have this code:

B4X:
'Service module
Sub Process_Globals
    Dim PE As PhoneEvents
   Dim AC As AnswerCall
   Dim PhoneId As PhoneId
   
   
End Sub
Sub Service_Create
    PE.InitializeWithPhoneState("PE",PhoneId)
   AC.Initialize("AnswerCall")
   Log("Service created")
   
End Sub

Sub Service_Start
   Log("Service started.")
End Sub

Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
    Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber)
    Log(Intent.ExtrasToString)
   ToastMessageShow(IncomingNumber,False)
   AC.LetPhoneRing(3000)
   If AC.isRinging == True Then
      AC.AnswerPhone
      
   End If
   AC.enableSpeakerphone
End Sub
Sub Service_Destroy
    
End Sub

I want to auto answer, a sound file plays music that the caller has to listen, as a digital music
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It looks like it is not possible to do what you want, from Android Developers Site:

Note: You can play back the audio data only to the standard output device. Currently, that is the mobile device speaker or a Bluetooth headset. You cannot play sound files in the conversation audio during a call.
 
Upvote 0

pierpa

Member
Licensed User
Longtime User
simulate phone call

hello,

for a to-do-list i want my program to simulate a phone call and if the user presses the green-answer button, the program should say something through the phone speaker using the tts library.

which code should i use to say for example "hello" through tts via the phone speaker?

regards

ppp
 
Upvote 0

pierpa

Member
Licensed User
Longtime User
you mean that tts doesn't speak by default from the loudspeaker, but from earphone?

since now, my prog does this: plays ringtone to the loudspeaker through media player and the fake green and red buttons are used to redirect the user to other app pages. the user must read.

now, i want the user to answer the fake call, receiving infos through the tts and then he can read/tap the infos
 
Upvote 0

mjtaryan

Active Member
Licensed User
Longtime User
I have a related question. I have an app that will play audio or not depending on the user's preferences. However, for certain reasons the MP3 is to play even when the preference is Audio = False. Therefore, I want to be able to programatically enable or disable both the headphones and the speaker (if they are separate). I'm hoping for something like "Speaker.Enable = True (or False)" and "Headphones.Enable = True (or False)" or better yet "Sound.Enable = True" (which would handle both the speaker and the headphones. Is there any way to do what I want? Thanks.
 
Upvote 0
Top