GithubHelp home page GithubHelp logo

lowlatencyaudio's Introduction

LowLatencyAudio

LowLatencyAudio is a native plugin for PhoneGap. This implementation is designed to be compatible with PhoneGap 3.0 CLI deployment, and supports both iOS and Android.

Installation

The LowLatencyAudio plugin can be added to your project via the PhoneGap command line tools. Simply use the following command to add this to your project:

phonegap local plugin add https://github.com/triceam/LowLatencyAudio

Usage

  1. Preload the audio asset - Note: Make sure to wait for phonegap deviceready event before atteptimpting to load assets
  2. Play the audio asset
  3. When done, unload the audio asset

API methods

preloadFX: function ( id, assetPath, success, fail)
	params: ID - string unique ID for the audio file
			assetPath - the relative path to the audio asset within the www directory
			success - success callback function
			fail - error/fail callback function
	detail:	
			The preloadFX function loads an audio file into memory.  Assets that are loaded using preloadFX are managed/played using AudioServices methods from the AudioToolbox framework.   These are very low-level audio methods and have minimal overhead.  Audio loaded using this function is played using AudioServicesPlaySystemSound.   These assets should be short, and are not intended to be looped or stopped.   They are fully concurrent and polyphonic.
		
preloadAudio: function ( id, assetPath, voices, success, fail) 
	params: ID - string unique ID for the audio file
			assetPath - the relative path to the audio asset within the www directory
			voices - the number of polyphonic voices available
			success - success callback function
			fail - error/fail callback function
	detail:	
			The preloadAudio function loads an audio file into memory.  Assets that are loaded using preloadAudio are managed/played using AVAudioPlayer.   These have more overhead than assets laoded via preloadFX, and can be looped/stopped.   By default, there is a single "voice" - only one instance that will be stopped & restarted when you hit play.  If there are multiple voices (number greater than 0), it will cycle through voices to play overlapping audio.
	
play: function (id, success, fail) 	
	params: ID - string unique ID for the audio file
			success - success callback function
			fail - error/fail callback function
	detail:	
			Plays an audio asset
	
loop: function (id, success, fail) 	
	params: ID - string unique ID for the audio file
			success - success callback function
			fail - error/fail callback function
	detail:	
			Loops an audio asset infinitely - this only works for assets loaded via preloadAudio
	
stop: function (id, success, fail) 	
	params: ID - string unique ID for the audio file
			success - success callback function
			fail - error/fail callback function
	detail:	
			Stops an audio file - this only works for assets loaded via preloadAudio
	
unload: function (id, success, fail) 	
	params: ID - string unique ID for the audio file
			success - success callback function
			fail - error/fail callback function
	detail:	
			Unloads an audio file from memory

License

THIS SOFTWARE IS PROVIDED BY ANDREW TRICE "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANDREW TRICE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

lowlatencyaudio's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lowlatencyaudio's Issues

ACTION RESTRICTED FOR FX AUDIO

Hey Andrew,

Thanks for making the plugin. The play method works fine, but I get the

ACTION RESTRICTED FOR FX AUDIO

when I try to run the loop method.

Any help appreciated.

Remote Audio

I've successfully setup the plugin, preload the audio, and play the audio on-button click. But I've come to realize that your plugin may not support remote audio (which is crucial for my project.

LowLatencyAudio.preloadAudio('id', 'http://www.url.com/test.mp3', 1);

Am I right that this plugin is for locally stored files only

License does not grant any rights

Your license does not grant any rights to the user. So from a legal point of view, no one is allowed to copy or even use the plugin. :-(
All your license does is excluding your liability for everything.
Compare it with, e.g., the MIT license which contains a section granting the user

Permission [...] to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software

Pause Feature

Thanks for putting this together. I'd like to additionally be able to pause sounds, is that something that you plan on adding in the future?

No sound on iOS8 or 8.1 or using latest version of xcode.

Andrew,

I have used the Low Latency Audio plugin before without any issues, it works great! However, with the recent release of iOS8 and 8.1 I updated Xcode and build a new phonegap project using this plugin and no sound is playing anymore and I don't see any errors either.

Is there a special setting that I need to use for the latest version of xcode or ios?

In the mean time, I revert back to using the HTML audio tags with start great but while you keep running the app it will start to become sluggish.

Help please.

Remote Audio

First, thank you for the plugin. I am currently using it with phonegap build. I have a question. Is it possible to use this with remote audio files? If not, is there a certain reason why? if so, can you show me what I need to change in order to allow absolute paths?

Again thank you

God bless
jason

Build fails after installing plugin

Steps I have taken to reproduce...

  • My project builds and runs on the iOS simulator just fine
  • run phonegap local plugin add https://github.com/triceam/LowLatencyAudio to install the plugin
  • attempt to run on the simulator again

Build fails. Full build log can be found here: http://pastebin.com/DthE4S4f

Thanks

Error: CDVPlugin class LowLatencyAudio (pluginName: LowLatencyAudio) does not exist.

After installing the plugin, we see the error below.

We are on PhoneGap 3.4. We installed using the new CLI interface: phonegap local plugin add https://github.com/triceam/LowLatencyAudio.

2014-03-10 19:59:25.960 Spoof[7828:60b] CDVPlugin class LowLatencyAudio (pluginName: LowLatencyAudio) does not exist.
2014-03-10 19:59:25.962 Spoof[7828:60b] ERROR: Plugin 'LowLatencyAudio' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-03-10 19:59:25.963 Spoof[7828:60b] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [
"INVALID",
"LowLatencyAudio",
"preloadFX",
[
"sounds/guessed_right.mp3",
"sounds/guessed_right.mp3"
]
]

LowLatencyAudio.js

I noticed the LowLatencyAudio.js file contains the require() keyword. Should we be using browserify or something? A little confused Thanks.

Following the Instructions, but failing somewhere

So I did a lot of reading up on your plugin and I installed it via Terminal as instructed.

The installation was successful and my IOS Phonegap 3.0 app built with no errors.

  1. I added the javascript in the header of my HTML file like so

script type="text/javascript" src="cordova.js"
script type="text/javascript" src="cordova_plugins.js"
script type="text/javascript" src="js/LowLatencyAudio.js"

script
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
}
/script

  1. And I added this to the body

    $('#btn').click(function() {

    LowLatencyAudio.preloadAudio('id', 'files/test.mp3', 1);
    
    LowLatencyAudio.play( 'id');
    

});

But the audio doesn't play. I really would like to use this plugin, hoping you can help

Phonegap Build

How would I go about using this with PhoneGap Build. There seems to
be a plugin based on your plugin but I can't get it to work.

Locally I have my app working without any problems but when I send it to PG build
so I can get it signed/zipaligned the app breakds down.

Problem when loading many files

I've been using this plugin with great results. But sometimes when the sounds are loading I'm getting this error on Android devices:

02-24 00:22:53.480: W/PluginManager(5138): THREAD WARNING: exec() call to LowLatencyAudio.play blocked the main thread for 20ms. Plugin should use CordovaInterface.getThreadPool().

¿Any ideas?

Pause

Is there a way to pause the audio. i.e. I am using the loop function for a music bed in the background of a game. I was hoping to allow the users to mute the audio thus pause it and then unmute (unpause)

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.