Warning: skipping unsupported OGG file

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. :slight_smile:

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?

Right, I should clarify. It’s best to stick with MP3s for the Flash target. Other targets don’t support it, so use Ogg elsewhere.

Derp…

That makes it really hard to achieve “write once, work everywhere” unless you explicitly choose to support:

  • Only Flash, or
  • Only non-Flash (eg. Mobile)

Anyway, we can discuss this in another thread. I’m okay with this distinction right now (for my projects) – I use Flash for testing/previewing.

Not that hard, really. Just use conditionals.

include.xml:

<assets path="assets/sound" rename="sound" include="*.mp3" if="flash" />
<assets path="assets/sound" rename="sound" include="*.ogg" unless="flash" />

Haxe code:

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);
}
1 Like

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

@singmajesty Are you talking about dynamic encoding at runtime?

If all the other platforms support MP3, maybe that’s an option for anyone who wants Flash with other targets.

Not without paying a hefty license fee.

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 :slight_smile:

Is anyone working on this? @singmajesty ?

Unfortunately I can’t work on this, not sure if others are interested?

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.

1 Like

I saw several people using fogg (https://github.com/TooTallNate/SoundJS/tree/master/src/haxe/org/xiph https://github.com/fbricker/muses/tree/master/org/xiph https://github.com/TuduraoJin/EnneaSound/tree/master/src/org/xiph) but sadly it looks LGPL which is GPL when using flash since you can’t just link it.

But xiph also has a c++ BSD version of libogg, so I’ll look into crossbridge to see if I can make a swc with it.

@ibilon were you able to progress on this?

There was a post on the Haxe (core) mailing list by the author of this repo:

released public domain ogg vorbis decoder writen in Haxe. It is ported from stb_vorbis, and now available in Flash, C#, Java and Neko targets.

You can check demo here : http://ogg.spheresofa.net/en/

This may be of some use to you, or anyone looking into this issue.

2 Likes

I started looking at c++ code but developed nothing yet,

this library looks exactly like what we need, I’ll test it tonight!