Flash player never plays embedded sounds in my swfs(even on web)


(Red Ligot) #1

So, I’ve always had this problem with embedded sounds. Above is the link to my Flashpunk project that supposedly has sounds since the larger file size indicates it. I embedded the sound like this:

[Embed(source="../assets/Ambiahnce.mp3", mimeType = 'application/octet-stream')]
public static const MUSIC1:Class;

That is in my Assets.as file. In my Main.as file:

CURRSOUND = Assets.MUSIC1;//I set the CURRSOUND variable which is a Class
music = new Sfx(CURRSOUND);
music.loop();
music.play(1, 0);

so one thing to note too is that this had always been happening to me even before I used FlashPunk. In the past, whenever I embedded sounds, it had to be inside the .fla for it to load right. Any ideas? :frowning:


(Jacob Albano) #2

You mentioned an fla…are you using Flash Pro for this? Last I checked Flashpunk didn’t play well with that due to its outdated/incomplete Flex compiler. Using Flashdevelop might fix your problem.


(Red Ligot) #3

Sorry, I was being a little vague. What I meant to say was, back before I didn’t use FlashPunk, I had the same problem of the sound not loading.


(Jonathan Stoler) #4

Try taking out the mimeType of your embed.

When I tried on a test project, adding application/octet-stream to an mp3 embed caused an error and stopped the project from loading at all. (This was in debug mode, though.)


(Red Ligot) #5

Hmm… okay actually it turns out that I made some foolish mistake of putting the code in a function that I forgot to call. I’m sorry xD I feel silly.


(Red Ligot) #6

If you guys are still interested, http://www.newgrounds.com/dump/item/fd9dbc10715fccd06033328cd873eecb here. I fixed it lol. Thanks for suggesting though :smiley: (M to start) EDIT: If you’re curious, I actually did the music myself.


(Jacob Albano) #7

In the future, it’s good to produce what’s called “complete and minimal code” on programming forums. Trim your code down to the smallest it can be while still demonstrating the problem you have, and post that. Nine times out of ten you’ll end up finding the problem yourself, and if you don’t it makes it easier for people to help you.

Since Flashpunk has been around for a while, it’s unlikely (though not impossible) that the code you showed would be causing a problem; initializing an Sfx object and trying to play it is about as simple as you can get, and the probability that your problem lies there is pretty low.

Finally, it’s generally taken for granted that when somebody asks why a certain piece of code isn’t working, that code is actually being run. Double-check these things before looking for help.


One thing to note: calling loop() and then immediately following it up with play() is redundant and probably won’t do what you want. Calling loop() is the same as calling play() except with looping; it’s not a configuration option or something like that.


(Red Ligot) #8

Okay, thank you. I’ll make sure to double check before posting then(maybe even triple-check because sometimes I just miss it completely.)