Awesome
musique.js
A JavaScript Music Player API to create custom players.
How-to
Add musique.js into your HTML file.
You should download the library and reference the JavaScript file using a <script>
tag somewhere on your HTML pages.
<script src="musique.min.js"></script>
Create a new instance of Musique.
Once added the library you can create a new instance of Musique with an optinal configuration and a playlist.
var musique = new Musique({
'volume': 75,
'autoplay': true,
'playlist': [{
'title': 'Title Track 01',
'artist': 'Artist Track 01',
'album': 'Album Track 01',
'poster': 'https://foo.com/track01.jpg',
'src': 'https://foo.com/track01.mp3'
},
{
'title': 'Title Track 02',
'artist': 'Artist Track 02',
'album': 'Album Track 02',
'poster': 'https://foo.com/track02.jpg',
'src': 'https://foo.com/track02.mp3'
}]
});
Create and Enjoy!
Now, you can use the API to create awesome music players.
musique.next();
API
Table of contents
- Musique()
- Musique#play()
- Musique#setTrack()
- Musique#pause()
- Musique#stop()
- Musique#next()
- Musique#prev()
- Musique#volume()
- Musique#mute()
- Musique#reset()
- Musique#toggle()
Musique(options)
Creates a new instance of Musique
.
options
: A given options to customize an instance.volume
: Set the volumen as a value from0
to100
. Default:50
indexTrack
: A given number of the initial track. Default:0
.muted
: Set if the instance starts muted. Default:false
.playlist
: Define a collection oftrack
s. Default:[]
.track
title
artist
album
poster
src
autoplay
: Set if the instance starts playing automatically. Default:false
.
var musique = new Musique({
'volume': '75'
});
Musique#play([indexTrack])
Starts playback the current or a given indexTrack
.
indexTrack
: A given number of track.
musique.play();
musique.play(12);
Musique#setTrack(indexTrack)
Sets a given indexTrack
as current track
.
indexTrack
: A given number of track.
musique.setTrack(4);
Musique#pause()
Pauses playback.
musique.pause();
Musique#stop()
Stops playback and seeks to the beginning.
musique.stop();
Musique#next()
Jumps to the next track.
musique.next();
Musique#prev()
Jumps to the previous track.
musique.prev();
Musique#volume(value)
Defines the volumen as a value from 0
to 100
.
musique.volume(75);
Musique#mute()
Mutes an instance of Musique.
musique.mute();
Musique#reset()
Reset the current track to the initial.
musique.reset();
Musique#toggle()
Toggles between pause and play.
musique.toggle();
## Maintained by
- Guille Paz (Front-end developer | Web standards lover)
- E-mail: guille87paz@gmail.com
- Twitter: @pazguille
- Web: http://pazguille.me
License
Licensed under the MIT license.
Copyright (c) 2014 @pazguille.