Line 84: | Line 84: | ||
{{ScriptFunction|bool|Enabled|{ get; set; }|Is this component Enabled?|5= <pre>Space.Host.ExecutingObject.Radio.Enabled = true</pre>}} | {{ScriptFunction|bool|Enabled|{ get; set; }|Is this component Enabled?|5= <pre>Space.Host.ExecutingObject.Radio.Enabled = true</pre>}} | ||
− | {{ScriptFunction|string|URL|{ get; }|URL of the current stream|5= <pre>streamURL = Space.Host.ExecutingObject.Radio.URL </pre>}} | + | {{ScriptFunction|string|URL|{ get; }|URL of the current stream|5= <pre>streamURL = Space.Host.ExecutingObject.Radio.URL </pre>|6=<pre>--this script will update a UIText object with the current stream URL |
+ | --[this GameObject needs a "Shoutcast Streaming"/"SceneBackgroundMusic" component] | ||
+ | |||
+ | thisObj = Space.Host.ExecutingObject | ||
+ | |||
+ | text = Space.Host.GetReference("Text") -- set in Scripting Runtime references | ||
+ | |||
+ | |||
+ | OnUpdate = function() | ||
+ | text.UIText.Text = thisObj.Radio.URL | ||
+ | end | ||
+ | |||
+ | thisObj.OnUpdate(OnUpdate)</pre>}} | ||
Function will be called when track changes.
otc = function(trackInfo) Space.Log(trackInfo.Title) Space.Log(trackInfo.Artist) end Space.Host.ExecutingObject.Radio.OnTrackChange(otc)
Function will be called when there's an upcoming track change
otc = function(trackInfo) Space.Log(trackInfo.Title) Space.Log(trackInfo.Artist) end Space.Host.ExecutingObject.Radio.OnUpcomingTrackChange(otc)
Plays the radio stream
Space.Host.ExecutingObject.Radio.Play()
--this script will let us click a radio to make it start playing --(Example: clicking a light switch toggle's a parent light bulb's intensity) --[Requires a "Shoutcast Streaming" component on the parent of this object] thisGameObject = Space.Host.ExecutingObject IsPlaying = false StartPlaying = function() thisGameObject.Radio.Play() IsPlaying = true end StopPlaying = function() thisGameObject.Radio.Stop() IsPlaying = false end OnClick = function() if IsPlaying then StopPlaying() else StartPlaying() end end thisGameObject.AddClickable() thisGameObject.Clickable.Tooltip="Toggle Play/Stop" thisGameObject.Clickable.OnClick(OnClick)
Sets the given MP3 stream url as current stream
Space.Host.ExecutingObject.Radio.PlayMP3Stream("http://stream.example.org:1234/")
Sets the given Vorbis stream url as current stream
Space.Host.ExecutingObject.Radio.PlayVorbisStream("http://stream.example.org:1234/")
Stops playing the radio stream
Space.Host.ExecutingObject.Radio.Stop()
--this script will let us click a radio to make it start playing --(Example: clicking a light switch toggle's a parent light bulb's intensity) --[Requires a "Shoutcast Streaming" component on the parent of this object] thisGameObject = Space.Host.ExecutingObject IsPlaying = false StartPlaying = function() thisGameObject.Radio.Play() IsPlaying = true end StopPlaying = function() thisGameObject.Radio.Stop() IsPlaying = false end OnClick = function() if IsPlaying then StopPlaying() else StartPlaying() end end thisGameObject.AddClickable() thisGameObject.Clickable.Tooltip="Toggle Play/Stop" thisGameObject.Clickable.OnClick(OnClick)
Is this component Enabled?
Space.Host.ExecutingObject.Radio.Enabled = true
URL of the current stream
streamURL = Space.Host.ExecutingObject.Radio.URL
--this script will update a UIText object with the current stream URL --[this GameObject needs a "Shoutcast Streaming"/"SceneBackgroundMusic" component] thisObj = Space.Host.ExecutingObject text = Space.Host.GetReference("Text") -- set in Scripting Runtime references OnUpdate = function() text.UIText.Text = thisObj.Radio.URL end thisObj.OnUpdate(OnUpdate)
|