npm.io
1.0.3 • Published 4 years ago

react-native-get-mp3-duration

Licence
MIT
Version
1.0.3
Deps
1
Size
11 kB
Vulns
0
Weekly
0
Stars
1

react-native-get-mp3-duration

Computes the duration of an mp3 buffer in react native

NPM Build Status JavaScript Style Guide

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
  • 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 twitter

Keywords