[Kde-games-devel] Correct useage of phonon?

Luciano Montanaro mikelima at cirulla.net
Sat May 10 23:24:30 CEST 2008


On sabato 10 maggio 2008, Michael Thaler wrote:
> Hello,
>
> (modified version of my post on kde-devel)
>
> I am trying to port a game to KDE. Currently the game uses SDL_Mixer to
> play sounds. I want to replace it by phonon, but I am not sure about the
> correct way to use phonon.
>
> What I want to do is play sound a (e.g. a "bling") if a player does
> something and play sound b (e.g. a "whozz") if a player does something
> else. The game has twelve different sounds that get played when a player
> does something and an mp3 that gets played when the credits are shown. Most
> of the sounds are very short, about 5 KB, some are up to 50 KB. I guess
> loading the sounds from disk and playing them with
>
> m_media->setCurrentSource(filename);
> m_media->play();
>

This is essentially how I did it in KGoldrunner. 
I don't like it either, but that's what is available for now. I don't know 
what the future will bring, but I would not hold my breath waiting...

You can see my code in kgrsoundbank.{h,cpp} 

SDL_Mixer looks like a much better fit for games.

Luciano

> would work, but I think it is quite ugly to load the files from disk each
> time they are played. My question is: is it reasonable to have thirteen
> MediaObjects that are initialized in the constructor of the class or are
> MediaObjects to heavywight to do that. If so, is there any other way to
> preload the sound files?
>






-- 
Luciano Montanaro //
                \X/ mikelima at cirulla.net


More information about the kde-games-devel mailing list