Difference between revisions of "Lua:Class:xmplayer"

From Cheat Engine
Jump to navigation Jump to search
(Major overhaul of the post.)
m (Leunsel moved page xmplayer isPlaying to Lua:Class:xmplayer)
 
(No difference)

Latest revision as of 00:39, 27 June 2026

{} Class

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.

Global Object[edit]

<> Lua API Reference

variable xmplayer : xmplayer

The global xmplayer object can be used directly to play, pause, resume, and stop XM files.

Properties[edit]

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[edit]

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[edit]

setVolume[edit]

Parameter Type Description
volume Integer The playback volume to set.

playXM[edit]

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[edit]

Check whether xmplayer is initialized[edit]

1 print("Initialized: " .. tostring(xmplayer.Initialized))

Play an XM file from disk[edit]

1 xmplayer.playXM([[C:\\Music\\module.xm]])

Play an XM file without looping[edit]

1 xmplayer.playXM([[C:\\Music\\module.xm]], true)

Set the volume[edit]

1 xmplayer.setVolume(50)

Pause and resume playback[edit]

1 xmplayer.pause()
2 
3 xmplayer.resume()

Stop playback[edit]

1 xmplayer.stop()

Check whether an XM file is playing[edit]

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[edit]

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[edit]

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[edit]

1 if xmplayer.IsPlaying then
2   xmplayer.stop()
3 end
4 
5 xmplayer.playXM([[C:\\Music\\next_module.xm]])

Main Pages

Core Lua documentation entry points

Lua
Script Engine