playClip: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page PlayClip to playClip: Converting page titles to lowercase)
No edit summary
Line 9: Line 9:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
playClip(uri)
playClip(uri)
playClip(uri, cycleCount)
playClip(uri, cycleCount)
playClip(uri, cycleCount, volume)
playClip(uri, cycleCount, volume)
</source>
</syntaxhighlight>


'''Parameter'''
'''Parameter'''
Line 24: Line 24:
To play a song from an online source to all clients, the GM can create the macro "playSong" on a Lib token, say, "Lib:MusicPlayer":
To play a song from an online source to all clients, the GM can create the macro "playSong" on a Lib token, say, "Lib:MusicPlayer":


<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[playClip(macro.args)]
[playClip(macro.args)]
</source>
</syntaxhighlight>


To play the song, the GM can then use [[execLink]]:
To play the song, the GM can then use [[execLink]]:


<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[H: songUrl = "http://erinmcnamee.com.hostbaby.com/files/07_No_Sorrow__Banish_Misfortune.mp3"]
[H: songUrl = "http://erinmcnamee.com.hostbaby.com/files/07_No_Sorrow__Banish_Misfortune.mp3"]
[H: audioByte = macroLinkText("playSong@Lib:MusicPlayer", "none", songUrl)]
[H: audioByte = macroLinkText("playSong@Lib:MusicPlayer", "none", songUrl)]
[H: execLink(audioByte,0,"all")]
[H: execLink(audioByte,0,"all")]
</source>
</syntaxhighlight>


== Dropbox URLs ==
== Dropbox URLs ==

Revision as of 22:36, 14 March 2023

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.
 This article needs: Needs basic examples of both online and local file playback

playClip() Function

Introduced in version 1.5.7
Play an audio clip on local computer, from an online source or from a local file. Multiple audio sources can be played from at the same time and unlike playStream() the same audio source can be played simultaneously by multiple calls to playClip(). Supports MP3 and Wave formats. Playback can be disabled on a client via Preferences -> Sound -> Play streams. See the playStream() page for details on using Dropbox urls.

Note: Audio clips are loaded into memory in uncompressed form and could potentially consume a lot of memory. playClip() is best used for short Sound FX clips. Use playStream() for long-playing soundtracks/ambient sounds.

Usage

playClip(uri)
playClip(uri, cycleCount)
playClip(uri, cycleCount, volume)

Parameter

  • uri - The uri/url of the file. For example, http://www.mywebsite/mysong.mp3 or file:/C:/mysong.mp3
  • 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.
  • volume - The volume the audio is to be played at. Can range from 0 to 1. Defaults to 1.

Examples

To play a song from an online source to all clients, the GM can create the macro "playSong" on a Lib token, say, "Lib:MusicPlayer":
[playClip(macro.args)]

To play the song, the GM can then use execLink:

[H: songUrl = "http://erinmcnamee.com.hostbaby.com/files/07_No_Sorrow__Banish_Misfortune.mp3"]
[H: audioByte = macroLinkText("playSong@Lib:MusicPlayer", "none", songUrl)]
[H: execLink(audioByte,0,"all")]

Dropbox URLs

After creating the dropbox share link you have to replace www.dropbox.com with dl.dropboxusercontent.com. That provides a direct link that playClip can use. Thanks to Full Bleed on the forums for the tip.