Esempio n. 1
0
        public IActionResult Music(string artist, string album, string track)
        {
            Uri url = new Uri("http://ws.audioscrobbler.com/2.0/").
                      AddQuery("method", "album.getinfo").
                      AddQuery("api_key", "ae35bc3b28eb6c8460ed87e3749d354b").
                      AddQuery("artist", artist).
                      AddQuery("album", album).
                      AddQuery("format", "json");

            string getinfo = SearchMusicController.GetResult(url);

            getinfo = getinfo.Replace("#text", "text");

            InfoAlbum.Rootobject infoAlbum = JsonConvert.DeserializeObject <InfoAlbum.Rootobject>(getinfo);
            ViewData["Album"]  = infoAlbum.album.name;
            ViewData["Artist"] = infoAlbum.album.artist;
            ViewData["Image"]  = infoAlbum.album.image.Single(x => x.size == "extralarge").text;
            ViewData["Tracks"] = infoAlbum.album.tracks.track;
            return(View("Index"));
        }
Esempio n. 2
0
        // GET: Redirect
        public ActionResult Redirect(string artist, string track)
        {
            if ((artist == null) || (track == null))
            {
                return(NotFound("Insert artist and track for redirection work."));
            }
            try
            {
                var infoTrack = SearchMusicController.MGetInfoTrack(artist, track);
                var album     = infoTrack.Album;
                if (infoTrack.Album != null)
                {
                    return(RedirectToAction("Music", "Play", new { artist = artist, album = album, track = track }));

                    //return Redirect($"/Play/Music/{artist}/{album}/{track}");
                }
            }
            catch (NullReferenceException)
            {
                return(NotFound("This track is not contained on database."));
            }

            return(NotFound("This track is not contained on some album."));
        }