[Gambas-user] The SDL component (for Ahmad, and other people)

Benoit Minisini gambas at ...2...
Wed Oct 1 21:57:33 CEST 2003

The SDL component is an "alpha version" of a component that will let you use 
the power of the SDL library.

At the moment, you can only play sounds with it. And a lot of things are 
missing in the implementation !

How can it be used ?

First, you have a static class named Music that let you play music.

Music.Load(FileName AS String) tells the component which music file you want 
to play.

Supported formats are WAV, OGG and MP3.

Then call Music.Play() to play the music, Music.Pause() to pause the music, 
Music.Play() to resume it, and Music.Stop() to stop it.

To play a sound, you must instanciate the 'Sound' class.

  DIM MySound AS Sound
  DIM MySoundFile AS String
  mySound = NEW Sound(MySoundFile)

MySoundFile contains the path to the sound file.

Then, you can play it with mySound.Play().

When you call mySound.Play(), the played sound is affected to a Channel 
object, which is returned by the Play() method.

  DIM hChannel AS Channel

  hChannel = MySound.Play()

Then, with a reference to the channel, you can pause the sound with 
hChannel.Pause(), resume it with hChannel.Play() and stop it with 

A same Sound object can be played twice (or more) on two different channels.

If you want to play a Sound in loop, specify the number of loops as a 
parameter to the Play method. Specify -1 if you want an endless loop.

  hChannel = MySound.Play(6) ' Play six times !

Of course, all this interface is subject to any change. But I think the 
principle of Sound and Channel classes will stay.


Benoit Minisini
mailto:gambas at ...1...

More information about the User mailing list