Example #1
0
        public void FullfillAIResponse()
        {
            if (!SetAndTestMPD())
            {
                OnActionFullfilled?.Invoke("There is no connected MPD Server");
                return;
            }

            if (response.Result.ActionIncomplete)
            {
                OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
                return;
            }

            string action = response.Result.Action;

            if (action == "music.play")
            {
                FullfillPlayAction();
            }
            else if (action == "music.playlist")
            {
                FullfillPlaylistAction();
            }
            else if (action == "music.artist")
            {
                FullfillArtistAction();
            }
            else if (action == "music.pause")
            {
                FullfillPauseAction();
            }
            else if (action == "music.previous")
            {
                FullfillPreviousAction();
            }
            else if (action == "music.shuffle")
            {
                FullfillShuffleAction();
            }
            else if (action == "music.skip")
            {
                FullfillSkipAction();
            }
            else if (action == "music.resume")
            {
                FullfillSkipAction();
            }
            else if (action == "music.stop")
            {
                FullfillStopAction();
            }
        }
Example #2
0
        private void FullfillPlaylistAction()
        {
            string       playlistName = response.Result.Parameters["Playlist"] as string;
            MPDFileEntry playlist     = con.GetPlaylists().Find(x => x.Path.Contains(playlistName));

            if (playlist != null)
            {
                con.LoadPlaylist(playlist.Path);
                con.PlaySongIndex(0);
                OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
            }
            else
            {
                OnActionFullfilled?.Invoke("Sorry there is no playlist named " + playlistName);
            }
        }
Example #3
0
        private void FullfillPlayAction()
        {
            string songTitle = response.Result.Parameters["Song"] as String;
            var    fileList  = con.GetSearchedFiles(songTitle, MPDCommands.MPD_SEARCH_TYPE.MPD_SEARCH_FILE);

            if (fileList.Count == 0)
            {
                OnActionFullfilled?.Invoke(
                    String.Format(
                        "Sorry there is no song with the title {0} in your Files", songTitle));
            }
            else
            {
                con.ClearPlaylist();
                con.AddSong(fileList[0].Path);
                con.PlaySongIndex(0);
                OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
            }
        }
Example #4
0
        private void FullfillArtistAction()
        {
            string artistName            = response.Result.Parameters["Artist"] as string;
            List <MPDFileEntry> fileList = con.GetSearchedFiles(
                artistName, MPDCommands.MPD_SEARCH_TYPE.MPD_SEARCH_ARTIST);

            if (fileList.Count != 0)
            {
                con.ClearPlaylist();
                foreach (var file in fileList)
                {
                    con.AddSong(file.Path);
                }
                Random r = new Random();
                con.PlaySongIndex(r.Next(0, fileList.Count));
                OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
            }
            else
            {
                OnActionFullfilled?.Invoke(
                    String.Format("There is no artist called {0} in your list", artistName));
            }
        }
Example #5
0
 private void FullfillStopAction()
 {
     con.StopPlayback();
     OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
 }
Example #6
0
 private void FullfillResumeAction()
 {
     con.Pause(false);
     OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
 }
Example #7
0
 private void FullfillSkipAction()
 {
     con.NextSong();
     OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
 }
Example #8
0
 private void FullfillShuffleAction()
 {
     con.ShufflePlaylist();
     OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
 }
Example #9
0
 private void FullfillPreviousAction()
 {
     con.PreviousSong();
     OnActionFullfilled?.Invoke(response.Result.Fulfillment.Speech);
 }