I use OGG for sounds, which I play with FlxSound (HaxeFlixel). When I compile to the flash target, I see:
Warning: skipping unsupported OGG file
(Of course, the audio doesn’t play.)
Why isn’t OGG supported for the flash target?
When I google for Flash (non-HaXe) solutions to play OGGs in Flash, I get links like this (which, ironically, mentions simple Flash Ogg Vorbis player using HaXe Ogg Vorbis library), which makes it seem like this is technically feasible.
Flash Player does not support Ogg files. It is possible to write to a byte array to specify sound output, so if you parsed the Ogg yourself - as FOggPlayer presumably does - you could still play it.
However, I’m not confident that this will give good performance. FOggPlayer is labeled “experimental,” which suggest that it hasn’t been optimized. It’s probably best to stick with MP3s.
I’m hesitant to use MP3s. My first Android phone couldn’t play MP3s, period (not sure if it was defective or not). Ogg provides better quality (or better file size) compared to MP3. Although in this case, I don’t see that I have much choice.
IMO, this would be a great “added value” feature ofOpenFL.
Can I suggest rewording the warning slightly for those of us who are unaware (like me) that Flash simply doesn’t support OGG playback?
public static inline var SOUND_EXT:String = #if flash ".mp3" #else ".ogg" #end ;
public function new() {
var sound:Sound = Assets.getSound("sound/FileName" + SOUND_EXT);
}
We could offer an OGG to MP3 encoder, for sake of the Flash target, but we would have to charge a couple dollars to do so, due to licensing. If there’s a demand, let me know and I could consider it.
Otherwise, WAV is supported everywhere, though that isn’t ideal for file size. Without OGG support in Flash Player, there isn’t a lot we can do
The license fee for using an encoder much lower, a dollar or two. Compared to the $2500-$3000 cost of using it at runtime in a title, I think it’s probably the only reasonable solution. I don’t want to encourage people to violate the license by using it unpaid at runtime, that’s why support was removed
It would be awesome if we could use OGG in Flash because it’s much smaller in file size than MP3, for files I tested it was between 40-50%. Small file size is really important when looking for Flash game sponsors.
@kurismakku +1, and we could just make ogg files for an openfl project, though the problem is we need a ogg decoder for flash (they exist) but obviously they are slower than the flash mp3 player.
@ibilon we discussed an ogg decoder for Flash @singmajesty believes that it may not work across all Flash clients, and is probably not going to be “production strength” code.
This also simplifies asset generation, because you don’t have to generate MP3s just for Flash.
If the Sound class is not marked as final, I would start by looking at trying to get an OGG player working as a subclass of Sound. This would make it possible to create a custom Sound instance that is OGG specific, and when calling Assets.getSound it could return this in the case of OGG assets instead of the normal Flash Sound class, effectively making it transparent
I am,
I’ll look at flash ogg player with compatible license and then making a subclass of Sound.
I’ll be able to start on this Thursday, hopefully it could be done by the end of the week if I just have to put components together.