Is there an API/method I can use to play audio (specifically from the FM radio radio) through the phone's built-in speaker even when the headphones are plugged in? There doesn't seem to be any concise, advanced beginner/intermediate-friendly discussion of such a thing in Mozilla's documentation. I've seen .mozAudioChannelType
mentioned (How to play audio in background with firefox os?), and it looks promising, but I don't know whether it's what I need or whether I'm barking up the wrong tree entirely.
Edit:
I've gotten the radio to play through the speaker in a really hacky kind of way, which is more fun and interesting than actually helpful for this problem. If I run a basic app that just turns on the radio:
var radio = navigator.mozFMRadio;
if (radio.antennaAvailable) {
radio.enable(88.9);
} else {
alert("You need to plug your headphone");
}
...and then unplug the headphones, the radio keeps playing, but it's all staticky from the lack of an antenna. However, if I let the exposed metal of the headphone cable lightly rest in the jack, just barely touching it, the headphones act as an antenna and the radio plays clearly though the speaker. I know this probably doesn't mean anything important and is just a curiosity, but I felt it worth bringing up.