Cordova app only playing audio from headphones and not speakers? - ios

I am building an iOS/Android app using Cordova and Ionic and I'm in the unfortunate position where I cannot test on a physical iPad and have to rely on the iOS Simulator for testing. It was just made known to me that this app does not play audio through the speakers when headphones are NOT plugged in, like you would expect, but other Cordova (non-Ionic) apps work fine on both speakers and headphones.
I am on: Cordova v5.1.1, and Ionic v1.0.0-beta.9
I am also using this Cordova plugin for native audio:
de.neofonie.cordova.plugin.nativeaudio 3.1.0 "Cordova Native Audio"
The audio works perfectly fine on my Nexus 7, OS X/Windows browsers, and the iOS Simulator (if there is a way to simulate plugging and unplugging headphones, that would be great but I have not found an option like that).
Here is some code for what I am using for audio:
Preloading one of the files:
//First is the name of the file to play
window.plugins.NativeAudio
.preloadSimple(first, 'audio/' + first + '.mp3', function(msg){}, function(msg) {
console.log('NativeAudio error: ' + msg);
});
Playing the file:
window.plugins.NativeAudio.play(id);
The code above works perfectly fine, it's just that the iPad does not seem to want to play out of the speakers for some reason.

Old question, but I just ran into a similar issue on Ionic 3 with the same plugin and ended up here, so I thought maybe this will help someone at some point.
I have found this plugin to play sounds over the speaker only when the phone's mute switch is off.

Related

Flutter Web playing audio not working on iOS 14.6 on both Chrome and Safari

I tried to use both audioplayers and just_audio to play audio from URL and it works on Windows browsers, Android browsers, and iOS 15+ browsers, but not working on iPhone of iOS 14.6.
The used code to play audios with audioplayers:
await audioPlayer.release();
audioPlayer.play(UrlSource(audioURL));
audioPlayer.onPlayerComplete.listen((event) {
audioPlayer.release();
});
Apparently I have read that iPhones used to prevent automatic audio playing and it works only with user interaction but doesn't work if I played the audios automatically without user interaction, I have tried this and this seems to be correct, but I want to play it without user interaction.
so is there a way to prevent this problem in Flutter?

How to play react-native-webview audio while the iPhone is muted?

I'm currently running an Expo project with react-native-webview 9.4.0 installed, and I'm trying to use the WebView to play audio from a local .html file with a custom JS script using the Web Audio API. The audio works fine on the iOS simulator and on an iPhone when not on Silent Mode, but once I turn on Silent Mode it's impossible to get any audio to play.
There seems to have been a couple attempts to fix this issue over the past couple months (https://github.com/react-native-community/react-native-webview/pull/1218) and (https://github.com/react-native-community/react-native-webview/issues/1140), but even with the most recent version of react-native-webview I still can't get the Web Audio to play with the iPhone muted. I've tried various workarounds from StackOverflow without any success either. Does anyone else have this issue or have a workaround to suggest?

AudioKit crackling after connecting headphones on iPhone 8+

We have an app, that uses AudioKit to record sound from the microphone and to playback it directly to your headphones.
If you connect your headphones to an iPhone 8+ after you started the app, it starts to crackle at the end of every recorded audioframe. If you do the same thing on every device older than iPhone 7 the app will work correctly.
If you plugged in the headphones before starting the app, it will work correctly in all scenarios, also if you plug in or plug off your headphones.
For better analysis I built a test-app, which only includes the audio-related functions.
This test-app behaves exactly like the other app.
We really have to fix this issue, because we have customers depending on the feature.
Any help in fixing this would be highly appreciated. AudioKit-version is 4.1.
We setup a github repository where you can checkout the code:
https://github.com/eskarion/audio-test
Thanks in advance!

how to run Phonegap app for ios audio file in background

I want to run my html5 audio player which is online streaming radio link to be played even if the device is locked (sleep mode) or the app is turned in background while opening another app. The player works very well when I start it as web app from Safari browser but now after I have built it for ios using Phonegap Build when the device is locked or the user switched between the apps in the device then the player stops. Is there any solution for this? Maybe a plugin?
Here is my web app in github: https://github.com/albpower/radio-pendimi
I have solved this problem using Background-audio ios Phonegap plugin. Here you can find more informations about plugin and usage from official Phonegap plugins directive.
https://build.phonegap.com/plugins/1193

Unable to play m.youtube.com video in BlackBerry simulator

When I try to play video from m.youtube.com I get an error:
an error has occured attempting to play media.
How do I solve this?
Make sure you are running the MDS Simulator (start it before the simulator), otherwise most applications that use networking on the simulator (including the web browser) will not work.
EDIT: as noted below, YouTube mobile uses RTSP which isn't supported in the simulators
Try playing around with different versions of the OS in your emulator. Be aware, however, that Blackberry support for Flash video is virtually nonexistent even on their handsets, so you're bound to run into issues.

Resources