コード例 #1
0
        public async static void AddMusicFileSpotify(string trackID)
        {
            if (String.IsNullOrWhiteSpace(trackID))
            {
                throw new ArgumentException($"Cannot add new music file, since its ID is null or empty.", nameof(trackID));
            }

            try
            {
                ISpotifyService             spotifyService = DependencyInjector.GetService <ISpotifyService>();
                Dictionary <string, string> tagData        = await spotifyService.GetTrackData(trackID);

                MetaData trackData = UtilityHelper.FormatMetaDataSpotify(tagData, out string trackURI);

                TrackVirtual track = new TrackVirtual(trackData, false);
                track.SpotifyID  = trackID;
                track.SpotifyURI = trackURI;
                SpotifyTracks.Add(track);
                FilteredSpotifyTracks.Add(track);
            }
            catch (Exception) // TODO: more polished exception handling
            {
                UtilityHelper.ShowExceptionDialog(
                    "Track parsing error",
                    "Track parsing error happened while trying to parse a music file from Spotify. This file will be omitted from Playzone!",
                    $"Track URI: {trackID}");
            }
        }