Beispiel #1
0
        public async Task <bool> PhoneCallEnded()
        {
            PushNotification("Phone call ended");

            var shouldStartWithMusic = PhoneCallsStack.ShouldStartWithMusic();

            if (!shouldStartWithMusic)
            {
                return(false);
            }

            var powerStatus = await _yamahaService.PowerStatus();

            var isTurnOn = powerStatus == PowerStatusEnum.On;
            var state    = await _smartHouseService.GetCurrentState();

            if (state == SmartHouseState.Pandora && isTurnOn)
            {
                _pandoraService.Play();
            }
            else if (state == SmartHouseState.Music && isTurnOn && _mpdService.GetStatus().State == MpdState.Pause)
            {
                _mpdService.Play();
            }

            return(true);
        }
Beispiel #2
0
        public async Task <bool> PhoneCallStarted(PhoneCallData phoneCall)
        {
            PushNotification("Phone call started");

            var powerStatus = await _yamahaService.PowerStatus();

            var isTurnOn = powerStatus == PowerStatusEnum.On;

            var state = await _smartHouseService.GetCurrentState();

            var isPlaying = false;

            if (state == SmartHouseState.Pandora && isTurnOn)
            {
                isPlaying = _pandoraService.IsPlaying();
            }
            else if (state == SmartHouseState.Music && isTurnOn)
            {
                isPlaying = _mpdService.GetStatus().State == MpdState.Play;
            }

            if (isPlaying)
            {
                if (state == SmartHouseState.Pandora)
                {
                    if (!PhoneCallsStack.PhoneCallActive())
                    {
                        _pandoraService.Pause();
                    }

                    PhoneCallsStack.AddPhoneCall(phoneCall);
                }
                else if (state == SmartHouseState.Music)
                {
                    if (!PhoneCallsStack.PhoneCallActive())
                    {
                        _mpdService.Pause();
                    }

                    PhoneCallsStack.AddPhoneCall(phoneCall);
                }
            }

            return(isPlaying);
        }
Beispiel #3
0
 public IEnumerable <PhoneCallData> AllPhoneCalls()
 {
     return(PhoneCallsStack.AllPhoneCalls());
 }