Web lists-archives.org

Re: Correct useage of phonon?




On 5/10/08, Michael Thaler <michael.thaler@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Hello,
>
>  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. As far as I understand, to play a sound, I have to do the
>  following:
>
>  namespace Phonon {
>     class MediaObject;
>  }
>
>  class AudioPlayer
>  private:
>     Phonon::MediaObject* m_media;
>   public:
>         AudioPlayer();
>  };
>
>  AudioPlayer::AudioPlayer() : m_media(0)
>  {
>         m_media = Phonon::createPlayer(Phonon::GameCategory);
>         m_media->setCurrentSource("mySound.wav");
>         m_media->play();
>  }
>
>  The game has about 15 sounds in .wav format and one sound in .mp3 format.
>  One possibility to play the sounds would be a method:
>
>  AudioPlayer::play(QString& filename)
>  {
>         m_media->setCurrentSource(filename);
>         m_media->play();
>  }
>
>  But I think this is not a good idea because the sounds have to be loaded from
>  disk when the sound is played. Alternatively I could create a MediaObject for
>  each sound. Is this the intended way or is there another way to preload the
>  sounds when the application is started?

use MediaObject::enqueue( MediaSource ) for this.
>
>  Thanks in advance,
>  Michael
>
>  >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
>
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<