Computes the duration of an mp3 buffer in react native
npm install --save react-native-get-mp3-duration
# or
yarn add react-native-get-mp3-duration
import getMP3Duration from 'get-mp3-duration';
import {FileSystem} from 'react-native-file-access'; // or another lib that read the file into base64
const bufferStr = await FileSystem.readFile('fixtures/vbr.mp3', 'base64')
const duration = await getMP3Duration(bufferStr)
console.log(duration, 'ms') // 285727 ms
import getMP3Duration from 'get-mp3-duration';
import {FileSystem} from 'react-native-file-access'; // or another lib that read the file into base64
const bufferStr = await FileSystem.readFile('fixtures/vbr.mp3', 'base64')
const duration = await getMP3Duration(bufferStr, 'seconds')
console.log(duration, 'seconds') // 285.727 seconds
- mp3-duration this package is a fork of mp3-duration to add browser support.
- vmsg is an optimized mp3 recorder for the web which ports the lame mp3 encoder to wasm.
MIT © Travis Fischer
Support my OSS work by following me on twitter