Esempio n. 1
0
    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
    }
Esempio n. 2
0
    public override void Init()
    {
        _allowedAgents = SplitStringIntoHashSet(AllowedAgents);

        _commandsUsage = new Dictionary <string, string>
        {
            { "/help", "" },
            { "/stream", "[url - leave blank to stop stream]" },
            { "/volume", "[0-100 increments of 10]" }
        };

        ScenePrivate.Chat.Subscribe(Chat.DefaultChannel, OnChat);

        scenePlayHandle = ScenePrivate.PlayStream(StreamChannel.AudioChannel, LoudnessPercentToDb(AudioStreamLoudness));
        if (DebugLogging)
        {
            Log.Write("setHandle " + scenePlayHandle);
        }
    }
Esempio n. 3
0
        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.");
                    }
                }
            });
        }