1.0.0 • Published 3 years ago

@jswork/next-audio v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

next-audio

Pure audio api for next.

version license size download

installation

npm install -S @jswork/next-audio

status

codestatusdescription
-1error当在音频/视频加载期间发生错误时
0init当音频组件在初始状态
1play当音频/视频已开始或不再暂停时
2pause当音频/视频已暂停时
3loaded当浏览器已加载音频/视频的元数据时
4ended当目前的播放列表已结束时
5canplay当浏览器可以播放音频/视频时

method

apimemberparamsdescription
playmethod-Play audio
pausemethod-Pause audio
loadmethod-Force load audio
stopmethod-Stop audio
seekmethod(num)Set seek by currentTime
movemethod(num)Set seek percent(0-1)
destroymethod(num)Destroy from memroy/dom and unload events.
propmethod(name,args)Set props(loop/volume/rate/current)

method - prop(name)

namedescription
loopSet/get loop
volumeSet/get volume
rateSet/get playback rate
currentSet/get play currentTime
mutedSet/get muted(mute/unmute)
endedGet if audio is ended

property

apimemberparamsdescription
timesproperty-Return rate/current/duration seconds
statusproperty-Get current status.

usage

<audio id="audio" controls src="http://kolber.github.io/audiojs/demos/mp3/juicy.mp3">
  NOT SUPPORT
</audio>
import NxAudio from '@jswork/next-audio';

// code goes here:
const nxAudio = new NxAudio({ element: document.getElementById('audio') });
nxAudio.play();
nxAudio.prop('loop', true);

resources

license

Code released under the MIT license.