I am writing a Cordova application, and I am not able to play sounds on a 4.2.2 Android device.
I have tried the 2 things mentioned here, that is PhoneGap's Media class (not working) and this syntax (not working):
var audio = new Audio('coins.mp3');
audio.play();
I have also tried this plugin but without success.
Also the workaround mentioned in code.google.com (using Video instead of Audio) does work when I am in debug, but not after deploying the app to the store and then downloading it:
var success = document.createElement("video");
success.setAttribute("src", "success.mp3");
success.play();
So it is not possible to play audio with javascript on older Android devices?
Related
I am attempting to record audio samples from user on a PWA app. This application runs great on my Mac with the blobs being full in data. There is no problem in running the audio on the Mac. When running the PWA on my phone, blobs have 0 size, and nothing happens when running the audio.
React.js is used for the PWA. Before updating my chrome to the latest version(78.0.1304.108) the recording consisted of no problems. After the upgrade, attempts to find a solution failed. Phones with older versions work.
The following packs and JavaScript libraries were used (React-Mic,#cleandersonlobo/react-mic,React-Audio-Recorder),(getUserMedia,MediaRecorder)
Ok so I solved this issue, it turns out I used all audio inputs stream that chrome allows and because chrome dosent display an error regarding this it was hard to find it, so all I did was just redirecting the input streams better.
I'm making a platform which involves the server triggering Audio to be played with Socket.io. I'm trying to make a PWA for iOS using similar code, but it just doesn't work and I've heard that Safari requires user interaction (I am using this with the full screen PWA meta tag, not through Safari directly). It works fine on the latest version of Chrome on desktop.
Is there anyway to make this work?
Web Interface (uses same audio
playing and socket.io code): https://github.com/archiebaer/bithop-web-interface
No, Safari restricts audio playing quite a lot. It seems in your scenario, there is no work around unfortunately.
I am trying to record a video with audio (for desktop it will use web cam and headphone if any, for IOS and Andriod it will use phone camera and mic).
Tried to implement using (http://www.html5rocks.com/en/tutorials/getusermedia/intro/) but when I tried the given demo its not working with Andriod and IOS even not working in firefox too.
Tried to implement using (https://www.webrtc-experiment.com/RecordRTC) too but we have different js for firefox and chrome and its not working with IOS and Andriod.
If anybody know a solution which one work for chrome, firefox, andriod and IOS than please reply.
Waiting for the response, in the mean time trying my own to find out some solutions.
I'm playing audio in my HTML5 app using:
createjs.Sound.play('boom-sound');
I then imported the project to Intel XDK. Now the game is playing smoothly in the emulator but the no sounds are there. I also tested after building the app for android and no audio was there.
Any idea, anyone?
soundjs does not work that well, I've also had problems making it play sound on IOS devices in the past. To fix this problem I now use howler.js.
SoundJS has run into trouble in environments like Intel XKD and PhoneGap because it defaults to using the WebAudioPlugin. While Web Audio may be available, it needs to load audio through XHR which will not work with local files.
Loading files from an external server would get around this, but require the app to fetch data which is less than ideal. Using createjs.Sound.registerPlugins([HTMLAudioPlugin]) would get around this but HTML audio playback is sometimes limited on mobile devices.
Luckily, SoundJS recently added a CordovaAudioPlugin, and since Intel XDK is based on Cordova this should give you full SoundJS functionality. You'll need to grab the plugin and the latest SoundJS-NEXT from github. Then you can setup the plugin with registerPlugins
createjs.Sound.registerPlugins([CordovaAudioPlugin]);
Hope that helps.
I have a big problem with my cordova (version 4.0) App in iOS:
It uses HTML5 Audio triggered with buzz.js. Now the problem is, that I want all audio to stop/mute when leaving the app. I expected this to be the standard behaviour, but this is not the case. When I leave the app in the iPad emulator, it keeps on playing the audio in the background.
Through my research I just found posts of people who had the exact opposite problem and wanted to keep playing audio with the app in the background.
I know I could try to handle this issue with the resume and pause events cordova provides, but since iOS doesn't allow volume control for HTML5 audio it will probably be difficult/lots of work.
As I said, I'm using Cordova 4 CLI to build my app using xCode 6.1
I have no knowledge of Objective-C etc, just JavaScript.
The plugins installed with the project are the following:
me.apla.cordova.app-preferences 0.4.2 "AppPreferences"
org.apache.cordova.inappbrowser 0.5.3 "InAppBrowser"
org.apache.cordova.statusbar 0.1.8 "StatusBar"
The pause and resume events should do what you want. Have you tried using them? For example:
document.addEventListener("pause", function() {
myBuzzSound.fadeOut();
});
and on resume...
document.addEventListener("resume", function() {
myBuzzSound.fadeIn();
});