Difference between revisions of "Lua:Class:xmplayer"
Jump to navigation
Jump to search
(Major overhaul of the post.) |
|||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | ''' | + | {{Class|'''class''' xmplayer}} |
| − | + | 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. | ||
| − | {{ | + | == Global Object == |
| + | |||
| + | {{CodeBox|'''variable''' xmplayer ''':''' xmplayer}} | ||
| + | |||
| + | 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}} | {{LuaSeeAlso}} | ||
| − | |||
| − | |||
Revision as of 00:39, 27 June 2026
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]])