Difference between revisions of "Lua:Class:xmplayer"

From Cheat Engine
Jump to navigation Jump to search
(Created page with ''''function''' xmplayer_isPlaying() Returns true if an XM file is currently being played. ===Function Parameters=== <none> == See also == * Lua {{DISPLAYTITLE:xmplayer_i…')
 
m (Leunsel moved page xmplayer isPlaying to Lua:Class:xmplayer)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''function''' xmplayer_isPlaying()
+
[[Category:Lua]]
 +
{{Class|'''class''' xmplayer}}
  
Returns true if an XM file is currently being played.
+
The xmplayer class represents Cheat Engine's built-in XM module player.
  
 +
The xmplayer object is already defined globally as <code>xmplayer</code>. It does not need to be created manually.
  
===Function Parameters===
+
== Global Object ==
<none>
 
  
== See also ==
+
{{CodeBox|'''variable''' xmplayer ''':''' xmplayer}}
* [[Lua]]
 
  
{{DISPLAYTITLE:xmplayer_isPlaying}}
+
The global <code>xmplayer</code> object can be used directly to play, pause, resume, and stop XM files.
 +
 
 +
== Properties ==
 +
 
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Property
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|IsPlaying
 +
|Boolean
 +
|Indicates whether xmplayer is currently playing an XM file.
 +
|-
 +
|Initialized
 +
|Boolean
 +
|Indicates whether xmplayer is actively loaded in memory.
 +
|}
 +
 
 +
== Methods ==
 +
 
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Method
 +
!align="left"|Return Type
 +
!style="width: 80%;background-color:white;" align="left"|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===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Parameter
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|volume
 +
|Integer
 +
|The playback volume to set.
 +
|}
 +
 
 +
===playXM===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Parameter
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|filename
 +
|String
 +
|The path to an XM file.
 +
|-
 +
|tablefile
 +
|[[Lua:Class:TableFile|TableFile]]
 +
|A table file containing XM data.
 +
|-
 +
|stream
 +
|[[Lua:Class:Stream|Stream]]
 +
|A stream containing XM data.
 +
|-
 +
|noloop
 +
|Boolean OPTIONAL
 +
|If true, disables looping.
 +
|}
 +
 
 +
== Examples ==
 +
 
 +
===Check whether xmplayer is initialized===
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
print("Initialized: " .. tostring(xmplayer.Initialized))
 +
</syntaxhighlight>
 +
 
 +
===Play an XM file from disk===
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
xmplayer.playXM([[C:\\Music\\module.xm]])
 +
</syntaxhighlight>
 +
 
 +
===Play an XM file without looping===
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
xmplayer.playXM([[C:\\Music\\module.xm]], true)
 +
</syntaxhighlight>
 +
 
 +
===Set the volume===
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
xmplayer.setVolume(50)
 +
</syntaxhighlight>
 +
 
 +
===Pause and resume playback===
 +
<syntaxhighlight lang="lua" line highlight="1,3">
 +
xmplayer.pause()
 +
 
 +
xmplayer.resume()
 +
</syntaxhighlight>
 +
 
 +
===Stop playback===
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
xmplayer.stop()
 +
</syntaxhighlight>
 +
 
 +
===Check whether an XM file is playing===
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
if xmplayer.IsPlaying then
 +
  print("XM playback is active")
 +
else
 +
  print("No XM file is currently playing")
 +
end
 +
</syntaxhighlight>
 +
 
 +
===Play an XM file from a table file===
 +
<syntaxhighlight lang="lua" line highlight="4">
 +
local tableFile = findTableFile("music.xm")
 +
 
 +
if tableFile ~= nil then
 +
  xmplayer.playXM(tableFile)
 +
end
 +
</syntaxhighlight>
 +
 
 +
===Play an XM file from a stream===
 +
<syntaxhighlight lang="lua" line highlight="4,6">
 +
local stream = createMemoryStream()
 +
stream.loadFromFile([[C:\\Music\\module.xm]])
 +
 
 +
xmplayer.playXM(stream, true)
 +
 
 +
stream.destroy()
 +
</syntaxhighlight>
 +
 
 +
===Stop current playback before playing another XM file===
 +
<syntaxhighlight lang="lua" line highlight="2,5">
 +
if xmplayer.IsPlaying then
 +
  xmplayer.stop()
 +
end
 +
 
 +
xmplayer.playXM([[C:\\Music\\next_module.xm]])
 +
</syntaxhighlight>
 +
 
 +
{{LuaSeeAlso}}

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