Find out whether sound is playing?

Started by Schnitter, December 01, 2007, 15:09:44

Previous topic - Next topic

Schnitter

I wrote 2 classes: SoundLoader and Sound.
SoundLoader:
http://nopaste.info/cd09c4ee25.html
Sound:
http://nopaste.info/40f958733a.html

Now, I want to find out, whether the sound is playing. Of course I could just create a boolean "isPlaying" variable(Peoblem: When to set it to false?), but I wonder, that there isn't a OpenAL provided method?
And another question: How can I calculate the size of my sound-file in seconds(or milliseconds)?

That's all for now.

Edit: Another question: I cannot play sound-files, which are in C:\ for example :(
And what's about playing *.mp3-files with OpenAL?


MfG

bobjob

alot of good questions i dont know how to answer :D

as for playing mp3's there is an easyer format to use called ".ogg" you can download free software called audacity and convert mp3's into ogg's with similar compression sizes. you will also need to download the java packages jogg and jorbis in order to read the file format, there is an example of a ogg music player (with source code) that is independant of lwjgl, it is good enough for background music, when streaming ogg in openAL it gets a bit more tricky.

Schnitter

Yes, but the problem is, that my MP3-Player doesn't support ogg :(
(But it isn't that important - I planned to buy a new one in 2008)

Ehm...where can I download Jogg? I found the jorbis download page and downloaded it - but nothind with jogg.
There's a francais site, but I don't think it's the right one?


EDIT: lol^^ Ok, it's in the same package ;)
About 1200 lines of code just for that simple player? :(
Mindblowing code^^

bobjob

lol, yeah the code is very robust, it can play over the net. you can strip heeps of it, to get down to the bare minimum. i got it down to 450 lines, that was only removing the net code. also i added some code for myself, like set playlist, stop, pause, next and previous. Oh i also removed the swing componoents. so its just a music player i can use in the background of other programs

Schnitter

Do you know another tutorial using jogl or do I have to use this code?

bobjob

just to play jorbis i dont know of any tutorials only that sample code. im not sure how you want to use your music player, but it shouldnt be to hard to strip the non essential code. if your planning to use it along with lwjgl, it should work fine as the player works in its own thread.

if your feeling keen, here is a different approach you can take.
after completing the lwjgl audio tutorials
http://www.lwjgl.org/documentation_openal_01.php
try check this one out, here is a tutorial in order to get oggVorbis working with openAL (in c++)
http://www.devmaster.net/articles/openal-tutorials/lesson8.php

but i still think using jorbis indepandant of openAl is a easyer option.