rna
react-native-audio-polyfill
npm i react-native-audio-polyfill
rna

react-native-audio-polyfill

Audio polyfill for desktop and native.

by Yusuke Shibata

1.1.8 (see all)License:MITTypeScript:Not Found
npm i react-native-audio-polyfill
Readme

react-native-audio-polyfill

html Audio class polyfill for react-native. You can use Audio for android,ios without modification to browser code.

Usage

import Audio from 'react-native-audio-polyfill'

const audio1 = new Audio()

audio1.onload = () => {
  console.log('audio loaded')
  audio1.play()
}

Play local files

audio1.addEventListener('loadeddata', () => audio1.play())
audio1.addEventListener('error', err => console.log('audio error:', err)
audio1.src = './test.mp3'
audio1.load()

Play remote files

audio1.addEventListener('loadeddata', () => audio1.play())
audio1.addEventListener('error', err => console.log('audio error:', err)
audio1.src = 'http://www.music.helsinki.fi/tmt/opetus/uusmedia/esim/a2002011001-e02-128k.mp3'
audio1.load()

Play assets in native

import asset1 from './test.mp3'

audio1.addEventListener('loadeddata', () => audio1.play())
audio1.addEventListener('error', err => console.log('audio error:', err)
audio1.src = asset1
audio1.load()

Install

npm install react-native-audio-polyfill

Add it to your project

react-native link

Coverage

functions

  • addTextTrack()
  • canPlayType()
  • load()
  • play()
  • pause()

properties

  • audioTracks
  • autoplay
  • buffered // only android
  • controller
  • controls
  • crossOrigin
  • currentSrc
  • currentTime
  • defaultMuted
  • defaultPlaybackRate
  • duration
  • ended
  • error
  • loop
  • mediaGroup
  • muted
  • networkState
  • paused
  • playbackRate
  • played
  • preload
  • readyState
  • seekable
  • seeking
  • src
  • startDate
  • textTracks
  • videoTracks
  • volume

event

  • abort
  • canplay
  • canplaythrough
  • durationchange
  • emptied
  • ended
  • error
  • loadeddata
  • loadedmetadata
  • loadstart
  • pause
  • play
  • playing
  • progress // only android
  • ratechange
  • seeked
  • seeking
  • stalled
  • suspend
  • timeupdate
  • volumechange
  • waiting

TODO

  • canPlayType support.
  • Create audio component with controls=true.
  • Buffering progress for ios.

License

MIT

Downloads/wk

2

GitHub Stars

13

LAST COMMIT

NaNyrs ago

MAINTAINERS

1

CONTRIBUTORS

0

OPEN ISSUES

5

OPEN PRs

0
VersionTagPublished
1.1.8
latest
3yrs ago
No alternatives found
No tutorials found
Add a tutorial