Music Player - WickSound class

Working on adding a Howler sound wrapper to the Editor to have better in-built sound capabilities:

Here is the API…

WickSound = class {
	constructor(assetName) {
	loop(loop)
	volume(volume)
	stereo(pan)
	seek(seconds)
	play(offset) 
	mute()
	unmute()
	isPlaying()
	stop()
	pause()
	currently()
	duration()
}

Example Usage:

// declaring an instance...
let mysong = new WickSound("mySong.mp3");

// play song starting at 3.5 seconds of the song...
mysong.play(3.5);

// set song to fully sound at left speaker
mysong.stereo(-1);

// pausing only this song
mysong.pause();

// resuming song where it was paused.
mysong.play();

// stop only this song
mysong.stop();

// set song to loop forever
mysong.loop(true);

// set song to not loop
mysong.loop(false);

// returns song duration in seconds...
mysong.duration()

// returns song current cursor in seconds...
mysong.currently()

// returns true if the song is still playing
mysong.isPlaying()

// set song volume to half of its max volume.
mysong.volume(0.5)

// mute song
mysong.mute()

// unmute song with the same volume before mute
mysong.unmute()

// seek (set song cursor to 34.6 seconds)
mysong.seek(34.6)

I’ll probably do a demo tomorrow… everything works already : )

5 Likes

:O :partying_face:

mmmmYES
We need this

is there a place for us to test this? this looks exciting…

1 Like

Yes, I’ll be posting a wick file with a API written temporarily (You can use it like that) in the First Layer/Frame. I’ll be pushing the changes to my branch after you guys test it. It will not be officially within the Editor online, but I’m planning to upload my own Custom Editor (I don’t have a cool name yet) when I rent a host service… I’m planning doing that early next year.

1 Like

I’m pretty proud with what we can achieve with things like this… this small things make a huge difference…

WickSoundDemo.wick (1.3 MB)

4 Likes

This looks very neat and useful. But I think “currently” is a bad name for the function that gets the audio’s time position. I think something like “currentTime” would work better.

Thank you for the feedback.

I’ll probably erase that method completely. seek() already returns the current time if no argument is passed. (same as Howler)

1 Like

Ok, I just converted this small music player into a native mac-os app using electron.

Yes! From Wick to Mac-OS… In theory, we could put our apps made in wickeditor into the appstore… The downside is that there is an increase in size. It went from 5Mgs to 192Mgs :confounded:, but this is just the beginning.

Here is a picture running this wick app natively in macos (not using the web browser…)

3 Likes

Does this stop all the songs or just the ones named?

If you use the stop() function on a song from the WickSound class, only this one song will stop.

Example:

// create an instance for a song
let mySong = new WickSound(“mySong.mp3”);

// stop only that song
mySong.stop();