コード例 #1
0
        /// <summary> Подготовка песни к воспроизведению </summary>
        public void SetCurrentSong(Song song)// => Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(() =>
        {
            try
            {
                if (song.CurrentMusicContainer == null)
                {
                    song.CurrentMusicContainer = CurrentMusicContainer;
                }
                else
                {
                    CurrentMusicContainer = song.CurrentMusicContainer;
                }

                CurrentSong = song;
                MP.Open(new Uri(CurrentSong.LocalUrl));


                // Загрузка изображения
                try
                {
                    TagLib.File file_TAG = TagLib.File.Create(song.LocalUrl);
                    var         bin      = file_TAG.Tag.Pictures[0].Data.Data; // Конвертация в массив байтов

                    var bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmapImage.StreamSource = new MemoryStream(bin);
                    bitmapImage.EndInit();
                    CurrentImage = bitmapImage;
                }
                catch (Exception)
                {
                    CurrentImage
                        = new BitmapImage(new Uri("pack://application:,,,/FierceStukCloud_NetCoreLib;component/Resources/Images/fsc_icon.png"));
                }
            }
            catch (Exception)
            {
            }
        }//));