示例#1
0
        private async void selectPlayButton_Click(object sender, RoutedEventArgs e)
        {
            if (list.SelectedItem == null)
            {
                return;
            }

            if (list.SelectedItem.Sign == 0)
            {
                Media.Source = new Uri("ms-appdata:///local/" + list.SelectedItem.Url);
                Uri         uri  = new Uri("ms-appdata:///local/" + list.SelectedItem.Url);
                StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri);

                RandomAccessStreamReference imageStreamRef = RandomAccessStreamReference.CreateFromFile(file);
                MusicProperties             songProperties = await file.Properties.GetMusicPropertiesAsync();

                StorageItemThumbnail currentThumb = await file.GetThumbnailAsync(ThumbnailMode.MusicView, 200, ThumbnailOptions.UseCurrentScale);

                var albumCover = new BitmapImage();
                albumCover.SetSource(currentThumb);
                album.ImageSource = albumCover;
            }
            else if (list.SelectedItem.Sign == 1)
            {
                Uri pathUri = new Uri(list.SelectedItem.Url);
                Media.Source      = pathUri;
                album.ImageSource = list.SelectedItem.Imag;
            }

            //album.ImageSource = list.SelectedItem.Imag;
            if (list.SelectedItem.Sign == 0)
            {
                Media.Source = new Uri("ms-appdata:///local/" + list.SelectedItem.Url);
            }
            else if (list.SelectedItem.Sign == 1)
            {
                Uri pathUri = new Uri(list.SelectedItem.Url);
                Media.Source = pathUri;
            }
            SmallStoryboard.Begin();
            BigStoryboard.Begin();
            PoleStoryboard.Begin();

            TimeLine.Maximum = Media.NaturalDuration.TimeSpan.TotalSeconds;
            //初始化喜欢的图片
            if (list.SelectedItem.Like == true)
            {
                var bitmap = new BitmapImage(new Uri("ms-appx:///Assets/like.png"));
                LikeButtonImage.Source = bitmap;
            }
            else
            {
                var bitmap = new BitmapImage(new Uri("ms-appx:///Assets/unlike.png"));
                LikeButtonImage.Source = bitmap;
            }

            PlayPauseButton.Icon  = new SymbolIcon(Symbol.Pause);
            PlayPauseButton.Label = "Pause";
            PlayPauseButtonFlag   = 1;
        }
示例#2
0
        private void PlayPauseButton_Click(object sender, RoutedEventArgs e)
        {
            if (list.SelectedItem == null)
            {
                return;
            }
            Media.Play();
            Media.AutoPlay = true;


            if (PlayPauseButtonFlag == 0)
            {
                PlayMedia();
                PlayPauseButton.Icon  = new SymbolIcon(Symbol.Pause);
                PlayPauseButtonFlag   = 1;
                PlayPauseButton.Label = "pause";
                SmallStoryboard.Begin();
                BigStoryboard.Begin();
                PoleStoryboard.Begin();
            }
            else
            {
                PauseMedia();
                PlayPauseButton.Icon  = new SymbolIcon(Symbol.Play);
                PlayPauseButtonFlag   = 0;
                PlayPauseButton.Label = "play";
                SmallStoryboard.Pause();
                BigStoryboard.Pause();
                PoleBackStoryboard.Begin();
            }
        }