_ElementoZerO_ Posted June 16, 2016 Share Posted June 16, 2016 Hello to all! I'm trying to add some sound to my little game using : var ambientWind = new BABYLON.Sound("ambientWind", "./assets/audio/wind01.mp3", this.GameKernel.scene, null, { loop: true, autoplay: false }); i'm get this error: Uncaught (in promise) TypeError: Failed to execute 'decodeAudioData' on 'AudioContext': parameter 1 is not of type 'ArrayBuffer' I already tried to fallow this : link No errors but still not audio... Then i'm tried with jQuery .ready().. nothing... I'm using BabylonJs latest preview version Any suggestions? Quote Link to comment Share on other sites More sharing options...
_ElementoZerO_ Posted June 17, 2016 Author Share Posted June 17, 2016 no advice guys? Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted June 17, 2016 Share Posted June 17, 2016 Have you tried with wav format ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 17, 2016 Share Posted June 17, 2016 @davrous should be able to help you soon Quote Link to comment Share on other sites More sharing options...
_ElementoZerO_ Posted June 17, 2016 Author Share Posted June 17, 2016 Ok thank you ^^ Quote Link to comment Share on other sites More sharing options...
_ElementoZerO_ Posted June 18, 2016 Author Share Posted June 18, 2016 On 17/6/2016 at 5:03 PM, V!nc3r said: Have you tried with wav format ? Dho today i tried with wav and it seems work.. why mp3 not work??? Quote Link to comment Share on other sites More sharing options...
davrous Posted June 19, 2016 Share Posted June 19, 2016 Hello, Can you please create a playground sample that repro this error? Or send the mp3 file? Which browser are you using? How did you encode the mp3? Can you play it if you're drag'n'dropping it in Chrome? Bye, David Quote Link to comment Share on other sites More sharing options...
_ElementoZerO_ Posted June 19, 2016 Author Share Posted June 19, 2016 Hello, the code is very big and split in various js if you want i can send you in private, i'm using bracket with chrome browser, but is very strange because after using .wav now also .mp3 (the same) seems work..unbelievable.. I tried to drag and drop the .mp3 file in chrome and work. I think at this point that is the preview function of bracket, unfortunately before the issue i don't try with xamp.. Quote Link to comment Share on other sites More sharing options...
dbawel Posted June 19, 2016 Share Posted June 19, 2016 @_ElementoZerO_ - Are you certain that the MP3 file actually does work now, as I often find that when elemets suddenly appear to work when they did not previously, it is often an illusion. Just make certain that the MP3 file is actually working and not simply playing the WAV file in your browser cache - as reloading your scene doesn't clean cache (depending on your broeser and settings), and you very well might be drawing the conclusion that your MP3 file is playing when it is actually playing the same name WAV file from memory since most browsers are set up to function by file name first, and file format secondly. DB Quote Link to comment Share on other sites More sharing options...
_ElementoZerO_ Posted June 20, 2016 Author Share Posted June 20, 2016 On 19/6/2016 at 8:29 PM, dbawel said: @_ElementoZerO_ - Are you certain that the MP3 file actually does work now, as I often find that when elemets suddenly appear to work when they did not previously, it is often an illusion. Just make certain that the MP3 file is actually working and not simply playing the WAV file in your browser cache - as reloading your scene doesn't clean cache (depending on your broeser and settings), and you very well might be drawing the conclusion that your MP3 file is playing when it is actually playing the same name WAV file from memory since most browsers are set up to function by file name first, and file format secondly. DB ok today i work on my notebook with linux and again the same problem so maybe is the os? because i use linux mint on notebook and windows 10 on Desktop at home, now will try with windows 10 and . (now that i think is probably the china usb card..because my onboard card is broken..) EDIT: ok under windows all work correctly despite the china usb audio card..so at this point i think is a problem bounded to alsamixer when i get home will try with opensuse on desktop and will update. EDIT2: ok on opensuse work too, so at this point is my notebook linux that have same problem. Thank you to all for the help ^^ webGLmmk 1 Quote Link to comment Share on other sites More sharing options...
webGLmmk Posted July 27, 2016 Share Posted July 27, 2016 On 6/20/2016 at 1:10 AM, _ElementoZerO_ said: ok today i work on my notebook with linux and again the same problem so maybe is the os? because i use linux mint on notebook and windows 10 on Desktop at home, now will try with windows 10 and . (now that i think is probably the china usb card..because my onboard card is broken..) EDIT: ok under windows all work correctly despite the china usb audio card..so at this point i think is a problem bounded to alsamixer when i get home will try with opensuse on desktop and will update. EDIT2: ok on opensuse work too, so at this point is my notebook linux that have same problem. Thank you to all for the help ^^ I'm working with a visualization and can't get either mp3 or wav to work on Mint. The same page plays on Ubuntu, strangely enough. And Chromebook. I notice it won't work on Android Chrome either. *EDIT* It may be this: http://stackoverflow.com/questions/12587977/html5-audio-chrome-on-android-doesnt-automatically-play-song-vs-chrome-on-pc-d https://bugs.chromium.org/p/chromium/issues/detail?id=138132 So, Android Chrome does not allow autoplay in HTML5 audio. All the results I'm getting are around 2012, 2013, but Im pretty sure it applies, and there are no "hey guess what you can do now". Not sure what the reasoning is here. Pretty lame for HTML5 game dev. Going to put a control button in and see if it plays then. **EDIT** @_ElementoZerO_ Try opening update manager, running all your updates, then restart. I got it to work on Mint/Chromium at least Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 27, 2016 Share Posted July 27, 2016 When either mp3 or wav to work, maybe images:http://www.babylonjs-playground.com/#I2NLB#0 Good Luck Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 27, 2016 Share Posted July 27, 2016 No PG is hard to see what's wrong. I look at your line of code, you use autoplay: false. Do you use play() after. var ambientWind = new BABYLON.Sound("ambientWind", "./assets/audio/wind01.mp3", this.GameKernel.scene, null, { loop: true, autoplay: false }); ambientWind.play(); Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 27, 2016 Share Posted July 27, 2016 Just to clarify myself, maybe my example above to lead missunderstanding on linux and older android devices you always have to load from XMLHttpRequest for any reasonhttps://doc.babylonjs.com/overviews/Playing_sounds_and_music This should workhttp://babylonjs-playground.com/#1IJM2V#0 Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted July 28, 2016 Share Posted July 28, 2016 Babylon.sound seems to dislike the way i update my players positions (multiplayer), so personally i'm using html5 audio player instead, example; Html. <audio id="ambientBackground01" src="assets/sounds/ambientBackground01.mp3" loop></audio> Javascript. window.onload = function() { //fix for autoplay document.getElementById('ambientBackground01').play(); /* variable example.. var au = document.getElementById('ambientBackground01'); au.play(); au.pause(); au.volume += 0.1; */ }; quick n easy, but ofc it doesn't have the same features as you can get with babylon sound Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 28, 2016 Share Posted July 28, 2016 @Nabroski has provided the essential step to playing HTML media on any OS, device, browsr, etc. If you have any questions about specific behaviors for an OS, device, or browser, I have tested most all thoroughly for HTML media. but s mentioned, the key step is to load the media before playing. Also, as several users have mentioned, autoplay() is enabled on some OS and not on others. And you will not be able to use the autoplay option to make the media autoplay, and play(), pause(), and other HTML media functions won't work as you might expect within WebGL. The only way to use video and audio media in WebGL, is to first understand that you must use HTML nodes, and then must first load the media into memory (not simply assigning a variable), and then either the OS will initialize autoplay, or not - depending on the OS. And if autoplay is not initialized natively such as on Android and/or Ipad, then the user must trigger a play() function through an event or other method so that the video/audio begins to play; as even though the media has been loaded, it will not buffer without the user initializing play manually. The only other essential info the developer must know is that once the media is loaded and either the browser or user initializes play (depending on the OS), the method to access any HTML media attributes and properties is to call these using the DOM functions/events. Otherwise, you might be able to find a few methods which will appear to trigger some of the media functions in WebGL - as there are a few methods which do work in WebGL - depending on many factors such as the architecture of your scene and the loading and handling of scene assets (media). However, you will spend countless hours discovering and testing, only to find such methods do not work consitantly in every OS, device, browser, etc., as this is a common waste of time which even developers highly experienced in WebGL often find themselves. So until there are new and reliable APIs specifically developed to handle media such as Web Audio API, and/or other methods or standards widely adopted to handle media in WebGL; the only way to create scenes which make use of external media - mainly audio and video - to work on most any device and OS, is to rely on HTML DOM nodes. So you must first load your media into memory (it is essential to embed the media into an HTML document), then buffer the media in the browser (also essential, as loading does not buffer) by using either autoplay when this is natively enabled in the OS, or by providing the user with a control to initialize play() on any OS which doesn't enable autoplay natively; and then call each DOM attribute/property for control or coordination of your media. Otherwise, you'll find the problems with media control and manipulation in WebGL to be a deep hole of anxiety which might sometimes appear to work, but has a zero chance of working across multiple OS, devices, and browsers - or with any reliability at all if you do find a method which "appears" to work on one or more of your devices. I hope that no other developers waste the countless hours which I and many others have spent trying to solve the conflicts we've discovered in using media in WebGL, and expecting a rational and reasonable result; since most of the functionality you might expect from your experience in using HTML media, as well as other media such as the use of images as textures in WebGL - simply does not function as you might have expected. And the only reliable process (and I mean "the only" one) to gain full control over your media in any OS using WebGL is to use HTML media and the massive number of events which are standard in every browser. It takes a small amount of testing to fully understand how media performs in WebGL as well as on each OS, device, etc., but is the only way to assure compatability and functionality for most all platforms and devices. I've spent more time working on developing "useless" methods to maniulate media in WebGL than any other aspect of WebGL development, and hope that this info is carried through the forum - especially to any newbies, as I have probably tried to answer more posts about issues with media in WebGL than any other problem - and the answer is almost always due to how WebGL handles (or doesn't handle) media uniquely for each OS, browser, and often a specific device. Cheers, DB Nabroski, GameMonetize and V!nc3r 3 Quote Link to comment Share on other sites More sharing options...
dqope21 Posted March 20, 2017 Share Posted March 20, 2017 Sorry to dig up an old issue but I have a problem getting a .wav or .mp3 to play upon scene load. I put the file in the same folder as my JS file and call var music = new BABYLON.Sound("Test", "test.wav", scene, function(){ console.log('music called!') }, { loop: true, autoplay: true }); music.play(); However, I get the errors: Error while decoding audio data for: Test / Error: EncodingError: Unable to decode audio data Uncaught (in promise) DOMException: Unable to decode audio data Any help would be appreciated! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 20, 2017 Share Posted March 20, 2017 Are you sure that your browser supports wav? otherwise try mp3 Also check that the file or test.wav test.mp3 has the ebon way to indicate from running your html file. var music = new BABYLON.Sound("Test", "root/test.wav", scene, function(){ console.log('music called!') }, { loop: true, autoplay: true }); This is not necessary for you to use autoplay: true the options : music.play(); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.