Package Exports
- react-native-get-mp3-duration
- react-native-get-mp3-duration/index.ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-get-mp3-duration) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-native-get-mp3-duration
Computes the duration of an mp3 buffer in react native
Install
npm install --save react-native-get-mp3-duration
# or
yarn add react-native-get-mp3-duration
Usage
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
Duration in seconds
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
Related
- 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.
License
MIT © Travis Fischer
Support my OSS work by following me on twitter