WoW:API PlaySoundFile: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
m (Move page script moved page API PlaySoundFile to API PlaySoundFile without leaving a redirect)
 
(18 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{wowapi}}
{{wowapi}}
<center>'''PlaySoundFile''' ''-Documentation by [[user:coder_1024|coder_1024]] taken from Dhargo's post on the official forums-''</center>
Plays the specified audio file once. Unlike [[API PlayMusic|PlayMusic]], you cannot stop the playback.
PlaySoundFile("path"[, "channel"])


<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
== Arguments ==
;path : String &ndash; The path and name of the sound file you'd like to play, relative to the WoW directory; both ogg and mp3 formats are accepted. The file must exist prior to logging in to WoW.
;channel : String &ndash; Either "Master" (this will play the sound also with disabled sounds like before 4.0.1), "SFX", "Ambience", "Music".


  PlaySoundFile(SoundFile);
== Examples ==
You can play a sound file included with your addon:
  PlaySoundFile("Interface\\AddOns\\MyAddOn\\mysound.ogg")
Or one of the ones shipped with WoW ([[Power of the Horde]], in this case):
PlaySoundFile("Sound\\Music\\ZoneMusic\\DMF_L70ETC01.mp3")  


<!-- Describe the purpose of the function, though exhausting detail can be saved for a later section -->
== Notes ==
* There does not appear to be a bad error if the file is missing - it just won't play. There is a return status, which is 1 if the sound was OK and nil if it couldn't be found.
* This API call was broken in patch 1.11 and was fixed in patch 1.11.2.
* As of 4.0.1, custom .wav files are no longer supported.


Play the specified sound file.  The file will be played once. Unlike [[API PlayMusic|PlayMusic]], you cannot stop the file fron playing once it starts.
== See also ==
 
* [[PlaySoundFile macros]] for a listing of audio files shipped with the game.
----
;''Arguments''
 
<!-- List each argument, together with its type -->
 
:(SoundFile)
:;SoundFile : String - The path and name of the sound file you'd like to play.  This has been successfully tested with .wav and .mp3 files.  Note that the path is relative to the World of Warcraft installation directory.
 
----
;''Example: Playing a sound file from within an AddOn's directory''
 
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory -->
 
PlaySoundFile("Interface\\AddOns\\MyAddOn\\mysound.wav");
 
or
 
PlaySoundFile("Interface\\AddOns\\MyAddOn\\mysound.mp3");
 
----
;''Details''
 
<!-- Details not appropriate for the main description can go here -->
 
This has been successfully tested for playing sounds inside your AddOn's directory, so you don't have to worry about putting your sound files outside your AddOn directory.
 
However - it does appear that the sound file must be present in the AddOn directory '''BEFORE''' loading the game.  A /console reloadui will not refresh the sound files. 
 
There does not appear to be a bad error if the file is missing - it just won't play. There is a return status, which is 1 if the sound was OK and nil if it couldn't be found.
 
This API call was broken in patch 1.11 and was fixed in patch 1.11.2.

Latest revision as of 04:47, 15 August 2023

WoW API < PlaySoundFile

Plays the specified audio file once. Unlike PlayMusic, you cannot stop the playback.

PlaySoundFile("path"[, "channel"])

Arguments[edit]

path
String – The path and name of the sound file you'd like to play, relative to the WoW directory; both ogg and mp3 formats are accepted. The file must exist prior to logging in to WoW.
channel
String – Either "Master" (this will play the sound also with disabled sounds like before 4.0.1), "SFX", "Ambience", "Music".

Examples[edit]

You can play a sound file included with your addon:

PlaySoundFile("Interface\\AddOns\\MyAddOn\\mysound.ogg")

Or one of the ones shipped with WoW (Power of the Horde, in this case):

PlaySoundFile("Sound\\Music\\ZoneMusic\\DMF_L70ETC01.mp3") 

Notes[edit]

  • There does not appear to be a bad error if the file is missing - it just won't play. There is a return status, which is 1 if the sound was OK and nil if it couldn't be found.
  • This API call was broken in patch 1.11 and was fixed in patch 1.11.2.
  • As of 4.0.1, custom .wav files are no longer supported.

See also[edit]