dcl-audius-player
v1.0.23
Published
Decentraland libary for implementing Audius music into your scene
Downloads
42
Maintainers
Readme
DCL Audius Player
This project allows you to integrate the Audius decentralized music platform into your Decentraland scene!
Install
To use any of the helpers provided by this library:
Install it as an npm package. Run this command in your scene's project folder:
npm install dcl-audius-player
Add this line at the start of your game.ts file, or any other TypeScript files that require it:
import { APPlayingNewTrack, APStoppedTrack, AudiusPlayer, AudiusPlaylistType, AudiusUIType } from "dcl-audius-player";'
Usage
Basic Audius Player Integration
The DCL Audius Library requires a few arguments when being constructed:
playlistName
: String for the Audius Playlist to playorder
: Either AudiusPlaylistType.ORDER or AudiusPlaylistType.SHUFFLEuiType
: Either AudiusUIType.CORNER or AudiusUIType.NONEautoStart
: Boolean to auto start the playlist on scene loadloop
: Boolean to loop the playlist once it's finishedvolume
: Set the volume of the audio stream
This example uses MyAmazingComponent to do < insert use case >
to an entity over a period of 2 seconds:
import { APPlayingNewTrack, APStoppedTrack, AudiusPlayer, AudiusPlaylistType, AudiusUIType } from "dcl-audius-player";'
AudiusPlayer.init(
'angzaar', //playlist name
AudiusPlaylistType.ORDER, //playlist type - order, shuffle
AudiusUIType.NONE, //ui type - top, corner
false, //auto start
true, //loop
.5) //volume
Audius Player Events
There are a couple out of the box Event Listeners with the Audius Player
- APPlayingNewTrack - playing a new track
- APStoppedTrack - stopped playing a track
- APFinishedPlaylist - finished a playlist
Create event listeners below:
AudiusPlayer.events.addListener(APPlayingNewTrack, null, (info)=>{
log('new track info is', info)
})
AudiusPlayer.events.addListener(APStoppedTrack, null, (info)=>{
log('stopped track', info)
})
Audius Player Functions
Once your Audius Player is initialized, you can peform several functions within the player:
Toggle playing
SHIFT + F
Play Next Song
SHIFT + E
Change Playlist
AudiusPlayer.changePlaylist('new name')
Get Current Playing Track
AudiusPlayer.currentlyPlaying()
Get Current Playlist Tracks
AudiusPlayer.getPlaylist()
Change Volume
AudiusPlayer.updateVolume(.5)
Play
AudiusPlayer.play()
Play Specific Track
AudiusPlayer.playSong(2) //index of the track to play
Stop
AudiusPlayer.stop()
...
Copyright info
This scene is protected with a standard Apache 2 licence. See the terms and conditions in the LICENSE file.