no audio, problem with ogg/mp3?

135 views
Skip to first unread message

Wdvretuow

unread,
May 15, 2013, 6:43:17 AM5/15/13
to mel...@googlegroups.com
Hi there,

Over the past days I've been working with the melonJS tutorial to create a simple 2d game. I'm really happy with it but now I've stumbled onto a problem I can't solve. I've done everything told in step 7 of the tutorial, I even changed the line me.audio.init("mp3,ogg"); to me.audio.init("mp3", "ogg"); (which at least let me load the game again) but although all of the code is there, the game doesn't play any of the sounds on my macbook (Chrome, Safari, Firefox). I've had it tested on a windows pc and that didn't work either.

Does anyone know what might cause this problem? Here's some of the code I used:


example from resources.js
{name: "dst-inertexponent", type: "audio", src: "data/bgm/", channel : 1},

{name: "jump", type: "audio", src: "data/sfx/", channel: 1},
{name: "cling", type: "audio", src: "data/sfx/", channel: 2},
{name: "stomp", type: "audio", src: "data/sfx/", channel: 1}

example from entitites.js
// play some audio
me.audio.playTrack("jump");

example from play.js
// play the audio track
me.audio.playTrack("DST-InertExponent"); 

example from game.js
// add "#debug" to the URL to enable the debug Panel
if (document.location.hash === "#debug") {
window.onReady(function () {
me.plugin.register.defer(debugPanel, "debug");
});
}

// Initialize the audio.
me.audio.init(".mp3",".ogg");


I actually read somewhere it might have something to do with the window.onReady(function () code, but since I'm pretty new with java (I'm surprised I've got this far!) I don't have a clue what to do. 

I hope some genius out here can help me! Cheers.

Aaron McLeod

unread,
May 15, 2013, 8:34:34 AM5/15/13
to mel...@googlegroups.com
I have the 0.9.7 build in one of my games, and the audio works fine. It should be initialized via:

me.audio.init("mp3,ogg");

Also, your onReady function call seems odd to me. Generally that's where you call me.video.init, pass in the resources array to the loader, etc. I follow a pretty close example to the tutorial, and it's worked out well for me so far :)


--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aaron McLeod
http://agmprojects.com

woutervan...@gmail.com

unread,
May 15, 2013, 9:09:33 AM5/15/13
to mel...@googlegroups.com
I replaced it with me.audio.init("mp3,ogg"); but then the loader won't work:



I'm also using 0.9.7, so I'm not sure what's the problem :( Would it help if I'd send you the code? 

<script type="text/javascript" src="lib/melonJS-0.9.7-min.js"></script>





Op woensdag 15 mei 2013 14:34:34 UTC+2 schreef Aaron McLeod het volgende:

Aaron McLeod

unread,
May 15, 2013, 9:11:49 AM5/15/13
to mel...@googlegroups.com
Can either host the code on a web site somewhere, or put it in a zip. Is there a console error? About 95% of the time the app doesnt load, it's cause an error occurred with loading a resource.

woutervan...@gmail.com

unread,
May 15, 2013, 9:13:54 AM5/15/13
to mel...@googlegroups.com
Thanks, I've emailed you the link to the site I'm hosting the js. 

Op woensdag 15 mei 2013 15:11:49 UTC+2 schreef Aaron McLeod het volgende:

Aaron McLeod

unread,
May 15, 2013, 9:19:10 AM5/15/13
to Wouter van de Watering, mel...@googlegroups.com
Glad to hear! happy coding!


On Wed, May 15, 2013 at 9:18 AM, Wouter van de Watering <woutervan...@gmail.com> wrote:
Ouch, got it. It was just a typo in the file name. Thanks a lot!



2013/5/15 Aaron McLeod <sircoo...@gmail.com>
Yup, i got it. So when i loaded up the page, it had trouble loading dst-inertexponent.ogg. Double check that the file is there, and that you have the directory specified correctly.

It could be a permissions thing, but i'd imagine you wouldn't have an issue on your own machine.


On Wed, May 15, 2013 at 9:13 AM, Wouter van de Watering <woutervan...@gmail.com> wrote:
Hey Aaron,

I'm hosting the game right here: http://www.chillground.nl/bagage
That's the version with me.audio.init("mp3", "ogg"); still in it (and it works, kinda). 

Here's the link to the loader that isn't working: http://www.chillground.nl/bagage2.

Cheers,
Wouter


2013/5/15 Aaron McLeod <sircoo...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/Hc16uYa-Yqw/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to melonjs+u...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Aaron McLeod
http://agmprojects.com




--
Aaron McLeod
http://agmprojects.com

woutervan...@gmail.com

unread,
May 15, 2013, 9:20:42 AM5/15/13
to mel...@googlegroups.com, woutervan...@gmail.com
Ok, I've got it! It was just a stupid little typo in the dst-inertexponent.ogg file. Thanks!

Jay Oster

unread,
May 15, 2013, 2:20:04 PM5/15/13
to mel...@googlegroups.com
The onReady lines are from the boilerplate: https://github.com/melonjs/boilerplate/blob/master/js/game.js#L12

Aaron McLeod

unread,
May 15, 2013, 2:21:52 PM5/15/13
to mel...@googlegroups.com
Ah okay, wasn't sure. I can see that there's another one being called here: https://github.com/melonjs/boilerplate/blob/master/index.html, which calls the function loading that. So i wonder, is that window.onReady there necessary, since it's being called from within one?

Jay Oster

unread,
May 15, 2013, 2:26:32 PM5/15/13
to mel...@googlegroups.com
Probably not. It was pretty much copy-pasted from my template, which runs similar code in a completely different context: https://github.com/blipjoy/template/blob/master/public/js/config.js#L27

Aaron McLeod

unread,
May 15, 2013, 2:29:33 PM5/15/13
to mel...@googlegroups.com
ah neat. Didn't know we had a boilerplate to be honest. Might check it out for my spine stuff. 


--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages