eshaz / icecast-metadata-js

Browser and NodeJS packages for playing and reading Icecast compatible streaming audio with realtime metadata updates.
164 stars 20 forks source link

[Enhancement] [icecast-metadata-player] getter and setter for volume #166

Closed Yahav closed 1 year ago

Yahav commented 1 year ago

So, as with any audio library i think a volume setter/getter is somewhat of a must. Is there anyway to implement this within this package? html5 audio and webaudio have this ability of course so its just a matter of writing adding it to the wrapper.

eshaz commented 1 year ago

You can change the volume by getting the internal Audio element through player.audioElement and getting / setting the volume there.

All of the audio output from IcecastMetadataPlayer is routed through this Audio element, which is created internally by default, or it can be supplied on instantiation (see options)

const player = new IcecastMetadataPlayer("https://stream.example.com");

// get the volume
const myVolume = player.audioElement.volume;

// set the volume
player.audioElement.volume = .5;
Yahav commented 1 year ago

Amazing, and this will work for all encoding methods?