Buzz, a Javascript HTML5 Audio library

Related tags

Video/Audio buzz
Overview

Buzz, a Javascript HTML5 Audio library

Buzz is a small but powerful Javascript library that allows you to easily take advantage of the new HTML5 audio element. It tries to degrade properly on non-modern browsers.

var mySound = new buzz.sound("/sounds/myfile", {
    formats: [ "ogg", "mp3", "aac" ]
});

mySound.play()
    .fadeIn()
    .loop()
    .bind("timeupdate", function () {
        document.querySelector("#timer").innerHTML = buzz.toTimer(this.getTime());
    });

Official website

http://buzz.jaysalvat.com/

Real life demo

http://buzz.jaysalvat.com/demo/

Documentation

http://buzz.jaysalvat.com/documentation/

Contributing

Please don't edit files in the dist subdirectory as it is generated via Grunt. You'll find source code in the src subdirectory! Regarding code style like indentation and whitespace, follow the conventions you see used in the source already.

PLEASE DO NOT use Gruntfile. I will. :)

License

The MIT License (MIT)

Copyright (c) 2021 Jay Salvat

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • doesn't play() after stop()

    doesn't play() after stop()

    Hi,

    I'm adding sound to a box animation. When the animation finishes I am calling:

    sound.stop()

    However, when I try to play it again(

    sound.play()

    ) after, I don't get any sound...

    opened by metamindxx 11
  • Publish on npm

    Publish on npm

    Is this on npm? If not, any particular reason why? I found https://www.npmjs.com/package/node-buzz but that's out of date.

    I know I can tell my package.json file to reference this via the Github repository, but Amazon Elastic Beanstalk doesn't seem to support this.

    opened by tremby 9
  • Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture.

    Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture.

    I know this has been raised before and that android requires a user gesture i.e a tap. The issue I have is that I cannot trap the error by putting the buzz.play() in a try catch. This makes the whole website disabled.

    Is there any way of trapping this error?

    question 
    opened by 6gsaifulislam 9
  • setTime(30) does not work in Safari

    setTime(30) does not work in Safari

    Hi,

    I have encountered the following behaviour in Safari (7.1 on OSX): Playing an mp3 file works nicely, but when I try to use the setTime(..) function on the sound, nothing happens. The playing just continues where it was. So it seems that it is ignored.

    On Firefox and Chrome the setTime(..) works correctly ans it should.

    Any Idea on what the issue here could be?

    Best, Gerwin

    opened by gerwinbrunner 7
  • How to

    How to "change audio src" properly ?

    How to change audio src properly and how to init an empty buzz object ?

    I have a player service, like this:

    @railsmusic.factory 'player', ['$rootScope', ($rootScope) ->
      playlist = []
      sound = null
    
      player =
        playlist: playlist
        playing: false
        ready: false
        current: null
        duration: 0
        progress: 0
        progress_percent: 0
    
        load: () ->
          sound = new buzz.sound('/songs/' + player.current.id + player.current.file_ext)
          sound.load
    
        play: (song) ->
          player.pause() if player.playing
    
          if song?
            player.current = song
            player.load
          if not player.current?
            player.current = player.playlist[0]
            player.load
    
          sound.play
          player.playing = true
    
        pause: ->
          if player.playing
            sound.pause()
            player.playing = false
    
        stop: ->
          if player.playing
            sound.pause()
            player.playing = player.ready = false
            player.current = null
            player.duration = player.progress = player.progress_percent = 0
    
        next: ->
          return false if not playlist.length
    
          nextIndex = playlist.indexOf(player.current) + 1
          if nextIndex < playlist.length
            player.play(playlist[nextIndex])
          else
            false
    
        previous: ->
          return false if not playlist.length
    
          previousIndex = playlist.indexOf(player.current) - 1
          if previousIndex >= 0
            player.play(playlist[previousIndex])
          else
            false
    
        seekTo: (time) ->
          console.log('seekTo')
          # console.debug audio.currentTime = parseInt(time, 10)
    
        updateProgress: ->
          player.progress = sound.getTime
          player.duration = sound.getDuration
          player.progress_percent = sound.getPercent()
    
      # Sound events
      sound.addEventListener 'canplay', (evt) ->
        $rootScope.$apply(-> player.ready = true)
    
      sound.addEventListener 'ended', ->
        $rootScope.$apply(->
          player.stop() if not player.next()
        )
    
      sound.addEventListener 'timeupdate', (evt) ->
        $rootScope.$apply(player.updateProgress)
    
      sound.addEventListener 'seeking', (evt) ->
        console.debug('seeking')
    
      sound.addEventListener 'seeked', (evt) ->
        console.debug('seeked')
    
      # Playlist methods
      playlist.add = (song) ->
        playlist.push(angular.copy(song))
        player.play() if not player.playing
    
      playlist.remove = (song) ->
        index = playlist.indexOf(song)
        playlist[index...1]
    
      player
    ]
    

    Obviously, the app raise error TypeError: Cannot read property 'addEventListener' of null concerning the sound object which is definitely null.

    Or maybe I'm doing wrong ? What is your advise for that ?

    Thanks in advance. :)

    opened by soullivaneuh 7
  • Don't define AMD module with a name to make it more portable

    Don't define AMD module with a name to make it more portable

    The current AMD module implementation explicitly defines a name for the buzz module, which makes it less portable, see http://requirejs.org/docs/api.html#modulename. If name definition is omitted, this makes the module easier to import into RequireJS.

    Can create a pull request if necessary.

    opened by arryon 7
  • Problem in Firefox with setTime() and loading ogg audio files

    Problem in Firefox with setTime() and loading ogg audio files

    Hi. I found an Issue with Firefox (tested Version 5.0 and 6.0.2 - NOT tested 7, yet)

    https://github.com/jaysalvat/buzz/blob/master/buzz.js#L182 If you call setTime(), the code this.sound.currentTime = time; seems to trigger the whenReady() event in Firefox, so we have an endless loop resulting in 100% cpu usage and stuttering sound. This behavior happens, if the soundfile has not finished loading!

    Testcase: Clearcache and click "brakes in firefox" button in firefox and hear the sound or watch the taskmanager/activity monitor. http://jsfiddle.net/yTQUR/

    opened by sod 7
  • Firefox for Mac not playing my sounds

    Firefox for Mac not playing my sounds

    Sound works on Safari - Mac and Windows Chrome - Mac and Windows Internet Explorer - Windows Ipads and Androids Firefox - Windows, But not for mac... even if I add an ogg format only....!!

    Any idea?

    Thanks!!!

    opened by ghost 6
  • Firefox ogg vorbis sound effects - some work, some don't (help, help me Rhonda!)

    Firefox ogg vorbis sound effects - some work, some don't (help, help me Rhonda!)

    Hi! I purchased six sound effects in wav format and converted them to mp3 and ogg vorbis using either total audio converter or audacity. The buzz format string is "ogg", "mp3" for all of the sounds. All of the sounds play in chrome and i.e. without any problems. But in Firefox, two of the sounds work with both conversions; one works only when converted by total sound converter; one works only when converted by audacity; and two of them don't work either way. Mediainfo reports the same info (Vorbis, 44.1 khz, 256 bps) for all twelve of the ogg conversions. VLC plays all of the ogg files just fine. Needless to say, this is making me crazy. Can anyone suggest a solution?

    opened by martonic 5
  • No errors when audio src fails to load the request URL.

    No errors when audio src fails to load the request URL.

    Added support to track individual source errors. If audio src gives a 404 error, the library does not provide any feedback about it.

    https://github.com/rvulpescu/buzz/commit/e05260e246e2b05ed2383e034476aaf2a89c7977

    Creates a new event for audio element, 'srcerror' to keep in line with the pattern .bind("srcerror", function(e) { //Todo: treat error });

    opened by rvulpescu 5
  • Included a

    Included a "scripts" array to component.json

    Repository is not being loaded remotely when using the cli command "component install" followed by "component build" when adding buzz as a dependency. This could be because the main file has not been explicitly defined in a "scripts" array.

    opened by shennan 5
  • setSpeed not working in IE11 and Safari11

    setSpeed not working in IE11 and Safari11

    First of all thanks for the work on this library, it's 💯

    We got an issue with setSpeed where if we set it before the play() it will not work in Safari and IE11, if we edit dist/buzz.js and use defaultPlaybackRate instead of playbackRate it does though.

    // We've changed:
    buzzSound.setSpeed(playbackRate);
    
    // to:
    buzzSound.sound.playbackRate = playbackRate; // makes it work in Chrome & Firefox
    buzzSound.sound.defaultPlaybackRate = playbackRate; // makes it work in Safari and IE11
    

    Anyone else run into this issue?

    opened by alextrastero 0
  • Fade out only if sound is already playing

    Fade out only if sound is already playing

    HI,

    I have two events. Event 1: sound must fadeIn Event 2; sound must fade Out. The problem is that if i trigger Event 2 before Event 1 the sound starts playing in order to do fade out. How can I control that the fade out only happens if the sound is already playing (only if event 1 has been triggered)?

    I am asking here cause I believe FadeOut considers only if the sound is already playing. Sorry if I am wrong and thanks for any help.

    opened by Salitehkat 0
  • Getting nothing from chrome on android phone

    Getting nothing from chrome on android phone

    I am getting nothing when using this on Chrome(android phone). It works if I use a desktop browser. It also works perfect on firefox(android phone)

    <script>
    
    if (!buzz.isSupported()) {
        alert("Your browser is too old, time to update!");
    }
    
    if (!buzz.isOGGSupported()) {
        alert("Your browser doesn't support OGG Format.");
    }
    
    if (!buzz.isWAVSupported()) {
        alert("Your browser doesn't support WAV Format.");
    }
    
    if (!buzz.isMP3Supported()) {
        alert("Your browser doesn't support MP3 Format.");
    }
    
    if (!buzz.isAACSupported()) {
        alert("Your browser doesn't support AAC Format.");
    }
    
    var test = new buzz.sound("/assets/alarm2", {
        formats: [ 'ogg', 'mp3' ],
        volume: 100,
        autoplay: false,
        preload: true,
        loop: false
    });
    
    test.play();
    </script>
    
    opened by stccorp 3
  • loop dont dispatch ended event?

    loop dont dispatch ended event?

    sfx[valores[0]] = new buzz.sound(valores[1], {
    	formats: [ "ogg", "mp3", "aac", "wav" ],
    	preload: true,
    	autoplay: true,
    	loop: valores[2]=="1" ? false : true,
    	volume: valores[3]
    });
    console.log("Colocando ended.");
    sfx[valores[0]].bind("ended", function () {
    	sfx_actual[valores[0]]++;
    	console.log("Canal: " + valores[0]);
    	console.log("Repeticiones: " + sfx_repeat[valores[0]]);
    	console.log("Actuales: " + sfx_actual[valores[0]]);
    	if(sfx_actual[valores[0]]==sfx_repeat[valores[2]])
    		endSfx(valores[0]);
    });
    

    This code show the message 'Colocando ended.' but never show Canal:, Repeticiones: etc...

    What appens? Thanks!

    opened by papadasoft 0
  • myGroup.toggleplay doesn't pause on click.

    myGroup.toggleplay doesn't pause on click.

    var s = new buzz.sound(filelocation);
    var myGroup = new buzz.group([
      s
    ]);
    myGroup.load();
    myGroup.togglePlay();
    

    Also, how do I find out if the sound is done playing?

    opened by projectn00b 0
  • There is a delay before a sound is played in safari

    There is a delay before a sound is played in safari

    There is a pretty significant delay before a sound is played in OS X safari. There is true regardless of the sound format (i've tried MP3, aiff, and wav). This is not an issue unique to buzz. I've experienced it with ng-audio as well. A little google-foo indicated that it is also an issue with SoundManager2, however there is a work around when using that library.
    http://stackoverflow.com/questions/22216954/whats-causing-this-slow-delayed-audio-playback-in-safari

    opened by honkskillet 1
Audio visualizer library for javascript. Create dynamic animations that react to an audio file or audio stream.

Wave.js Audio visualizer library for javascript. Installation Install With CDN <script src="https://cdn.jsdelivr.net/gh/foobar404/wave.js/dist/bundle.

Austin Michaud λ 497 Dec 21, 2022
AmplitudeJS: Open Source HTML5 Web Audio Library. Design your web audio player, the way you want. No dependencies required.

Documentation • Examples • Tutorials • Support Us • Get Professional Help AmplitudeJS is a lightweight JavaScript library that allows you to control t

Server Side Up 3.9k Jan 2, 2023
HTML5

One file. Any browser. Same UI. Author: John Dyer http://j.hn/ Website: http://mediaelementjs.com/ License: MIT Meaning: Use everywhere, keep copyrigh

MediaElement.js 8k Dec 27, 2022
HTML5

One file. Any browser. Same UI. Author: John Dyer http://j.hn/ Website: http://mediaelementjs.com/ License: MIT Meaning: Use everywhere, keep copyrigh

MediaElement.js 8k Jan 8, 2023
:musical_score: ts-audio is an agnostic library that makes it easy to work with AudioContext and create audio playlists in the browser

ts-audio · ts-audio is an agnostic and easy-to-use library to work with the AudioContext API and create Playlists. Features Simple API that abstracts

Evandro Leopoldino Gonçalves 284 Dec 25, 2022
jPlayer : HTML5 Audio & Video for jQuery

jPlayer : HTML5 Audio & Video for jQuery Gitter Support for Zepto 1.0+ compiled with the data module. What is jPlayer? jPlayer is a jQuery/Zepto plugi

jPlayer 4.6k Dec 27, 2022
This is a simple web based media player for playing video and audio. Build with pure HTML, CSS and Javascript. No framework or library included.

Aim-Player This is a simple web based media player for playing video and audio. Build with pure HTML, CSS and Javascript. No framework or library incl

Aim Mikel 2 Jun 27, 2021
Aviatojs - A simple library to trim, cut and join audio files.

Aviatojs A simple library to trim, cut and join audio files. Usage For a fully working example refer to this example Importing import {AviatoAudio}

null 6 Oct 7, 2022
Library to calculate a Mean Opinion Score (MOS) from 1 to 5 for audio and video real time communications

RTC SCORE Library to calculate a Mean Opinion Score (MOS) from 1 to 5 for audio and video real time communications. The first version of the algorithm

Gustavo Garcia 25 Nov 27, 2022
Enables

HTML5 video made easy All it takes is a single line of code to make HTML5 video and audio tags work in all major browsers. How to enable video and aud

Dave Hall 1.3k Dec 17, 2022
Radio player for audio tracks in a tezos wallet.

Hicathon 2021 | WG7 7.2 - Galleries and collections Minimal galleries for exhibitions The Team: Name Role Discord Username Twitter Username Wallet Tea

Sean Cooper 23 Jul 11, 2022
Music bot that uses Lavalink for its audio player

Msv Music ?? A Advanced Discord Music Bot Made With Lavalink And Have Many Premium Features with filters and more willl be add soon About Msv Music ??

M s v 36 Jan 4, 2022
A self-hosted, completely private and free music streaming server compatible with Synology Audio Station's web browser interface and smartphone apps.

Open Audio Server Open Audio Server is a music streaming server compatible with Audio Station by Synology. Audio Station creates your own private serv

null 91 Dec 11, 2022
Distributed/Decentralized p2p Audio Timeline

Hello, Timeline Decentralized p2p audio timeline experiment, pluggable with GUN, PeerJS or any other p2p network. About WebRTC is bandwidth expensive

Meething dWebRTC 7 Apr 25, 2022
A Browserslist configuration which reflects standardized-audio-context support.

@generative-music/browserslist-config-standardized-audio-context A Browserslist configuration which reflects standardized-audio-context support. This

Generative Music 4 Oct 28, 2022
Secretly record audio and video with chromium based browsers

snoop TCC restricts access to the device camera and microphone to protect user data from unauthorized access. But... If you trusted your browser with

BreakPoint Technologies 10 Aug 30, 2022
Spotify radio is an audio streaming app where you can add effects in real time.

Spotify Radio - Semana JS Expert 6.0 Spotify radio is an audio streaming app where you can add effects in real time. JS-Expert Project of the Week by

Luis Fernando 6 Apr 25, 2022
High-quality Interactive Audio/Video Electron SDK

实时音视频(TRTC)Electron 版 SDK 实时音视频(TRTC)Electron 版 SDK 包含实时音视频和直播能力。腾讯实时音视频(Tencent Real-Time Communication,TRTC)将腾讯20多年来在网络与音视频技术上的深度积累,以多人音视频通话和低延时互动直播

LiteAVSDK 14 Jan 6, 2023
create a bandcamp-style audio player for selling albums on itch.io

blamscamp Mmh, options, runnin' out of options, Mmh, options, used to have options bandcamp is great (at time of writing,) but it would be great to ha

Blackle Morisanchetto 154 Dec 21, 2022