コード例 #1
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.");
                    }
                }
            });
        }