Exemplo n.º 1
0
        private async Task CortanaResponseShowSong(SongResult info)
        {
            if (info == null)
            {
                await CompleteMessage("Right now... Nothing is playing");
            }
            else if (info.Loved)
            {
                var message = $"Now is playing: {info.Song}, from artist {info.Artist}, on album {info.Album}. You liked this song.";
                await CompleteMessage(message);
            }
            else
            {
                var message = $"Now is playing: {info.Song}, from artist {info.Artist}, on album {info.Album}. Do you like this song?";

                var userPrompt = new VoiceCommandUserMessage();
                userPrompt.DisplayMessage = userPrompt.SpokenMessage = message;

                var userReprompt = new VoiceCommandUserMessage();
                var prompt       = "Do you like this song?";
                userReprompt.DisplayMessage = userReprompt.SpokenMessage = prompt;

                var response = VoiceCommandResponse.CreateResponseForPrompt(userPrompt, userReprompt);
                var voiceCommandConfirmation = await voiceServiceConnection.RequestConfirmationAsync(response);

                if (voiceCommandConfirmation == null)
                {
                    response = VoiceCommandResponse.CreateResponse(userPrompt);
                    await voiceServiceConnection.ReportSuccessAsync(response);
                }
                else if (voiceCommandConfirmation.Confirmed)
                {
                    var service = new SmartHouseService();
                    var result  = await service.LoveSong();

                    await CompleteMessage(result?.Message);
                }
                else
                {
                    await CompleteMessage("");
                }
            }
        }
Exemplo n.º 2
0
        private async Task ExecutePandoraCommands(string command)
        {
            var pandora    = new PandoraService();
            var smartHouse = new SmartHouseService();

            await ShowProgressScreen($"Starting to {command} song");

            switch (command)
            {
            case "Play":
                await smartHouse.Run(UWPLib.Model.SmartHouseCommands.Play);
                await CompleteMessage("");

                break;

            case "Stop":
                await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.Play);
                await CompleteMessage("");

                break;

            case "Next":
                await smartHouse.Run(UWPLib.Model.SmartHouseCommands.Next);
                await CompleteMessage("");

                break;

            case "Love":
                await smartHouse.LoveSong();
                await CompleteMessage("");

                break;

            case "Hate":
                await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.ThumbDown);
                await CompleteMessage("");

                break;

            case "Boring":
                await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.Tired);
                await CompleteMessage("");

                break;

            case "Show":
                var info = await smartHouse.GetCurrentSong();
                await CortanaResponseShowSong(info);

                break;

            case "NextStation":
                var nextInfo = await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.NextStation);
                await CompleteMessage(nextInfo?.Message);

                break;

            case "PrevStation":
                var prevInfo = await pandora.Run(SmartHouse.UWPLib.Model.PandoraCommands.PrevStation);
                await CompleteMessage(prevInfo?.Message);

                break;

            default:
                LaunchAppInForeground();
                break;
            }
        }