PlayEffect() публичный Метод

public PlayEffect ( string audioFile ) : AudioPlayer
audioFile string
Результат AudioPlayer
Пример #1
0
        public IceBucket(IEnumerable<string> args)
        {
            stateMachine = new Controller.EnumStateMachine<States>("Main");
            pulsatingEffect1 = new Effect.Pulsating(S(2), 0.05, 1.0, false);
            lightSpot = new StrobeColorDimmer("Spotlight");

            inputArm = new DigitalInput("Arm");
            inputDisarm = new DigitalInput("Disarm");
            inputDump = new DigitalInput("Dump");
            inputNextSong = new DigitalInput("Next Song");
            inputReset = new DigitalInput("Reset");
            relayStart = new Switch("Relay Start");
            relayDirA = new Switch("Relay Dir A");
            relayDirB = new Switch("Relay Dir B");

            audioPlayer = new AudioPlayer("Audio Player");

            this.oscServer = new Expander.OscServer(9999);

            stateMachine.For(States.Armed)
                .SetUp(() =>
                {
                    pulsatingEffect1.Start();
                    audioPlayer.PlayEffect("Nuclear-alarm");
                })
                .Execute(instance =>
                {
                    while (!instance.IsCancellationRequested)
                    {
                        instance.WaitFor(S(1));
                    }
                })
                .TearDown(() =>
                {
                    audioPlayer.PauseFX();
                    pulsatingEffect1.Stop();
                });

            stateMachine.For(States.Dumped)
                .Execute(instance =>
                {
                    while (!instance.IsCancellationRequested)
                    {
                        instance.WaitFor(S(1));
                    }
                });
            ;

            stateMachine.SetBackgroundState(States.Idle);
        }
Пример #2
0
        public DemoScene1(IEnumerable<string> args)
        {
            pulsatingEffect1 = new Effect.Pulsating(S(2), 0.1, 1.0, false, "Pulse FX 1");
            light1 = new StrobeColorDimmer("Small RGB");
            buttonTestSound = new DigitalInput("Test sound");
            buttonPlayBackground = new DigitalInput("Play Background");
            buttonPauseBackground = new DigitalInput("Pause Background");
            buttonTrigger1 = new DigitalInput("Test seq");
            buttonTestLight1 = new DigitalInput("Test light");
            buttonTestLight2 = new DigitalInput("Test pulse");
            switchTest1 = new Switch("Switch test 1");

            audioPlayer = new AudioPlayer("Audio Player");

            raspberry.DigitalInputs[4].Connect(buttonTrigger1, true);
            raspberry.DigitalOutputs[7].Connect(switchTest1);

            raspberry.Connect(audioPlayer);

            var demoSeq = new Controller.Sequence("Demo Sequence");
            demoSeq.WhenExecuted
                .Execute(instance =>
                {
                    audioPlayer.PlayEffect("laugh");
                    switchTest1.SetPower(true);
                    light1.SetColor(Color.Orange, 1.0);
                    instance.WaitFor(TimeSpan.FromSeconds(1));
                    switchTest1.SetPower(false);
                    light1.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0));
                });

            buttonTestSound.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PlayEffect("sixthsense-deadpeople");
                }
            };

            buttonPlayBackground.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PlayBackground();
                }
            };

            buttonPauseBackground.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    audioPlayer.PauseBackground();
                }
            };

            buttonTestLight1.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    light1.SetOnlyColor(Color.White);
                    light1.RunEffect(new Effect2.Fader(0.0, 1.0), S(1.0));
                    Thread.Sleep(S(1));
                    light1.RunEffect(new Effect2.Fader(1.0, 0.0), S(1.0));
                }
            };

            buttonTestLight2.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    pulsatingEffect1.Start();
                }
                else
                {
                    pulsatingEffect1.Stop();
                }
            };

            buttonTrigger1.ActiveChanged += (sender, e) =>
            {
                if (e.NewState)
                {
                    Executor.Current.Execute(demoSeq);
                }
            };

            pulsatingEffect1.AddDevice(light1);
        }