Пример #1
0
    public override void OnReceivedMessage(Message message)
    {
        // A scene was changed (next video?)
        if (message.Route == (int)MessageDestination.SCENE_CHANGE)
        {
            // Is the scene valid?
            if (message.Identifier == "VALID")
            {
                // Get the scene node from the message
                SimulationScene scene = (SimulationScene)message.Data;

                // Try to get the scene attribute containing the video URL
                string url; //filePath
                if (scene.GetAttribute("VIDEO_URL", out url))
                {
                    // Right now the video is being loaded dynamically. There is only one video instance in the memory.(The video that is currently playing)
                    int width  = 1920;
                    int height = 1080;

                    string path = Application.dataPath + @"/JsonScene/" + url;

                    _videoPlayer.PlayVideo(path, width, height);

                    string brightness;
                    if (scene.GetAttribute("GENERAL_SETTINGS_SCENE_BRIGHTNESS", out brightness))
                    {
                        int brightnessInt = Int32.Parse(brightness);
                        _videoPlayer.SetExposure(brightnessInt);
                    }
                    else
                    {
                        _videoPlayer.SetExposure(100.0f);
                    }

                    string volume;
                    if (scene.GetAttribute("GENERAL_SETTINGS_SOUND_VOLUME", out volume))
                    {
                        int volumeInt = Int32.Parse(volume);
                        _videoPlayer.SetVolume(volumeInt);
                    }
                    else
                    {
                        _videoPlayer.SetVolume(100.0f);
                    }
                }
                else // Failure, log a message
                {
                    Debug.LogWarning("Failed to get 'VIDEO_URL' attribute from scene node");
                }
            }
        }
        else if (message.Route == (int)MessageDestination.SIMULATION_PAUSE) // Pause Video
        {
            _videoPlayer.PauseVideo();
        }
        else if (message.Route == (int)MessageDestination.SIMULATION_RESUME) // Resume Video
        {
            _videoPlayer.ResumeVideo();
        }
    }
Пример #2
0
    public override void OnReceivedMessage(Message message)
    {
        if (message.Route == (int)MessageDestination.SCENE_CHANGE)
        {
            if (message.Identifier == "VALID")
            {
                StopAllSources();
                SimulationScene scene = (SimulationScene)message.Data;

                string volumeStr; //filePath
                int    volume = 0;
                if (scene.GetAttribute("GENERAL_SETTINGS_ALARM_VOLUME", out volumeStr))
                {
                    volume = Int32.Parse(volumeStr);
                    if (volume <= 0)
                    {
                        return;
                    }
                }
                string filePath;
                if (scene.GetAttribute("GENERAL_SETTINGS_ALARM_FILE", out filePath))
                {
                    // Add a prefix to fix bad file names
                    string url        = Application.dataPath + @"/JsonScene/" + filePath;
                    string filePrefix = @"file://";
                    url = filePrefix + url;

                    Debug.Log(url);
                    AudioClip clip;
                    if (AudioLoader.LoadAudioClipBlocking(url, out clip))
                    {
                        PlayClip(Vector3.zero, clip, (float)volume / 100, true);
                    }
                    else
                    {
                        Debug.LogError("FAILED TO PLAY CLIP FROM URL " + url);
                    }
                }
            }
        }
    }
    public override void OnReceivedMessage(Message message)
    {
        switch (message.Route)
        {
        case (int)MessageDestination.SIMULATION_PAUSE:
        {
            // Pause the timeline
            timeline.SetPauseState(true);
        }
        break;

        case (int)MessageDestination.SIMULATION_RESUME:
        {
            // Pause the timeline
            timeline.SetPauseState(false);
        }
        break;

        case (int)MessageDestination.SIMULATION_START:
        {
            //timeline.Reset();
        }
        break;

        case (int)MessageDestination.SIMULATION_END:
        {
            timeline.ResetTimeline();
        }
        break;

        case (int)MessageDestination.SCENE_CHANGE:     // A Scene change has occurred
        {
            if (message.Identifier == "VALID")
            {
                SimulationScene scene = (SimulationScene)message.Data;

                // Get the timeline actions and push them to the timeline
                List <ITimelineAction> actions = timeline.GetRawActions();
                scene.GetActions(actions);

                string durationStr;
                if (scene.GetAttribute("DURATION", out durationStr))
                {
                    float duration;
                    if (float.TryParse(durationStr, out duration))
                    {
                        timeline.StartTimeline(duration);
                    }
                    else
                    {
                        Debug.LogWarning("Failed to parse scene duration");
                    }
                }
                else
                {
                    Debug.LogWarning("Failed to get scene duration");
                }
            }
        }
        break;
        }
    }