OnClientSoundStream: Difference between revisions
Jump to navigation
Jump to search
(Added error parameter) |
|||
(One intermediate revision by one other user not shown) | |||
Line 5: | Line 5: | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool success, int length, string streamName | bool success, int length, string streamName, string errorMessage | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 11: | Line 11: | ||
*'''length''': The length of the stream in seconds. Always returns '''0''' for a live stream | *'''length''': The length of the stream in seconds. Always returns '''0''' for a live stream | ||
*'''streamName''': The name of the stream. Note that this isn't the filename. Also note that this isn't always provided | *'''streamName''': The name of the stream. Note that this isn't the filename. Also note that this isn't always provided | ||
*'''errorMessage''': A string containing the error message or an empty string if there was no error | |||
==Source== | ==Source== | ||
Line 16: | Line 17: | ||
==Example== | ==Example== | ||
This example outputs to the chatbox (if it was a success) "thesoundname has finished in ... | This example outputs to the chatbox (if it was a success) "thesoundname has finished in ... seconds.", if it was not a success then it would output "thesoundname failed to start". | ||
<syntaxhighlight lang="lua">addEventHandler("onClientSoundStream",root,function(suc,length,streamN) | <syntaxhighlight lang="lua">addEventHandler("onClientSoundStream",root,function(suc,length,streamN) | ||
if not suc then outputChatBox("Sound: "..streamN.." failed to start.",100,0,0) return end | if not suc then outputChatBox("Sound: "..streamN.." failed to start.",100,0,0) return end | ||
outputChatBox("The sound: "..streamN.." has finished in "..length.." | outputChatBox("The sound: "..streamN.." has finished in "..length.."secs.") | ||
end) | end) | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 23:56, 20 November 2018
This event is triggered when a sound has just finished initial streaming. For file streams, this means the sound will now start playing, but isn't done downloading yet. For live streams, this just means the stream will start playing. This event will also trigger when, for some reason, the streaming failed.
Parameters
bool success, int length, string streamName, string errorMessage
- success: A boolean indicating whether the stream was a success or not
- length: The length of the stream in seconds. Always returns 0 for a live stream
- streamName: The name of the stream. Note that this isn't the filename. Also note that this isn't always provided
- errorMessage: A string containing the error message or an empty string if there was no error
Source
The source of this event is the sound which either successfully streamed or failed to stream.
Example
This example outputs to the chatbox (if it was a success) "thesoundname has finished in ... seconds.", if it was not a success then it would output "thesoundname failed to start".
addEventHandler("onClientSoundStream",root,function(suc,length,streamN) if not suc then outputChatBox("Sound: "..streamN.." failed to start.",100,0,0) return end outputChatBox("The sound: "..streamN.." has finished in "..length.."secs.") end)
See Also
Client player events
- onClientSoundBeat
- onClientSoundChangedMeta
- onClientSoundFinishedDownload
- onClientSoundStarted
- onClientSoundStopped
- onClientSoundStream
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled