wiki.sine.space | sinespace

Difference between revisions of "Scripting/SSceneBackgroundMusic"

From wiki.sine.space
Jump to: navigation, search
(Added simple examples to all members (8) of SSceneBackgroundMusic)
Line 12: Line 12:
 
Space.Host.ExecutingObject.Radio.OnUpcomingTrackChange(otc)</pre>}}
 
Space.Host.ExecutingObject.Radio.OnUpcomingTrackChange(otc)</pre>}}
  
{{ScriptFunction|void|Play|()|Plays the radio stream|5=<pre>Space.Host.ExecutingObject.Radio.Play()</pre>}}
+
{{ScriptFunction|void|Play|()|Plays the radio stream|5=<pre>Space.Host.ExecutingObject.Radio.Play()</pre>|6= <pre> --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) </pre>}}
  
 
{{ScriptFunction|void|PlayMP3Stream|(string url)|Sets the given MP3 stream url as current stream|5=<pre>Space.Host.ExecutingObject.Radio.PlayMP3Stream("http://stream.example.org:1234/")</pre>}}
 
{{ScriptFunction|void|PlayMP3Stream|(string url)|Sets the given MP3 stream url as current stream|5=<pre>Space.Host.ExecutingObject.Radio.PlayMP3Stream("http://stream.example.org:1234/")</pre>}}

Revision as of 00:54, 14 July 2021

Members

OnTrackChange

void OnTrackChange (Closure o)

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)


OnUpcomingTrackChange

void OnUpcomingTrackChange (Closure o)

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)


Play

void Play ()

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) 

PlayMP3Stream

void PlayMP3Stream (string url)

Sets the given MP3 stream url as current stream

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


PlayVorbisStream

void PlayVorbisStream (string url)

Sets the given Vorbis stream url as current stream

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


Stop

void Stop ()

Stops playing the radio stream

Space.Host.ExecutingObject.Radio.Stop()



Properties

Enabled

bool Enabled { get; set; }

Is this component Enabled?

Space.Host.ExecutingObject.Radio.Enabled = true


URL

string URL { get; }

URL of the current stream

streamURL = Space.Host.ExecutingObject.Radio.URL