Releases: chrisweb/web-audio-api-player
Releases · chrisweb/web-audio-api-player
v5.3.2
v5.3.1
v5.3.0
- after experimenting with the player on mobile I noticed that muting the sound when the visibility api reports that the app is hidden is actually not ideal because the song keeps playing and if hidden for a while it might even reach the end of the song, when that happens the player triggers an event but the player UI might not be able to react as the page is hidden, so I changed how the visibility API feature works, it now pauses the song when hidden (if the visibility watch feature is enabled / it is not by default), I put added a second option to choose what action gets performed if hidden, by default it will pause the song but you can chose to mute the song if that's what you prefer... I also updated the simple example and updated the docs to reflect the changes
breaking changes:
- removed the option visibilityAutoMute
- added new option: visibilityWatch (boolean, default: false)
- added second option: visibilityHiddenAction (default: PlayerCore.VISIBILITY_HIDDEN_ACTION_PAUSE)
check out the player options documentation for more details
v5.2.1
- the loadSound() player function is now public, pass a sound and an optional seekPercentage value
- documented loadSound in readme "player-functions"
v5.1.1
- fixed a bug where safari would not call onended if the currentTime of the audio element got set to a value equal to the duration
- fixed a bug where visibility change would call unmute and but the gain value was not a number
- fixed bug where player was calling next() even though willPlayNext indicated that queue is empty (and loop queue was not active)
- removed the console.warn when there are no more sounds in the queue, the willPlayNext of the onEnded callback already tells you there is no next sound
- reverted change that would round duration and currentTime, I think it is best to return the original value and let the UI decide how it wants to format it, revert audio element preload value (from "metadata") to "auto"
v5.1.0
- breaking change: renamed "createAudioContextOnFirstUserInteraction" to "unlockAudioOnFirstUserInteraction"
- fixed a bug where on start the playing percentage returned NaN
- fixed a bug where the player on iOS devices would not always play or not trigger progress callbacks
- fixed the isMuted function which was always returning the opposite of what should be the correct value
- fixed a case where a song duration that had been set manually would get overwriten
- if playTimeOffset or a setPosition function is called with a value that is > sound duration the player will now output a console warning to let you know something is not right
- both setPosition and setPositionInSeconds are now faster when using the "player_mode_audio", previously the song would get paused and then started playing at the new position, now the position gets changed and no pause gets triggered, unfortunatly fastseek is only available on firefox so it does not get used yet, for "player_mode_ajax" there is no seek, the sound still needs to get stopped and then re-started at the new position as the audio buffer source can not be re-used
- added a new player core options called "addAudioElementToDom", which is false by default, meaning the audi element will be kept offscreen, if you still want to add it to the DOM set this option to true
- added a new onSeeking callback for sounds, this callback gets called when the position gets changed, useful for example when the sound is not playing and the user clicks on the progress bar, which triggers a position change, using the onSeeking you can then ajust values like the current progress position and playTime
- added new functions setLoop() and getLoop() to the sound object, those can be used after a sound got added to the queue to change the value for "loop song" or check what the current value is
- added a getCurrentSound function to the player
- added a player option called "volumeTransitionTime", to change the volume transition duration, by default 100ms, set it to 0 for an instant transition, if > 0 a player volume change will fade from current value to new value
- most player methods now return a promise, this does not change the current behavior, but if you want to use them you now can, I recommend using a try catch and await the promise or call promise.catch to be able to catch eventual errors thrown by the player
- increased the target version for typescript to es2016 (as it almost 2024 now), this decreased the bundle size by a quarter
- addeda mute/unmute button to the example
- added play songs by ID to the example and a show extra song info from an external source (extra info like song title, album cover, artist name, ...)
- added a play a song by ID and with a playTimeOffset (does not start at the beginning of the song but at 10 seconds) to the example
- added two new buttons to the example, to show a toggle loop sound and a toggle for loop queue
- improved readme documentation by listing all available player functions as well as the sound functions
- improved callbacks documentation in readme, by adding description of callback parameters
- added a new chapter to readme to explain why audio can be locked on mobile and how to unlock it
v5.0.4
v5.0.3
v5.0.2
v5.0.0
v5.0 contains a lot of improvements compared to the v4.x branch, but the API is fully compatible with the 4.x series
- fixed several bugs related to the volume, like setting volume before playing a sound or getting intial volume to update UI accordingly
- each sound now has it's own gain node, this will allow in future version to let the user adjust the loudness of sounds in a playlist on a per sound basis and also to crossfade sounds or add a fade in / out to sounds
- promises got replaced by more modern async / await which resulted in cleaner code
- fixed several typescript types (I use typescript and tested this a lot, but if you find a wrong type or know how to improve the types (interfaces) then please open a ticket / PR)
- improved documentation / readme
- added some more buttons to example to show how to use them if needed
the audio player has no external dependencies