playClip: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{stub|Needs basic examples of both online and local file playback}} {{MacroFunction |name=playClip |version=1.5.7 |description= Play an audio clip on local computer, from an...") |
mNo edit summary |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 4: | Line 4: | ||
|version=1.5.7 | |version=1.5.7 | ||
|description= | |description= | ||
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 {{func|playStream}} the same audio source can be played simultaneously by multiple calls to {{func|playClip}}. Supports MP3 and Wave formats. Playback can be disabled on a client via Preferences -> Sound -> Play streams. | 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 {{func|playStream}} the same audio source can be played simultaneously by multiple calls to {{func|playClip}}. Supports MP3 and Wave formats. Playback can be disabled on a client via Preferences -> Sound -> Play streams. See the {{func|playStream}} page for details on using Dropbox urls. | ||
< | <p> | ||
Audio clips are loaded into memory in uncompressed form and could potentially consume a lot of memory. {{func|playClip}} is best used for short Sound FX clips. Use {{func|playStream}} for long-playing soundtracks/ambient sounds. | '''Note:''' Audio clips are loaded into memory in uncompressed form and could potentially consume a lot of memory. {{func|playClip}} is best used for short Sound FX clips. Use {{func|playStream}} for long-playing soundtracks/ambient sounds. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
playClip(uri) | playClip(uri) | ||
playClip(uri, cycleCount) | playClip(uri, cycleCount) | ||
playClip(uri, cycleCount, volume) | playClip(uri, cycleCount, volume) | ||
</ | </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": | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[playClip(macro.args)] | [playClip(macro.args)] | ||
</ | </syntaxhighlight> | ||
To play the song, the GM can then use [[execLink]]: | To play the song, the GM can then use [[execLink]]: | ||
< | <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")] | ||
</ | </syntaxhighlight> | ||
== Dropbox URLs == | == Dropbox URLs == | ||
After creating the dropbox share link you have to replace {{code|www.dropbox.com}} with {{code|dl.dropboxusercontent.com}}. That provides a direct link that playClip can use. Thanks to Full Bleed on the forums for the tip. | After creating the dropbox share link you have to replace {{code|www.dropbox.com}} with {{code|dl.dropboxusercontent.com}}. That provides a direct link that playClip can use. Thanks to Full Bleed on the forums for the tip. | ||
As if 9/1/23 new dropbox files have a different format and can no longer be converted to allow playClip to work. The url link needs to end in .mp3 or other valid file type. An alternate method is to now use a Discord server to file host and copy the link from the post. | |||
}} | }} | ||
[[Category:Audio Function]] | [[Category:Audio Function]] |
Latest revision as of 23:59, 11 September 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.mp3cycleCount
- 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.