defineAudioSource: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
m (Text replacement - "<source" to "<syntaxhighlight")
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{stub|Just a skeleton.}}
{{MacroFunction
{{MacroFunction
|name=defineAudioSource
|name=defineAudioSource
|version=1.5.7
|version=1.5.7
|description=
|description=
Description...
Assign a nickname to an audio source and optionally preload it or set playback values. The resulting nickname can be used instead of the URI in audio functions.


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
defineAudioSource(uri)
defineAudioSource(nickname, uri)
defineAudioSource(uri, cycleCount)
defineAudioSource(nickname, uri, preload)
defineAudioSource(uri, cycleCount, volume)
defineAudioSource(nickname, uri, preload, cycleCount)
defineAudioSource(uri, cycleCount, volume, start)
defineAudioSource(nickname, uri, preload, cycleCount, volume)
defineAudioSource(uri, cycleCount, volume, start, stop)
defineAudioSource(nickname, uri, preload, cycleCount, volume, start)
</source>
defineAudioSource(nickname, uri, preload, cycleCount, volume, start, stop)
</syntaxhighlight>


'''Parameter'''
'''Parameter'''
{{param|uri|The uri/url of the file. For example, http://www.mywebsite/mysong.mp3 or file:/C:/mysong.mp3 }}
{{param|nickname|The nickname of the file. For example, "tense music"}}
{{param|cycleCount|The number of times the audio should play. If set to 0, the file is cached but not played; if set to -1, the file is played continuously. Defaults to 1.}}
{{param|uri|The URI/URL of the file. For example, http://www.mywebsite/mysong.mp3 or file:/C:/mysong.mp3 }}
{{param|volume|The volume the audio is to be played at. Can range from 0 to 1. Defaults to 1.}}
{{param|preload|A string indicating if the audio should be pre-loaded or not. If set to "clip", preloads it as a clip. If set to "stream", preloads it as a stream. Any other string does not preload the audio source.}}
{{param|start|The time offset in seconds where audio should start playing, or restart from when repeating. Defaults to 0.}}
{{param|cycleCount|Set the default number of times the audio should play. If set to -1, the file is played continuously.}}
{{param|stop|The time offset where audio should stop playing or restart when repeating. Defaults to the end of the audio.}}
{{param|volume|Set the default volume the audio is to be played at. Can range from 0 to 1.}}
 
{{param|start|Set the default time offset in seconds where audio should start playing, or restart from when repeating. Streams only.}}
 
{{param|stop|Set the default time offset where audio should stop playing or restart when repeating. Streams only.}}
|examples=
 
<source lang="mtmacro" line>
</source>


|examples=
An example on how to define an audio source:
<syntaxhighlight lang="mtmacro" line>
[defineAudioSource("no sorrow", "http://erinmcnamee.com.hostbaby.com/files/07_No_Sorrow__Banish_Misfortune.mp3", "stream", -1, 0.5)]
</syntaxhighlight>
The source can now be played as
<syntaxhighlight lang="mtmacro" line>
[playStream("no sorrow")]
</syntaxhighlight>
which will play the file continuously and at 50% volume.
}}
}}
[[Category:Audio Function]]
[[Category:Audio Function]]

Latest revision as of 23:59, 14 March 2023

defineAudioSource() Function

Introduced in version 1.5.7
Assign a nickname to an audio source and optionally preload it or set playback values. The resulting nickname can be used instead of the URI in audio functions.

Usage

defineAudioSource(nickname, uri)
defineAudioSource(nickname, uri, preload)
defineAudioSource(nickname, uri, preload, cycleCount)
defineAudioSource(nickname, uri, preload, cycleCount, volume)
defineAudioSource(nickname, uri, preload, cycleCount, volume, start)
defineAudioSource(nickname, uri, preload, cycleCount, volume, start, stop)

Parameter

  • nickname - The nickname of the file. For example, "tense music"
  • uri - The URI/URL of the file. For example, http://www.mywebsite/mysong.mp3 or file:/C:/mysong.mp3
  • preload - A string indicating if the audio should be pre-loaded or not. If set to "clip", preloads it as a clip. If set to "stream", preloads it as a stream. Any other string does not preload the audio source.
  • cycleCount - Set the default number of times the audio should play. If set to -1, the file is played continuously.
  • volume - Set the default volume the audio is to be played at. Can range from 0 to 1.
  • start - Set the default time offset in seconds where audio should start playing, or restart from when repeating. Streams only.
  • stop - Set the default time offset where audio should stop playing or restart when repeating. Streams only.

Examples

An example on how to define an audio source:
[defineAudioSource("no sorrow", "http://erinmcnamee.com.hostbaby.com/files/07_No_Sorrow__Banish_Misfortune.mp3", "stream", -1, 0.5)]

The source can now be played as

[playStream("no sorrow")]
which will play the file continuously and at 50% volume.