### Navigation

- index
- next |
- previous |
- The Pygame SGE 0.5.0 documentation »
- Classes »

# sge.Music

class `sge.``Music`(fname, ID=None, volume=100)

  Music handling class.

  This class stores and plays music. Music is very similar to sound effects, but only one music file can be played at a time, and it is more efficient for larger files than `sge.Sound`.

  What music formats are supported depends on the implementation of the SGE, but Ogg Vorbis is generally a good choice. See the implementation-specific information for a full list of supported formats.

  Note

  You should avoid the temptation to use MP3 files; MP3 is a patent-encumbered format, so many systems do not support it and royalties to the patent holders may be required for commercial use. There are many programs which can convert your MP3 files to the free Ogg Vorbis format.

  `volume`

    The volume of the music in percent from `0` to `100` (`0` for no sound, `100` for maximum volume).

  `fname`

    The file name of the music given when it was created. (Read-only)

  `id`

    The unique identifier of the music. (Read-only)

  `length`

    The length of the music in milliseconds. (Read-only)

  `playing`

    Whether or not the music is playing. (Read-only)

  `position`

    The current position (time) playback of the music is at in milliseconds. (Read-only)

## sge.Music Methods

`Music.``__init__`(fname, ID=None, volume=100)

  Constructor method.

  Arguments:

  - `fname` – The name of the sound file in one of the paths specified in `sge.music_directories`. If set to `None`, this object will not actually play any music. If this is neither a valid sound file nor `None`, `IOError` is raised.
  - `ID` – The value to set `id` to. If set to `None`, `fname` minus the extension will be used, modified by the SGE if it is already the unique idenfifier of another music object.

  All other arguments set the respective initial attributes of the music. See the documentation for `sge.Music` for more information.

`Music.``play`(start=0, loops=0, maxtime=None, fade_time=None)

  Play the music.

  Arguments:

  - `start` – The number of milliseconds from the beginning to start playing at.

  See the documentation for `sge.Sound.play()` for more information.

`Music.``queue`(start=0, loops=0, maxtime=None, fade_time=None)

  Queue the music for playback.

  This will cause the music to be added to a list of music to play in order, after the previous music has finished playing.

  See the documentation for `sge.Music.play()` for more information.

static `Music.``stop`(fade_time=None)

  Stop the currently playing music.

  See the documentation for `sge.Sound.stop()` for more information.

static `Music.``pause`()

  Pause playback of the currently playing music.

static `Music.``unpause`()

  Resume playback of the currently playing music if paused.

static `Music.``clear_queue`()

  Clear the music queue.

### Navigation

- index
- next |
- previous |
- The Pygame SGE 0.5.0 documentation »
- Classes »