Sound won't play MP3 on Windows

I can’t get MP3 audio to play on Windows using the Sound class. Works fine on macOS. WAV files play fine on Windows, but not MP3. I get no error, the audio just doesn’t play, and .IsPlaying immediately returns False.

Is this supposed to work? I tried it on two PCs (Windows 10 and Windows 7). I searched the Xojo forum and Feedback and didn’t find anything relevant (well, one issue back in 2015 where MP3 playing was broken, but later fixed).

Does MP3 work in the Sound class/object in Windows for anyone else?

Note that I’ve tried this in several Xojo version back to 2017r1.1 with no luck.

Check the WindowsPlayerMBS and MFPMediaPlayerMBS classes in MBS Xojo Plugins.

Far away before Real Studio, I realized that my macOS project (with sounds) does not worked on Windows, but I never had then the idea to check a different kind of music file type.

I left the project as it was.

All along the years, big project were starting to be small projects, then hopeless project. :frowning:

No Great Project to watch here, Stay Home ! :wink:

WAV is JUST a container format (much like QuickTime)

Places like stack overflow have piles of suggestions like using MCI to play the mp3
(see https://stackoverflow.com/questions/2049825/simplest-way-to-play-mp3-from-visual-c)

MS has Core Audio but its all C++ code and API’s so I’m not sure its directly callable from Xojo using declares

The Win32 PlaySound function is pretty simple - but it plays WAV files but WAV is just the container format more than anything

Is this supposed to play arbitrary sounds files ?
Or only ones built into your app ?

Yup. No problems here, Mac or Windows.

If you find only certain files will play in Windows, you may have a codec issue. If you’d like to attach the file, I can test it for you.

I also have a sample project that uses the Sound object if that’s helpful.

These are audio recordings of verbal instructions. There are dozens of them. I’m storing them in a SQLite db (along with images) for easy organization/distribution and to keep the end user from messing with them. They were originally WAV files that I converted to MP3 to save space (along with the original BMP images converted to PNG). Makes a big difference when dealing with dozens of audio and hundreds of image files.

The MP3s play fine in other Windows apps, just not Xojo’s.

Thanks. Try this one.

Thanks. Try this one.

It has an invalid tag. (The date tag)

Removing the tag makes it play properly. Here’s the repaired file.

What program are you using to create your mp3 files?

I used Permute to batch convert all the WAV files (and also the images).

What did you use to remove the date tag? Is the tag in a fixed position where I could remove it within Xojo? (since I already have them all loaded into the db)

Interesting thing is that WMP and Groove play the files just fine. Why is Xojo tripping up on it?

Many MP3 players just ignore the metadata tags. It’s hard to say why Xojo chokes on it without knowing what library it uses to play media.

Permute clearly has a bug if it’s creating badly-formatted tags. You should let them know. Especially since it’s a paid piece of software.
I don’t know if you really want to try and create a Xojo tag analyzer/repair tool, there’s plenty free ones out there. However, if you’re really keen

I just used Mp3Tag - one of the greatest (albeit windows only) shareware programs for mass tagging and editing of any tagged media. You could fix all your mp3’s in one click.

There used to be some code around that would handle ID3 tags in pure xojo code

At first I tried using MoviePlayer to play the files, which worked in Windows, but wouldn’t on Mac. Aaarg! Cross-platform my ass! This past year or so has led me to understand “cross” in cross-platform as its alternate meaning. :angry:

After reviewing some of the Tag code, I just went with Mp3Tag to strip all tags from all files and re-import them into the db. Everything now works as I had initially designed it. :sweat:

Thanks all.

1 Like