
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
AMRPlayer is a modernized version of amr.js, supporting the loading and playback of AMR audio format.
amr.js has ceased updates, utilizing numerous global variables, lacking support for strict mode, not supporting modularity, and missing documentation.
This project has modernized it, supporting ES Module, CommonJS, and IIFE formats, compatible with modern build tools (such as Webpack, Rollup, Vite, etc.). It also adds playback control support and convenient data writing methods.
I used AMR audio interpretation in my project and found that there are not many libraries to choose from. Although amr.js lacks maintenance, it is still usable. Thanks to the original authors for their contributions, and thus I also share my achievements with everyone.
You can install AMRPlayer via npm:
npm install amrplayer
Depending on your project environment, you can choose any of the following methods to import AMRPlayer.
If your project uses ES Module (e.g., Vite or modern browser environments), you can import it as follows:
import AMRPlayer from 'amrplayer';
// Using AMRPlayer
const amrplayer = new AMRPlayer();
If your project uses CommonJS, you can import it as follows:
const AMRPlayer = require('amrplayer');
// Using AMRPlayer
const amrplayer = new AMRPlayer();
If you are directly using the <script> tag in the browser, you can import it as follows:
<script src="https://unpkg.com/amrplayer/dist/amrplayer.js"></script>
<script>
// AMRPlayer will be exposed as a global variable
const amrplayer = new AMRPlayer();
</script>
import AMRPlayer from 'amrplayer';
const amrplayer = new AMRPlayer();
ArrayBufferfetch('audio.amr')
.then(response => response.arrayBuffer())
.then(arrayBuffer => amrplayer.setBuffer(arrayBuffer));
Blob<input type="file" name="file" id="file" accept=".amr">
const file = document.getElementById('file').files[0];
// Note that setBlob is an asynchronous interface
await amrplayer.setBlob(file);
Convenient for playback using <audio>.
<audio id="audio" controls></audio>
const url = amrplayer.getWAV();
document.getElementById('audio').src = url;
const amraudio = amrplayer.getAudio(() => console.log('Audio playback ended'));
// Synchronous interface
amraudio.start(); // Start playback
amraudio.stop(); // Stop playback
// Asynchronous interface
amraudio.suspend(); // Pause playback
amraudio.resume(); // Resume playback
amraudio.toggle(); // Toggle playback state
amraudio.close(); // Close the audio context when amraudio is no longer needed
console.log('Current audio state:', amraudio.state);
new AMRPlayer()AMRPlayer.setBuffer(arrayBuffer)Decodes the passed ArrayBuffer into Float32Array and sets it as the audio data.
arrayBuffer: The ArrayBuffer to decode.Float32Array.AMRPlayer.setBlob(blob)Converts the passed Blob into ArrayBuffer and sets it as the audio data.
blob: The Blob to convert.Promise that resolves to the decoded Float32Array.AMRPlayer.getAudio(onEnd)Creates an AMRAudio instance and sets the callback function for when audio playback ends.
onEnd: The callback function triggered when audio playback ends.AMRAudio instance.AMRPlayer.getWAV()Converts the current audio data to WAV format.
data:audio/wav;base64,...AMRAudio Classnew AMRAudio(float32Array)Creates an AMRAudio instance.
float32Array: The Float32Array used to create the audio buffer.AMRAudio.start()Starts audio playback.
AMRAudio.stop()Stops audio playback.
AMRAudio.close()Closes the audio context. Asynchronous interface.
AMRAudio.suspend()Suspends the audio context. Asynchronous interface.
AMRAudio.resume()Resumes the audio context. Asynchronous interface.
AMRAudio.toggle()Toggles the audio playback state, cycling through: play -> pause -> resume. Asynchronous interface.
AMRAudio.stateGets the current audio playback state: 'stopped', 'running', 'suspended'.
AMRAudio.onEnd()Automatically called when playback ends. Triggered by automatic end or calling AMRAudio.stop().
This project is open-sourced under the MIT license. For more details, please refer to the LICENSE file.
FAQs
AMR Codec in Javascript (Modern Build Support)
We found that amrplayer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.