Coder Social home page Coder Social logo

floatinghotpot / cordova-plugin-nativeaudio Goto Github PK

View Code? Open in Web Editor NEW
233.0 12.0 290.0 2.92 MB

The low latency audio plugin is designed to enable low latency and polyphonic audio from Cordova/PhoneGap applications, using a very simple and basic API.

License: MIT License

CSS 3.67% HTML 3.71% JavaScript 19.26% Objective-C 46.01% Java 27.35%
cordova plugin audio game javascript

cordova-plugin-nativeaudio's Introduction

Cordova Native Audio Plugin

Cordova / PhoneGap 3.5+ extension for Native Audio playback, aimed at HTML5 gaming and audio applications which require minimum latency, polyphony and concurrency.

Contents

  1. Description
  2. History
  3. Roadmap
  4. Integration
  5. Supported Platforms
  6. Installation
  7. Usage
  8. API
  9. Demo

Description

This Cordova / PhoneGap (3.5+) plugin enables concurrency (multi-channel playback), polyphony (multi-voice playback) and minimized latency (via caching) in audio-based applications, by leveraging native audio APIs. Designed for the use in HTML5-based cross-platform games and mobile/hybrid audio applications.

History

Community-driven, clean fork of the Low Latency Audio Plugin for Cordova / PhoneGap, initially published by Andrew Trice and then maintained by Raymond Xie and Sidney Bofah.

This project cleans up a lot of legacy code, and adds success, error and completion callbacks. It also features integration in AngularJS projects via ngCordova.

Roadmap

Following the Cordova philosophy, this is a shim for a web audio implementation (on mobile) which is as fast and feature-rich as native mobile APIs. Currently, neither HTML5 Audio or the more recent Web Audio API offer a cross-platform solution which 1) is fast, 2) supports polyphony, 3) concurrency and 4) maintains a low overhead.

It should be replaced by a standardised W3C solution as soon as such an implementation offers comparable performance across (mobile) devices, which is crucial for HTML5-based games.

Integration

This plugin is available as an AngularJS service module, facilitating the usage in AngularJS-based Cordova/PhoneGap projects.

It extends the ngCordova project, an effort by the great guys at Drifty, creators of the Ionic Framework. Download it at the ngCordova website or the repository.

Supported Platforms

  • iOS (tested with 7.1.2, 8.1.3)
  • Android (tested in API levels 14 - 21)

Installation

Via Cordova CLI:

cordova plugin add cordova-plugin-nativeaudio

Usage

  1. Wait for deviceReady.
  2. Preload an audio asset and assign an id - either optimized for single-shot style short clips (preloadSimple()) or looping, ambient background audio (preloadComplex())
  3. play() the audio asset via its id.
  4. unload() the audio asset via its id.

API

Preloading

preloadSimple: function ( id, assetPath, successCallback, errorCallback)

Loads an audio file into memory. Optimized for short clips / single shots (up to five seconds). Cannot be stopped / looped.

