A audio library for applications.
Suono is a simple native audio lib for music application, it compatible with android native browser.
Easy to extend and welcome PR and issues.
npm i suono
# or using yarn
yarn add suono
import { Suono } from 'suono'
const suono = new Suono({
autoplay: false,
controls: false,
preload: 'metadata',
fallback: 'Your browser doesn\'t support HTML5 audio.',
autoSkip: true,
volume: 1,
mode: 'order',
debug: false,
crossorigin: 'anonymous'
})
<script type="module">
import { Suono } from '../dist/index.esm.js'
const suono = new Suono({
mode: 'order' // default value
})
</script>
return the current source of the audio
for debugging
set auto play or not, according to the browser autoplay strategy
set the native preload type, such as none, metadata, auto
. Default value is metadata
set loop, default false
set true to show the native controls for audio tag
set the range of volume, range from 0 to 1
if face the croessorigin issue, you can set the crossorigin type: anonymous
or use-credentials
if the source is loading, will return true
the playlist from the instance
the current index in the playlist
the playmode,'order', 'single', 'shuffle', 'list'
set auto skip to next audio when encounter errors or something else
create the audio in the memory and register the hooks for events, and load the resources.
reset the media element and load the resources, play from the start
play the audio
pause the audio
seek to the specific timing of the audio
skip to the other item in the playlist and play
play the previous or the next item in the playlist, will have different behavior accord to different play mode
append the audio element before the end tag of body
remove the audio element from the end tag of body
destroy the audio instance and element
get current item name
get current item src
get current item sources, for multiple source item
"scripts": {
"prebuild": "del-cli dist",
"esm": "tsc --module esnext && cpy dist/index.js dist --rename index.esm.js",
"cjs": "tsc --module commonjs",
"build": "npm run esm && npm run cjs",
"dev": "npm run build --watch",
}
MIT