Lua:Class:xmplayer
Revision as of 00:39, 27 June 2026 by Leunsel (talk | contribs) (Leunsel moved page xmplayer isPlaying to Lua:Class:xmplayer)
The xmplayer class represents Cheat Engine's built-in XM module player.
The xmplayer object is already defined globally as xmplayer. It does not need to be created manually.
Contents
- 1 Global Object
- 2 Properties
- 3 Methods
- 4 Method Parameters
- 5 Examples
- 5.1 Check whether xmplayer is initialized
- 5.2 Play an XM file from disk
- 5.3 Play an XM file without looping
- 5.4 Set the volume
- 5.5 Pause and resume playback
- 5.6 Stop playback
- 5.7 Check whether an XM file is playing
- 5.8 Play an XM file from a table file
- 5.9 Play an XM file from a stream
- 5.10 Stop current playback before playing another XM file
Global Object
The global xmplayer object can be used directly to play, pause, resume, and stop XM files.
Properties
| Property | Type | Description |
|---|---|---|
| IsPlaying | Boolean | Indicates whether xmplayer is currently playing an XM file. |
| Initialized | Boolean | Indicates whether xmplayer is actively loaded in memory. |
Methods
| Method | Return Type | Description |
|---|---|---|
| setVolume(volume) | void | Sets the XM playback volume. |
| playXM(filename, noloop OPTIONAL) | void | Plays an XM file from a filename. |
| playXM(tablefile, noloop OPTIONAL) | void | Plays an XM file from a table file. |
| playXM(stream, noloop OPTIONAL) | void | Plays an XM file from a stream. |
| pause() | void | Pauses XM playback. |
| resume() | void | Resumes paused XM playback. |
| stop() | void | Stops XM playback. |
Method Parameters
setVolume
| Parameter | Type | Description |
|---|---|---|
| volume | Integer | The playback volume to set. |
playXM
| Parameter | Type | Description |
|---|---|---|
| filename | String | The path to an XM file. |
| tablefile | TableFile | A table file containing XM data. |
| stream | Stream | A stream containing XM data. |
| noloop | Boolean OPTIONAL | If true, disables looping. |
Examples
Check whether xmplayer is initialized
1 print("Initialized: " .. tostring(xmplayer.Initialized))
Play an XM file from disk
1 xmplayer.playXM([[C:\\Music\\module.xm]])
Play an XM file without looping
1 xmplayer.playXM([[C:\\Music\\module.xm]], true)
Set the volume
1 xmplayer.setVolume(50)
Pause and resume playback
1 xmplayer.pause()
2
3 xmplayer.resume()
Stop playback
1 xmplayer.stop()
Check whether an XM file is playing
1 if xmplayer.IsPlaying then
2 print("XM playback is active")
3 else
4 print("No XM file is currently playing")
5 end
Play an XM file from a table file
1 local tableFile = findTableFile("music.xm")
2
3 if tableFile ~= nil then
4 xmplayer.playXM(tableFile)
5 end
Play an XM file from a stream
1 local stream = createMemoryStream()
2 stream.loadFromFile([[C:\\Music\\module.xm]])
3
4 xmplayer.playXM(stream, true)
5
6 stream.destroy()
Stop current playback before playing another XM file
1 if xmplayer.IsPlaying then
2 xmplayer.stop()
3 end
4
5 xmplayer.playXM([[C:\\Music\\next_module.xm]])