Uses lower-level native APIs with small footprint (iOS: AudioToolbox/AudioServices). Fully concurrent and multichannel.

  • params
  • id - string unique ID for the audio file
  • assetPath - the relative path or absolute URL (inluding http://) to the audio asset.
  • successCallback - success callback function
  • errorCallback - error callback function
preloadComplex: function ( id, assetPath, volume, voices, delay, successCallback, errorCallback)

Loads an audio file into memory. Optimized for background music / ambient sound. Uses highlevel native APIs with a larger footprint. (iOS: AVAudioPlayer). Can be stopped / looped and used with multiple voices. Can be faded in and out using the delay parameter.

Volume & Voices

The default volume is 1.0, a lower default can be set by using a numerical value from 0.1 to 1.0.

By default, there is 1 vice, that is: one instance that will be stopped & restarted on play(). If there are multiple voices (number greater than 0), it will cycle through voices to play overlapping audio.

Change the float-based delay parameter to increase the fade-in/fade-out timing.

Playback

  • params
  • id - string unique ID for the audio file
  • assetPath - the relative path to the audio asset within the www directory
  • volume - the volume of the preloaded sound (0.1 to 1.0)
  • voices - the number of multichannel voices available
  • successCallback - success callback function
  • errorCallback - error callback function
play: function (id, successCallback, errorCallback, completeCallback)

Plays an audio asset.

  • params:
  • id - string unique ID for the audio file
  • successCallback - success callback function
  • errorCallback - error callback function
  • completeCallback - error callback function
loop: function (id, successCallback, errorCallback)

Loops an audio asset infinitely - this only works for assets loaded via preloadComplex.

  • params
  • ID - string unique ID for the audio file
  • successCallback - success callback function
  • errorCallback - error callback function
stop: function (id, successCallback, errorCallback)

Stops an audio file. Only works for assets loaded via preloadComplex.

  • params:
  • ID - string unique ID for the audio file
  • successCallback - success callback function
  • errorCallback - error callback function
unload: function (id, successCallback, errorCallback)

Unloads an audio file from memory.

  • params:
  • ID - string unique ID for the audio file
  • successCallback - success callback function
  • errorCallback - error callback function
setVolumeForComplexAsset: function (id, volume, successCallback, errorCallback)

Changes the volume for preloaded complex assets.

  • params:
  • ID - string unique ID for the audio file
  • volume - the volume of the audio asset (0.1 to 1.0)
  • successCallback - success callback function
  • errorCallback - error callback function

Example Code

In this example, the resources reside in a relative path under the Cordova root folder "www/".

if( window.plugins && window.plugins.NativeAudio ) {
	
	// Preload audio resources
	window.plugins.NativeAudio.preloadComplex( 'music', 'audio/music.mp3', 1, 1, 0, function(msg){
	}, function(msg){
		console.log( 'error: ' + msg );
	});
	
	window.plugins.NativeAudio.preloadSimple( 'click', 'audio/click.mp3', function(msg){
	}, function(msg){
		console.log( 'error: ' + msg );
	});


	// Play
	window.plugins.NativeAudio.play( 'click' );
	window.plugins.NativeAudio.loop( 'music' );


	// Stop multichannel clip after 60 seconds
	window.setTimeout( function(){

		window.plugins.NativeAudio.stop( 'music' );
			
		window.plugins.NativeAudio.unload( 'music' );
		window.plugins.NativeAudio.unload( 'click' );

	}, 1000 * 60 );
}

Demo

The Drumpad in the examples directory is a first starting point.

[sudo] npm install plugin-verify -g
plugin-verify cordova-plugin-nativeaudio ios
plugin-verify cordova-plugin-nativeaudio android

Or, type the commands step by step:

cordova create drumpad com.example.nativeaudio drumpad
cd drumpad
cordova platform add ios
cordova plugin add cordova-plugin-nativeaudio
rm -r www/*
cp -r plugins/cordova-plugin-nativeaudio/test/* www
cordova build ios
cordova emulate ios

cordova-plugin-nativeaudio's People

Contributors

bbosman avatar dhaval85 avatar floatinghotpot avatar francescomussi avatar fridjon avatar giuseppelt avatar janpio avatar juangaspar avatar menardi avatar nrocy avatar pei-neofonie avatar rasmuswikman avatar rngwlf avatar sashasirotkin avatar sidneys avatar thiago-negri avatar thibaudd avatar tylervz avatar volrath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-nativeaudio's Issues

Examples

For some reason I can't get this plugin to work. Could you update one of the examples or paste a sample so I could update them?

ReferenceError: PGLowLatencyAudio is not defined

Hello,
I'm using Adobe Phonegap Build 3.1.0 and I'd like to use the LowLatencyPlugin plugin.

I have included the plugin in the config.xml and it is listed in the Installed 3rd Party Plugins list: com.rjfun.cordova.plugin.lowlatencyaudio 1.0
(everthing looks good)

In my index.html I have also included "cordova.js" and "LowLatencyAudio.js" scripts.

But every time I call PGLowLatencyAudio.preloadAudio(....) in my index.html I get following error.

ReferenceError: PGLowLatencyAudio is not defined.

Please Note: The deviceready event has been fired before.

Is it because I'm using the adobe phonegap build instead of the local build
environment?
A short example of the config.xml and the html file for the Adobe Phonegap Build would help.

Thank you in advance.

br,
Josef

Support pause

I want to be able to pause music loaded via LowLatencyAudio.

Simple Audio volume is based on ringer volume in iOS 8

I've noticed that the volume level this plugin uses is based on the ringer volume and not the audio volume in iOS 8. So when I press the volume up/down hardware buttons on my phone, if they are currently raising / lowering the audio volume, the volume of the plugin isn't affected. I can then hit the home button, open the app again and hit the volume buttons again, and now if the ringer volume is the one changing, then the plugin volume changes with it.

It seems like this is intended use but I'm worried that this will be confusing to users. Do most games' audio follow the audio or ringer volume on iOS 8?

Plugin hooks should be updated with cordova 5.4.0

Nodejs 5.0 requires cordova 5.4.0.
So I just update cordova to 5.4.0 and reinstall (rm and then add) this plugin.
It reports:

The module "ConfigParser" has been factored into "cordova-common". Consider update your plugin hooks.

Delay - problem with fading

I can't seem to get the fade working with the 'delay' value using preloadComplex. I've tried low values 0.08 up to 1. Do you have documentation on how to get this working?

I've tried many things and it doesn't fade at all.

Thanks

Unable to stop an already playing sound.

Using LowLatencyAudio 1.1.3 and Phonegap 3.5.0 there seems to be no way to stop an already playing sound. The sound keeps playing on Android and iOS.

Sound file was loaded using lla.preloadAudio("music", "sound/music.mp3", 1, 1). There's no difference whether I use play("music") or loop("music") to start and stop("music") or stop("music") and unload("music") to stop a sound. It keeps playing no matter what I do.

Weird null pointer exception

Bug was found Nexus 9 (android).
Standard usage: preload, play, loop, stop.
W/System.err(13840): java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.concurrent.Callable.call()' on a null object reference W/System.err(13840): at de.neofonie.cordova.plugin.nativeaudio.NativeAudioAssetComplex.onCompletion(NativeAudioAssetComplex.java:165) W/System.err(13840): at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:2538) W/System.err(13840): at android.os.Handler.dispatchMessage(Handler.java:102) W/System.err(13840): at android.os.Looper.loop(Looper.java:135) W/System.err(13840): at android.app.ActivityThread.main(ActivityThread.java:5254) W/System.err(13840): at java.lang.reflect.Method.invoke(Native Method) W/System.err(13840): at java.lang.reflect.Method.invoke(Method.java:372) W/System.err(13840): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) W/System.err(13840): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

problem, to preload more than 10 sound files

Hello, I'm just starting and this autlizar phonegap plugin and I'm using a delay over 10 reproducri preloadFX sounds, it takes on average 1 min 30 sec at a minimum, what I want to know is how can hacelerar preload.

this is the code to see if you give me any idea as faster loading of sounds.

var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
app.receivedEvent('deviceready');
console.log('deviceready');
},
receivedEvent: function(id) {
if( window.plugins && window.plugins.LowLatencyAudio ) {
window.plugins.LowLatencyAudio.preloadFX('assets/mew01.ogg', 'assets/mew01.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew02.ogg', 'assets/mew02.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew03.ogg', 'assets/mew03.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew04.ogg', 'assets/mew04.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew05.ogg', 'assets/mew05.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew06.ogg', 'assets/mew06.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew07.ogg', 'assets/mew07.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew08.ogg', 'assets/mew08.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew09.ogg', 'assets/mew09.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew10.ogg', 'assets/mew10.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew11.ogg', 'assets/mew11.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew12.ogg', 'assets/mew12.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew13.ogg', 'assets/mew13.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew14.ogg', 'assets/mew14.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew15.ogg', 'assets/mew15.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew16.ogg', 'assets/mew16.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew17.ogg', 'assets/mew17.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew18.ogg', 'assets/mew18.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew19.ogg', 'assets/mew19.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew20.ogg', 'assets/mew20.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew21.ogg', 'assets/mew21.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew22.ogg', 'assets/mew22.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew23.ogg', 'assets/mew23.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
window.plugins.LowLatencyAudio.preloadFX('assets/mew24.ogg', 'assets/mew24.ogg', function(msg){}, function(msg){ alert( 'Error: ' + msg ); });
}
},
play: function(sound) {
window.plugins.LowLatencyAudio.play('assets/' + sound + '.ogg');
},
};

Refrence to files is intermittent on Android 5.01

Everything is fine on 4.4 and 4.3, but when running the library on 5.01 audio that has been pre-loaded will return this:
chromium(23300): [INFO:CONSOLE(120)] "Error: A reference does not exist for the specified audio id.", source: file:///android_asset/www/js/index.js (120)

The problem occurs about 50% of the time in no particular order with random audio files. The same file can work one time, but not another.

No sound in some android, but works in others

I have three android phones and two iphones, nativeaudio plugin works well on one android(4.2.2) and all iphone. there are two android(4.4.4, 4.2.1) can't hear anything.

I digged internet for whole weekend, found some weird thing. when I add these code in plugin, sounds goes back,then remove them all, compile again, sounds is still there. I cant expained it. I lost my incident ground, but something wrong in there.

// setting volume on MediaPlayer doesnt work
mp = new MediaPlayer();
mp.setVolume(volume, volume);

// force set volume on AudioManager, it works. but the code just get/set same value..
    AudioManager audiMgr = (AudioManager)this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
    int currentVolume = audiMgr.getStreamVolume(AudioManager.STREAM_RING);
    audiMgr.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, 0);

Distorted Audio

I have a pop sound in my game that occurs very often. After about 1000 pops (I don't know the actual number), the pop started to sound very loud and distorted. I quit the app and relaunched and that fixed the problem. How do I prevent this from happening?

Hardcoded www in java file

lines 66 and 102 of the LowLatencyAudio.java file are hard coded with www. Our audio files are downloaded to the phones storage system, which live at cdvfile://localhost/persistent/...

And as far as I know there is no way to get from www to the external file system.

NativeAudio.java: Entry is not public in HashMap; cannot be accessed from outside package

hi,

Thanks a ton for the useful plugin. I have some difficulty in getting it to work. When I try to build it I get the following error

.../NativeAudio.java:[300,20] error: Entry is not public in HashMap; cannot be accessed from outside package

And also another question - Is the file "hotjs-audio.js" a necessary part of the plugin? I am a total NOOB to java so please pardon any stupidities ",)

Thanks,
M&M

Question related to preloadAudio

Hi,

Suppose that two audio files (say a.mp3 and b.mp3) has been preloaded into memory via preloadAudio function.

Will the previous loop or play stop playing when I loop or play something else (e.g. not concurrent)?

Thanks.

Problem compiling plugin

Hi,
I was using this plugin when it was located at https://github.com/floatinghotpot/cordova-plugin-lowlatencyaudio and it was working fine. I see that the above repository redirects to this one now. So I tried recompiling but am getting an error. Can you please tell what is wrong? Thanks.

-compile:
[javac] Compiling 42 source files to .../DollarCandy/platforms/android/ant-build/classes
[javac] .../DollarCandy/platforms/android/src/com/rjfun/cordova/plugin/nativeaudio/NativeAudio.java:200: cannot find symbol
[javac] symbol : method setButtonPlumbedToJs(int,boolean)
[javac] location: class org.apache.cordova.CordovaWebView
[javac] this.webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_DOWN, false);
[javac] ^
[javac] .../DollarCandy/platforms/android/src/com/rjfun/cordova/plugin/nativeaudio/NativeAudio.java:201: cannot find symbol
[javac] symbol : method setButtonPlumbedToJs(int,boolean)
[javac] location: class org.apache.cordova.CordovaWebView
[javac] this.webView.setButtonPlumbedToJs(KeyEvent.KEYCODE_VOLUME_UP, false);
[javac] ^
[javac] .../DollarCandy/platforms/android/src/com/rjfun/cordova/plugin/nativeaudio/NativeAudio.java:189: method does not override or implement a method from a supertype
[javac] @OverRide
[javac] ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 3 errors

What is the difference between NativeAudio and LowLatencyAudio?

On PhoneGap Build plugins page there are two plugins pointing to the current repository:
NativeAudio: https://github.com/SidneyS/cordova-plugin-nativeaudio/blob/239e9f1/README.md
LowLatencyAudio: https://github.com/floatinghotpot/cordova-plugin-nativeaudio/blob/89fa228/README.md

What is the difference between them? Which one is more modern and should be used?

Actually I haven't managed to make any of them work:
โ€” LowLatencyAudio does play sounds preloaded with preloadAudio, but fails ones, preloaded with preloadFX.
โ€” NativeAudio simply crashes the app on the first sound (iOS 6.1 Simulator) *.

Thank you.

UPD: * Managed to avoid crashes by passing more params ({path}, {path}, 1, 1, 0) to preloadComplex method. But still no effect of preloadSimple/preloadFX + play methods.

iOS 8 not supporting!

Hey man!
on iOS 8, there is somekind of js error at your plugin specifically, and there for not only sound isnt playing, but the entire game is defected (the game i built).
For a live demo (of the bug) go to the App Store and search "Amit Moryossef", than, download "wreckingball".
OR:
go to : http://ipx-il.com/Apps/WreckingBall/level.html?level=1 (on iPhone it looks much better)
and try to play for 3 seconds.

is there a way in javascript to like say "i dont care if there are errors, if thereare, continue normaly (instead of the code do break; or die or something..)

AudioTrack obtainBuffer err -11

On some divices app crashes with only this logs

V/AudioTrack(14435): obtainBuffer(1) returned 0 = 0 + 0 err -11

I/WindowState(14686): WIN DEATH: Window{349191d3 u0 me.yakovalperin.nistagmus/me.yakovalperin.nistagmus.MainActivity}

I'm not sure if it's plugin's problem or it's something in Android itself, I just cant google any info about this err and hope someone here knows something.

How to play an exact time frame

We made an audio sprite of 5000 sound files with an accompying JSON file of start and stop times for each sound. Does there exist a way to play 1 sound file from x to y exactly? Or rather, start and make you stop at some time?

I guess we could just have a timer that runs when you play, say every 20ms and if playtime > endTime then stop

Does your plugin offer a way to check current playback time?

How do I know if I successfully preloaded an mp3?

I have this script in my html file

if( window.plugins && window.plugins.NativeAudio ) {
window.plugins.NativeAudio.preloadSimple( 'pop1', 'pop.mp3', function(){}, function(){console.log( 'error: ');});
}

I don't where window.plugins is, I'm just copying from the example. Then somewhere in my game I call

window.plugins.NativeAudio.play( 'pop1' );

No sound plays. My pop.mp3 is in my www folder; it's not in any other folders, so I thought it should have preloaded properly.

What is completeCallback

Why does the plugin have successCallback, failureCallback, and completeCallback?

The README says it's an error callback. Then what how is it different form failureCallback?

Gapless sound looping

Hi there,
I'm trying to loop a short sound (mp3 about 45kb) using exactly the Example Code, but between each iteration there's a little gap. I'm getting the same result obtained with the Media Audio Plugin :(
(obs.: the same audio file loop perfectly with Audacity)

I tried also with many values of the delay parameter (preloadComplex method), but from the doc there's not many info about him: Change the float-based delay parameter to increase the fade-in/fade-out timing.
I tried with 0, 0.1, 0.5 but I don't heard difference.

Some suggestions? Maybe I'm doing something wrong?
Thanks!

java.io.FileNotFoundException on Android

for any reason I'm getting the following exception on Android: error: java.io.FileNotFoundException

I'm using the plugin exactly as you mentioned and it is working nice for iOS but not for Android.

Out of bounds exception

We got this exception from our crash reporter which for now only happens on the Enspert RAINBOW device, with Android 4.2.2. It happened about five times in a row.

Android: 4.2.2
Manufacturer: Enspert
Model: RAINBOW
Date: Wed Oct 21 16:23:00 MESZ 2015

java.lang.ArrayIndexOutOfBoundsException: length=0; index=-945812838
    at java.util.HashMap.put(HashMap.java:396)
    at com.rjfun.cordova.plugin.nativeaudio.NativeAudio.executePreload(NativeAudio.java:82)
    at com.rjfun.cordova.plugin.nativeaudio.NativeAudio.access$100(NativeAudio.java:32)
    at com.rjfun.cordova.plugin.nativeaudio.NativeAudio$3.run(NativeAudio.java:222)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    at java.lang.Thread.run(Thread.java:838)

This is the relevant code we use for preloading the sounds (after the deviceready event):

for (var soundKey in this.sounds) {
    window.plugins.NativeAudio.preloadSimple(soundKey, this.sounds[soundKey], Ext.emptyFn, loadFail);
}
for (var loopKey in this.loopingSounds) {
    window.plugins.NativeAudio.preloadComplex(loopKey, this.loopingSounds[loopKey], this.loopingSoundsVolume, 1, 0, Ext.emptyFn, loadFail);
}

iOS: Volume level is ignored

Using LowLatencyAudio 1.1.3 on iOS7 couses the volume level on iOS devices to be ignored - even if the sound is turned off. The problem doesent occur on Android devices.

I have tested with the example drumpad app

Thanks for the great plugin!

preloadComplex doesn't work

preloadComplex never worked for me, I liked how SidneyS initialized AVAudioSession, so I used his version of the plugin with LowLatencyAudio, which actually functioned

Now that the 2 plugins are combined, preloadComplex doesn't work again

preloadSimple works, yet preloadComplex doesn't, the success callback is triggered, there is no sound, I'm investigating

WRITE_EXTERNAL_STORAGE required?

The plugin currently requires WRITE_EXTERNAL_STORAGE permissions.

Why/where is this needed? From a security perspective I would like to avoid requiring this permission, especially as I'm only using the plugin to play audio which shouldn't need write access somewhere.

iOS build error on build.phonegap.com

Hi.

I have included this plugin but whenever I try to build on build.phonegap.com it fails for iOS but builds and runs fine on Android. Any thoughts?

Thanks

No Audio iOS

So my problem is confusing.

I preload a complex file, which succeeds. And then I play the file I loaded, which also succeeds, and then completes but no sound actually plays, I can only tell via the success / complete callbacks that it actually completes. It works find on android. It's almost like its treating it like its muted.

Not working on ios 8.3?

When i do the exact same code in the example, the success callback always called but there is no sound at all, what could be the cause of this?

is it because nativeaudio is not supporting 8.3 yet?

Case sensitive MacOsx problem

Hi, I'm having trouble installing plugin on a MacOsx case sensitive system, because nativeaudio.h and nativeaudio.m files should be named NativeAudio.h and NativeAudio.m, as defined in your plugin.xml:

header-file src="src/ios/NativeAudio.h"/>
source-file src="src/ios/NativeAudio.m"/>

Can you fix it please?

Best regards
Giacomo

Plugin doesn't work in iOS (cordova 3.5)

Getting build errors when using this plugin.

sclark:sixtyvocab sean$ cordova --version
3.5.0-0.2.4
sclark:sixtyvocab sean$ phonegap --version
3.5.0-0.20.4

error here

Undefined symbols for architecture i386:
  "_AudioServicesCreateSystemSoundID", referenced from:
      -[LowLatencyAudio preloadFX:] in LowLatencyAudio.o
  "_AudioServicesDisposeSystemSoundID", referenced from:
      -[LowLatencyAudio unload:] in LowLatencyAudio.o
  "_AudioServicesPlaySystemSound", referenced from:
      -[LowLatencyAudio play:] in LowLatencyAudio.o
   ld: symbol(s) not found for architecture i386
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

Xcode throws the same error
http://cl.ly/image/120r0s3r111f

More of the stack here

Ld build/emulator/sixtyvocab.app/sixtyvocab normal i386
    cd /Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios
    export IPHONEOS_DEPLOYMENT_TARGET=6.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/sean/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:/Users/sean/Development/adt-bundle-mac-x86_64-20140321/sdk/tools"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/build/emulator -F/Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/build/emulator -filelist /Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/build/sixtyvocab.build/Debug-iphonesimulator/sixtyvocab.build/Objects-normal/i386/sixtyvocab.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -force_load /Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/build/emulator/libCordova.a -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.0 -framework AssetsLibrary /Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/build/emulator/libCordova.a -framework CoreGraphics -framework MobileCoreServices -framework CoreLocation -lz -Xlinker -dependency_info -Xlinker /Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/build/sixtyvocab.build/Debug-iphonesimulator/sixtyvocab.build/Objects-normal/i386/sixtyvocab_dependency_info.dat -o /Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/build/emulator/sixtyvocab.app/sixtyvocab
Undefined symbols for architecture i386:
  "_AudioServicesCreateSystemSoundID", referenced from:
      -[LowLatencyAudio preloadFX:] in LowLatencyAudio.o
  "_AudioServicesDisposeSystemSoundID", referenced from:
      -[LowLatencyAudio unload:] in LowLatencyAudio.o
  "_AudioServicesPlaySystemSound", referenced from:
      -[LowLatencyAudio play:] in LowLatencyAudio.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

>> ** BUILD FAILED **
>> 
>> 
>> The following build commands failed:
>>  Ld build/emulator/sixtyvocab.app/sixtyvocab normal i386
>> (1 failure)
>> { [Error: /Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/cordova/build: Command failed with exit code 65] code: 65 }
   [error] /Applications/MAMP/htdocs/sixtyvocab/phonegap/platforms/ios/cordova/build: Command failed with exit code 65

asset not exist?

Im building a phonegap-build app and i added this there:

<gap:plugin name="de.neofonie.cordova.plugin.nativeaudio" version="3.0.2" />

this is the manual for it?

https://github.com/SidneyS/cordova-plugin-nativeaudio/tree/239e9f1c671df4accb424787f2d337181c7cc446

I have ios8 , i tried to do a simple load a sound and play it in loop.

In my build the file was in a folder named audio, and i did the following:

window.plugins.NativeAudio.preloadComplex( 'music', 'audio/Sound.mp3', 1, 1, 0, function(msg){
}, function(msg){
console.log( 'error: ' + msg );
});

window.plugins.NativeAudio.loop( 'music' );

and i got an error saying "asset not exist ", What can be the cause of this?

loop not working

Hi there!
I can't get .loop to work actually looping. It's behaving exactly as .play. I'm using preloadComplex and play works well but can't make it loop.

Any pointers?

This plugin is awesome!

Unable to stop sound

Stop does not acctualy stop the music.

function stopSound(name) {
if(window.plugins && window.plugins.LowLatencyAudio)
PGLowLatencyAudio.stop(name);
}
stopSound("copter");

Sound muted in standby

Hi,
I noticed that the sound stops to play when the phone goes in standby mode, or also when - on android - the home button is pressed. Is it possible to fix this, and have the sound playing also in standby?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.