Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A Vue.js plugin to play sounds.

License

NotificationsYou must be signed in to change notification settings

redcodemohammed/vue-sounds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Vue.js plugin to play sounds.

Easy to add sounds to your components.

Installation

npm install vue-sounds --save

Or with yarn

yarn add vue-sounds

Setup

importVuefrom'vue'importstorefrom'./store'importsoundsfrom"vue-sounds";Vue.use(sounds,store);

Usage

Adding audio clip

There are two methods to do that

Adding then when the user enters the website

You pass them in the option parameter

Vue.use(sounds,store,{sounds:[{name:"",url:""},        ....]});

Note that name field must be unique for every audio clip.

Dynamically adding clips

In any components you will have access to$sounds object:

this.$sounds.add("name","url");

The $sounds object

This will give you access to these methods:

MethodParametersReturn typeDescription
getsoundName {string}Player objectthis will search for an audio with the given name and returns a player object for that audio clip.
addsoundName {string} and url {string}voidit will add a new audio clip to the store.
getAllno parametersArray with {name, url} objectsreturns all of the audio clips in the store.

Play sounds

Before you can play sounds you have to create aPlayer object to do so, the plugin gives you access toget method

this.$sounds.get("name");

This will return a Player object that gives you access to these method:

MethodParametersReturn typeDescription
playno parametersPromise<void>play the clip.
pauseno parametersPromise<void>pause the clip.
stopno parametersPromise<void>stops the clip.
volumeoptional vol {Number} range (0-1)numbersets the volume to vol and returns it, if vol is undefined returns the current volume.

It will also throw an error if you try to get a clip that doesn't exist.

About

A Vue.js plugin to play sounds.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp