GLMediaPlayer not playing short MP3 files

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

GLMediaPlayer not playing short MP3 files

asambol
I'm using GLMediaPlayer for playing MP3 files and it works fine for "normal" files, i.e. songs.

However, playing very short files (< 1 sec duration) doesn't work. Here is the MP3 file: http://tinyurl.com/obzre8x

Opening file in audacity and saving again with usual MP3 LAME settings doesn't help.
Converting to WAV doesn't help either.
Converting to WAV and extending it to 5 sec duration works good in GLMediaPlayer.
Extending the original MP3 to 5 sec duration doesn't work in GLMediaPlayer.
Extending the original MP3 to 15 sec duration works good in GLMediaPlayer.

No exception is thrown on playback start. I tried with -Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native and I get the following output on playback start:
Regular MP3 file (works fine): http://pastebin.com/pVuaFsTw
Short MP3 file: http://pastebin.com/KnrBtzkx

So the only difference I see is that for short files the Stream doesn't even start - after playing, GLMediaPlayer switches to Paused state right away.

I can't post a self contained code example but I'm basically using MovieSimple code (with only audio stream, of course).

For now, I will convert all short files to 5sec WAV files, but would like to know if there is a simple solution I'm overlooking.
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

gouessej
Administrator
Hi

I use Paul Lamb Sound Library with its JOAL plugin, it works with very short sounds, I have used it for several years in my first person shooter. I use OGG files.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

asambol
I don't like the idea of introducing new dependencies to my project (since I'm already using ffmpeg for video playback), and Paul Lamb Sound Library requires 3 additional jar files (core, JOAL plugin and JOgg plugin).

Nevertheless, I tried it but couldn't load any sounds - according to documentation sounds need to be inside a JAR file or online/http. I couldn't load anything from filesystem, even after SoundSystemConfig.setSoundFilesPackage().

For now, I would like to continue using FFMPEGMediaPlayer for playing both video and MP3 files but it seems kinda buggy:
1. Short sounds don't work at all. For now I quickfixed by adding 10 sec silence to the end of the file.
2. Long sounds aren't played to the end - EOS is reported ~10 seconds before a 4 minute song finishes - I guess it finishes playing when it finishes buffering? Could be related to bug #1.
3. Video playback doesn't report EOS event at all. I am registered as a GLMediaEventListener to the player and get other events (play, pause) normally, and I get EOS for MP3 files, but not for videos.
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

gouessej
Administrator
I succeed in reading sounds from files not in JAR files. I call SoundSystem.loadSound(URL), I obtain the URL by calling Class.getResource(String). You can call java.io.File.toURI().toURL(). It reminds me that I have forgotten to remove LibraryJavaSound.jar from my project as I only use CodecJOrbis.jar, LibraryJOAL.jar and SoundSystem.jar + JOAL itself.

You need this to initialize this library:
soundSystem=new SoundSystem(LibraryJOAL.class);
SoundSystemConfig.setCodec("ogg",CodecJOrbis.class);

Paul Lamb Sound Library is used in Minecraft, it's rock solid. I suggest its use in your case because in my humble opinion, it's weird to use video playback just to play a MP3 sound.

If you prefer using FFMPEGMediaPlayer, I can do nothing for you and maybe there are some bugs :s
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

asambol
I finally got Paul Lamb Sound Library to work, thank you for your help.

For future reference, what I did wrong:
1. Not realizing there are methods which take URL instead of String paths.
2. Initializing SoundSystem in class constructor thread and then calling play() from EDT/rendering thread - froze my rendering, fixed by moving SoundSystem initialization to GLEventListener's init().
3. Using JOgg codec instead of JOrbis - only JOrbis worked for very short OGG files.

This still doesn't fix FFMPEGMediaPlayer issues, especially bug #3 which is not related to audio anyway (not reporting video EOS).
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

gouessej
Administrator
You're welcome. As JavaSound doesn't work very well with OpenJDK and as OpenAL-Soft is a better fallback, I advise the users of this library NOT to use its plugin based on JavaSound. Thank you for the feedback about the JOgg codec. I don't know whether this limitation comes from JOgg itself or from the "codec".

My suggestion is viable for audio. Yes of course, it doesn't fix the bugs in the FFMPEG media player.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

asambol
gouessej wrote
My suggestion is viable for audio. Yes of course, it doesn't fix the bugs in the FFMPEG media player.
Actually, I just realised I won't be able to use SoundSystem in my project, except for short OGG effects. Most of the files are actual songs in MP3 format (loaded dynamically, so no converting possible), and SoundSystem doesn't support MP3. :/ I guess I'm stuck with FFMPEGMediaPlayer.
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

gouessej
Administrator
You can implement a codec for Paul Lamb Sound Library to support MP3 by using JLayer:
http://www.javazoom.net/javalayer/javalayer.html

However, it's not a trivial task.

Edit.: It's possible to use the JLayer MP3 SPI to get the raw data (byte[]) and pass it to SoundSystem.loadSound().
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

asambol
I have created a bug report regarding GLMediaPlayer not reporting EOS on video, also mentioned EOS reporting ~10 seconds before end for MP3 files: https://jogamp.org/bugzilla/show_bug.cgi?id=1173
Reply | Threaded
Open this post in threaded view
|

Re: GLMediaPlayer not playing short MP3 files

kdropucic
In reply to this post by gouessej
I have created a bug report regarding GLMediaPlayer MP3 playback issues (duration and EOS): https://jogamp.org/bugzilla/show_bug.cgi?id=1216