SSceneBackgroundMusic
العميلالمكونات
في هذا الصنفPlay
الأعضاء 9
| دالة | Play | Plays the radio stream |
| دالة | PlayMP3Stream | Sets the given MP3 stream url as current stream |
| دالة | PlayVorbisStream | Sets the given Vorbis stream url as current stream |
| دالة | Stop | Stops playing the radio stream |
| دالة | OnTrackChange | Function will be called when track changes. |
| دالة | OnUpcomingTrackChange | Function will be called when there's an upcoming track change |
| خاصية | Enabled | Is this component Enabled? |
| خاصية | URL | URL 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
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
| url | string | – |
القيم المرجعة
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
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
| url | string | – |
القيم المرجعة
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)
Function will be called when track changes.
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
| o | Closure | – |
| trackInfoCallback | Action< 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)
Function will be called when there's an upcoming track change
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
| o | Closure | – |
| trackInfoCallback | Action< 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للقراءة فقط
مثال
Lua
theGameObject = Space.Host.ExecutingObject.Floor.GameObject



