This package has been migrated to @cycjimmy/h5-audio-controls for scoped NPM package. Please switch to @cycjimmy/h5-audio-controls to stay up to date.
$ npm install h5-audio-controls --save
# or
$ yarn add h5-audio-controls
import H5AudioControls from 'h5-audio-controls';
# OR
let H5AudioControls = require('h5-audio-controls');
new H5AudioControls(audioSrc [, options])
-
audioSrc
: [string] a url to an audio file -
The
options
supports:context
: [string|element] the context of audio controller. Defaultdocument.body
.position
: [string] the position of audio controller.- Choose one of the four options:
'left-top'
'top-right'
(Default)'right-bottom'
'left-bottom'
- Choose one of the four options:
buttonSize
: [string|number] Set button wrapper size. Default''
picSize
: [string|number] Set button picture size. Default''
autoPlay
: [boolean] Whether to play immediately after loading. Defaulttrue
-
H5AudioControls
instance supports the following methods:load()
: init controller.play()
: play the audio.pause()
: pause the audio.stop()
: stop the audio.
<script src="H5AudioControls.min.js"></script>
<script>
var audioSrc = '../media/test_audio.mp3';
new H5AudioControls(audioSrc).load();
</script>
To use via a CDN include this in your html:
<script src="https://cdn.jsdelivr.net/npm/h5-audio-controls@1/build/H5AudioControls.min.js"></script>