public override void Init() { //myVolume = ScenePrivate.PlayStream(StreamChannel.MediaChannel, 0); scenePlayHandle = ScenePrivate.PlayStream(StreamChannel.AudioChannel1, 0.0f); //turns off scene audio ObjectPrivate.TryGetFirstComponent(out audio); if (audio == null) { Log.Write("Did Not Find Audio Component"); ScenePrivate.Chat.MessageAllUsers("Media Screen for Youtube Viewer requires an Audio Emitter"); } else { Log.Write("Found Audio Component"); currentPlayHandle = audio.PlayStreamOnComponent(StreamChannel.AudioChannel1, volume); currentPlayHandle.SetLoudness(volume); SubscribeToAll("VolumeUp", VolumeUp); SubscribeToAll("VolumeDown", VolumeDown); SubscribeToAll("VolumeOn", VolumeOn); SubscribeToAll("VolumeOff", VolumeOff); } Log.Write("Script Started"); Script.UnhandledException += UnhandledException; // Catch errors and keep running unless fatal }
void Setup(StreamChannel channel, string eventName, float loudness) { unsubscribes += SubscribeToAll(eventName, (ScriptEventData subData) => { StopSound(true); if (PrivateMedia) { ISimpleData simpleData = subData.Data?.AsInterface <ISimpleData>(); if (simpleData != null && simpleData.AgentInfo != null) { AgentPrivate agent = ScenePrivate.FindAgent(simpleData.AgentInfo.SessionId); if (agent != null && agent.IsValid) { try { if (Spatialized) { if (audio != null) { currentPlayHandle = agent.PlayStreamOnComponent(channel, audio, loudness); } else { currentPlayHandle = agent.PlayStreamAtPosition(channel, ObjectPrivate.Position, loudness); } } else { currentPlayHandle = agent.PlayStream(channel, loudness); } } catch (ThrottleException) { // Throttled Log.Write(LogLevel.Warning, "PlayStream request throttle hit. Stream not set."); } catch (NullReferenceException) { // User Left, ignore. } } } } else { try { if (Spatialized) { if (audio != null) { currentPlayHandle = audio.PlayStreamOnComponent(channel, loudness); } else { currentPlayHandle = ScenePrivate.PlayStreamAtPosition(channel, ObjectPrivate.Position, loudness); } } else { currentPlayHandle = ScenePrivate.PlayStream(channel, loudness); } } catch (ThrottleException) { // Throttled Log.Write(LogLevel.Warning, "PlayStream request throttle hit. Stream not set."); } } }); }
public override void Init() { //myVolume = ScenePrivate.PlayStream(StreamChannel.MediaChannel, 0); ObjectPrivate.TryGetFirstComponent(out audio); if (audio == null) { Log.Write("Did Not Find Audio Component"); ScenePrivate.Chat.MessageAllUsers("Media Screen for Youtube Viewer requires an Audio Emitter"); } else { Log.Write("Found Audio Component"); currentPlayHandle = audio.PlayStreamOnComponent(StreamChannel.MediaChannel, volume); } Log.Write("Script Started"); PlayList.Clear(); if (Play1.Length > 0) { PlayList.Add(Play1); } if (Play2.Length > 0) { PlayList.Add(Play2); } if (Play3.Length > 0) { PlayList.Add(Play3); } if (Play4.Length > 0) { PlayList.Add(Play4); } if (Play5.Length > 0) { PlayList.Add(Play5); } if (Play6.Length > 0) { PlayList.Add(Play6); } if (Play7.Length > 0) { PlayList.Add(Play7); } if (Play8.Length > 0) { PlayList.Add(Play8); } if (Play9.Length > 0) { PlayList.Add(Play9); } if (Play10.Length > 0) { PlayList.Add(Play10); } if (Play11.Length > 0) { PlayList.Add(Play11); } if (Play12.Length > 0) { PlayList.Add(Play12); } if (Play13.Length > 0) { PlayList.Add(Play13); } if (Play14.Length > 0) { PlayList.Add(Play14); } if (Play15.Length > 0) { PlayList.Add(Play15); } Script.UnhandledException += UnhandledException; // Catch errors and keep running unless fatal //ScenePrivate.Chat.MessageAllUsers(WelcomeMessage); ScenePrivate.Chat.Subscribe(0, GetChatCommand); SubscribeToScriptEvent("SendPlayShuffle", GetCommands); SubscribeToScriptEvent("SendPlayList", GetCommands); SubscribeToScriptEvent("SendStop", GetCommands); SubscribeToScriptEvent("SendPrevious", GetCommands); SubscribeToScriptEvent("SendPause", GetCommands); SubscribeToScriptEvent("SendResume", GetCommands); SubscribeToScriptEvent("SendNext", GetCommands); SubscribeToScriptEvent("SendForceVideo", GetCommands); SubscribeToScriptEvent("SendVolumeDown", GetCommands); SubscribeToScriptEvent("SendVolumeUp", GetCommands); SubscribeToScriptEvent("SendEject", GetCommands); SubscribeToScriptEvent("play1", GetCommands); SubscribeToScriptEvent("play2", GetCommands); SubscribeToScriptEvent("play3", GetCommands); SubscribeToScriptEvent("play4", GetCommands); SubscribeToScriptEvent("play5", GetCommands); SubscribeToScriptEvent("play6", GetCommands); SubscribeToScriptEvent("play7", GetCommands); SubscribeToScriptEvent("play8", GetCommands); SubscribeToScriptEvent("play9", GetCommands); SubscribeToScriptEvent("play10", GetCommands); SubscribeToScriptEvent("play11", GetCommands); SubscribeToScriptEvent("play12", GetCommands); SubscribeToScriptEvent("play13", GetCommands); SubscribeToScriptEvent("play14", GetCommands); SubscribeToScriptEvent("play1", GetCommands); }