Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
cordova-plugin-advanced-nativeaudio
Advanced tools
Cordova/PhoneGap Plugin for low latency Native Audio Playback, must have for HTML5 games
Cordova / PhoneGap 3.5+ extension for Native Audio playback, aimed at HTML5 gaming and audio applications which require minimum latency, polyphony and concurrency.
This Plugin is forked by this Fork and has some added features.
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.
Via Cordova CLI:
cordova plugin add cordova-plugin-advanced-nativeaudio
deviceReady
.preloadSimple()
) or looping, ambient background audio (preloadComplex()
)play()
the audio asset via its id.unload()
the audio asset via its id.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.
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.
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.
play: function (id, successCallback, errorCallback, completeCallback)
Plays an audio asset.
loop: function (id, successCallback, errorCallback)
Loops an audio asset infinitely - this only works for assets loaded via preloadComplex.
stop: function (id, successCallback, errorCallback)
Stops an audio file. Only works for assets loaded via preloadComplex.
unload: function (id, successCallback, errorCallback)
Unloads an audio file from memory.
setVolumeForComplexAsset: function (id, volume, successCallback, errorCallback)
Changes the volume for preloaded complex assets.
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);
}
FAQs
Cordova/PhoneGap Plugin for low latency Native Audio Playback, must have for HTML5 games
The npm package cordova-plugin-advanced-nativeaudio receives a total of 1 weekly downloads. As such, cordova-plugin-advanced-nativeaudio popularity was classified as not popular.
We found that cordova-plugin-advanced-nativeaudio demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.