Breakroom is now Sinewave Campus. Book a meeting

SSceneBackgroundMusic

客户端组件
在此类中Play
  1. 函数
  2. Play
  3. PlayMP3Stream
  4. PlayVorbisStream
  5. Stop
  6. OnTrackChange
  7. OnUpcomingTrackChange
  8. 属性
  9. Enabled
  10. URL
  11. GameObject
成员 9
函数PlayPlays the radio stream
函数PlayMP3StreamSets the given MP3 stream url as current stream
函数PlayVorbisStreamSets the given Vorbis stream url as current stream
函数StopStops playing the radio stream
函数OnTrackChangeFunction will be called when track changes.
函数OnUpcomingTrackChangeFunction will be called when there's an upcoming track change
属性EnabledIs this component Enabled?
属性URLURL of the current stream
属性GameObject–

函数​

Play​

void Play()

Plays the radio stream

返回值

void

示例

Lua
Space.Host.ExecutingObject.Radio.Play()
Lua
--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)

PlayMP3Stream​

void PlayMP3Stream(string url)

Sets the given MP3 stream url as current stream

参数

名称类型默认值
urlstring–

返回值

void

示例

Lua
Space.Host.ExecutingObject.Radio.PlayMP3Stream("http://stream.example.org:1234/")

PlayVorbisStream​

void PlayVorbisStream(string url)

Sets the given Vorbis stream url as current stream

参数

名称类型默认值
urlstring–

返回值

void

示例

Lua
Space.Host.ExecutingObject.Radio.PlayVorbisStream("http://stream.example.org:1234/")

Stop​

void Stop()

Stops playing the radio stream

返回值

void

示例

Lua
Space.Host.ExecutingObject.Radio.Stop()
Lua
--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)

OnTrackChange​

void OnTrackChange(Closure o)
void OnTrackChange(Action< STrackInfo > trackInfoCallback)

Function will be called when track changes.

参数

名称类型默认值
oClosure–
trackInfoCallbackAction< STrackInfo >–

返回值

void

示例

Lua
otc = function(trackInfo)
end
Space.Host.ExecutingObject.Radio.OnTrackChange(otc)
Lua
--this script will update a UIText object with the track title on track change
--[this GameObject needs a "Shoutcast Streaming"/"SceneBackgroundMusic" component]

thisObj = Space.Host.ExecutingObject

text = Space.Host.GetReference("Text") -- set in Scripting Runtime references

otc = function(trackInfo)
text.UIText.Text = "Track: " .. trackInfo.Title .. " by " .. trackInfo.Artist
end

thisObj.Radio.OnTrackChange(otc)

OnUpcomingTrackChange​

void OnUpcomingTrackChange(Closure o)
void OnUpcomingTrackChange(Action< STrackInfo > trackInfoCallback)

Function will be called when there's an upcoming track change

参数

名称类型默认值
oClosure–
trackInfoCallbackAction< STrackInfo >–

返回值

void

示例

Lua
otc = function(trackInfo)

end
Space.Host.ExecutingObject.Radio.OnUpcomingTrackChange(otc)
Lua
--this script will update a UIText object with the track title on upcoming track change
--[this GameObject needs a "Shoutcast Streaming"/"SceneBackgroundMusic" component]

thisObj = Space.Host.ExecutingObject

text = Space.Host.GetReference("Text") -- set in Scripting Runtime references

outc = function(upcomingTrackInfo)
text.UIText.Text = "Track: " .. upcomingTrackInfo.Title .. " by " .. upcomingTrackInfo.Artist
end

thisObj.Radio.OnUpcomingTrackChange(outc)

属性​

Enabled​

bool Enabled {get; set; }

Is this component Enabled?

示例

Lua
Space.Host.ExecutingObject.Radio.Enabled = true
Lua
--clicking this object will Enable/Disable it's Scene Background Music component
thisGameObject = Space.Host.ExecutingObject
component = thisGameObject.Radio

OnClick = function()
component.Enabled = not component.Enabled
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

URL只读​

string URL {get; }

URL of the current stream

示例

Lua
streamURL = Space.Host.ExecutingObject.Radio.URL
Lua
--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)

GameObject只读​

SGameObject GameObject {get; }

示例

Lua
theGameObject = Space.Host.ExecutingObject.Floor.GameObject