Beispiel #1
0
        private void Previous()
        {
            if (SongGrid.SelectedIndex != 0)
            {
                if (Mplayer.Position.TotalSeconds > 3)
                {
                    SongGrid.SelectedIndex = SongGrid.SelectedIndex;
                }
                else if (SongGrid.SelectedIndex != -1)
                {
                    SongGrid.SelectedIndex = SongGrid.SelectedIndex - 1;
                }
                else
                {
                    return;
                }


                _selectedSong = SongGrid.SelectedItem as Itemsource.Songs;

                if (_selectedSong != null)
                {
                    PlaySong(_selectedSong);
                }
            }
        }
Beispiel #2
0
        void PlaySong(Itemsource.Songs song)
        {
            if (song != null)
            {
                _timer.Start();
                Mplayer.Open(new Uri(song.FileName));
                Console.WriteLine(song.FileName);
                Mplayer.Play();
                PlayPauseButton.OpacityMask = new VisualBrush {
                    Visual = (Visual)FindResource("Pause")
                };

                _audioPlaying = true;
                GetAlbumart(song);

                if (song.Name != null)
                {
                    NowPlayingSong.Content = song.Name + " - " + song.Artist;
                }
                else
                {
                    NowPlayingSong.Content = song.AltName + " - " + song.Artist;
                }

                NowPlayingAlbum.Text   = song.Album;
                NowPlayingTrack.Text   = song.Track;
                ScrubBar.Maximum       = song.Length;
                TotalScrubTime.Content = "- " + song.Duration;
            }
        }
Beispiel #3
0
        private void PlayOrPause()
        {
            if (_selectedSong == null && !_audioPlaying) // If no song is selected play the first one in the list
            {
                SongGrid.SelectedIndex = 0;
                _selectedSong          = SongGrid.SelectedItem as Itemsource.Songs;
                PlaySong(_selectedSong);
                return;
            }

            if (_selectedSong == null) //If we dont already have a song playing
            {
                _selectedSong = SongGrid.SelectedItem as Itemsource.Songs;
            }

            if (_audioPlaying) // If the song is playing pause it
            {
                PauseSong();
            }
            else // Otherwise continue the song
            {
                Mplayer.Play();
                _timer.Start();
                _audioPlaying = true;
                PlayPauseButton.OpacityMask = new VisualBrush {
                    Visual = (Visual)FindResource("Pause")
                };
            }
        }
Beispiel #4
0
        private void Album_OnClick(object sender, RoutedEventArgs e)
        {
            var tile = sender as Tile;

            if (tile != null)
            {
                var content = tile.Title;
                var album   = Itemsource.SongLibrary.Where(x => x.Album == content).ToList();

                SongGrid.ItemsSource = album;
                if (Mplayer.HasAudio)
                {
                    GetAlbumart(_selectedSong);
                }
                else
                {
                    SongGrid.SelectedIndex = 0;
                    _selectedSong          = SongGrid.SelectedItem as Itemsource.Songs;
                    GetAlbumart(_selectedSong);
                }
                if (_selectedSong != null && !Mplayer.HasAudio)
                {
                    NowPlayingAlbum.Text   = content;
                    NowPlayingTrack.Text   = _selectedSong.Track;
                    NowPlayingSong.Content = _selectedSong.Name + " - " + _selectedSong.Artist;
                }
            }
            ScrollViewer.Visibility = Visibility.Hidden;
            SongGrid.Visibility     = Visibility.Visible;
            SearchBox.Visibility    = Visibility.Visible;
        }
Beispiel #5
0
        private void GetAlbumart(Itemsource.Songs song)
        {
            if (song != null)
            {
                var tagFile = File.Create(song.FileName);
                try
                {
                    var pic = tagFile.Tag.Pictures[0];
                    var ms  = new MemoryStream(pic.Data.Data);
                    ms.Seek(0, SeekOrigin.Begin);

                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = ms;
                    bitmap.EndInit();

                    var img = new Image {
                        Source = bitmap
                    };
                    AlbumArt.Source        = img.Source;
                    BrightenArt.ToolTip    = tagFile.Tag.Album;
                    Placeholder.Visibility = Visibility.Hidden;
                }
                catch
                {
                    AlbumArt.Source        = null;
                    BrightenArt.ToolTip    = tagFile.Tag.Album;
                    Placeholder.Visibility = Visibility.Visible;
                }
            }
        }
Beispiel #6
0
        private void Next()
        {
            if (_shuffleSongs)
            {
                SongGrid.SelectedIndex = _rnd.Next(0, SongGrid.Items.Count);
            }
            else
            {
                SongGrid.SelectedIndex = SongGrid.SelectedIndex + 1;
            }

            _selectedSong = SongGrid.SelectedItem as Itemsource.Songs;

            if (_selectedSong != null)
            {
                PlaySong(_selectedSong);
            }
        }
        private void SongGrid_OnLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            _selectedSong = SongGrid.CurrentItem as Itemsource.Songs;

              if (SongGrid.ItemsSource != null && _selectedSong != null) //&& selectedSong.FileName != _currentSong
              {
            Mplayer.Open(new Uri(_selectedSong.FileName));
            Mplayer.Play();
            Console.WriteLine(_selectedSong.FileName);
            _audioPlaying = true;
            GetAlbumart();

            if (_selectedSong.Name == null)
              NowPlayingSong.Content = _selectedSong.AltName + " - " + _selectedSong.Artist;
            else
              NowPlayingSong.Content = _selectedSong.Name + " - " + _selectedSong.Artist;

            NowPlayingAlbum.Text = _selectedSong.Album;
            NowPlayingTrack.Text = _selectedSong.Track;
            PlayPause.OpacityMask = new VisualBrush {Visual = (Visual) FindResource("Pause")};
              }
        }
        private void Previous()
        {
            if (SongGrid.SelectedIndex != 0)
              {
            if (Mplayer.Position.TotalSeconds > 3)
              SongGrid.SelectedIndex = SongGrid.SelectedIndex;
            else
              SongGrid.SelectedIndex = SongGrid.SelectedIndex - 1;

            _selectedSong = SongGrid.SelectedItem as Itemsource.Songs;

            if (_selectedSong != null)
            {
              Mplayer.Open(new Uri(_selectedSong.FileName));
              Mplayer.Play();
              GetAlbumart();
              PlayPause.OpacityMask = new VisualBrush {Visual = (Visual) FindResource("Pause")};

              _audioPlaying = true;
              NowPlayingSong.Content = _selectedSong.Name + " - " + _selectedSong.Artist;
              NowPlayingAlbum.Text = _selectedSong.Album;
              NowPlayingTrack.Text = _selectedSong.Track;
            }
              }
        }
        private void Play()
        {
            if (Mplayer.Source == null && _shuffleSongs == false)
              {
            SongGrid.SelectedIndex = 0;
            _selectedSong = SongGrid.SelectedItem as Itemsource.Songs;

            if (_selectedSong != null)
            {
              Mplayer.Open(new Uri(_selectedSong.FileName));
              Console.WriteLine(_selectedSong.FileName);
              Mplayer.Play();
              PlayPause.OpacityMask = new VisualBrush {Visual = (Visual) FindResource("Pause")};

              _audioPlaying = true;
              GetAlbumart();
              if (_selectedSong.Name == null)
            NowPlayingSong.Content = _selectedSong.AltName + " - " + _selectedSong.Artist;
              else
            NowPlayingSong.Content = _selectedSong.Name + " - " + _selectedSong.Artist;
              NowPlayingAlbum.Text = _selectedSong.Album;
              NowPlayingTrack.Text = _selectedSong.Track;
            }
              }
              else if (Mplayer.Source == null && _shuffleSongs)
              {
            SongGrid.SelectedIndex = _rnd.Next(0, SongGrid.Items.Count);
            _selectedSong = SongGrid.SelectedItem as Itemsource.Songs;

            if (_selectedSong != null)
            {
              Mplayer.Open(new Uri(_selectedSong.FileName));
              Mplayer.Play();
              PlayPause.OpacityMask = new VisualBrush {Visual = (Visual) FindResource("Pause")};

              _audioPlaying = true;
              GetAlbumart();
              NowPlayingSong.Content = _selectedSong.Name + " - " + _selectedSong.Artist;
              NowPlayingAlbum.Text = _selectedSong.Album;
              NowPlayingTrack.Text = _selectedSong.Track;
            }
              }
              else if (_audioPlaying)
              {
            Mplayer.Pause();
            PlayPause.OpacityMask = new VisualBrush {Visual = (Visual) FindResource("Play")};
            _audioPlaying = false;
              }
              else
              {
            Mplayer.Play();
            PlayPause.OpacityMask = new VisualBrush {Visual = (Visual) FindResource("Pause")};
            _audioPlaying = true;
              }
        }
Beispiel #10
0
        private void GetAlbumart()
        {
            if (_selectedSong == null)
            _selectedSong = SongGrid.SelectedItem as Itemsource.Songs;

              if (_selectedSong != null)
              {
            var tagFile = File.Create(_selectedSong.FileName);
            try
            {
              var pic = tagFile.Tag.Pictures[0];
              var ms = new MemoryStream(pic.Data.Data);
              ms.Seek(0, SeekOrigin.Begin);

              var bitmap = new BitmapImage();
              bitmap.BeginInit();
              bitmap.StreamSource = ms;
              bitmap.EndInit();

              var img = new Image {Source = bitmap};
              AlbumArt.Source = img.Source;
              AlbumArt.ToolTip = tagFile.Tag.Album;
              Placeholder.Visibility = Visibility.Hidden;
            }
            catch
            {
              AlbumArt.Source = null;
              AlbumArtToolTip.ToolTip = tagFile.Tag.Album;
              Placeholder.Visibility = Visibility.Visible;
            }
              }
        }
Beispiel #11
0
        private void Album_OnClick(object sender, RoutedEventArgs e)
        {
            var tile = sender as Tile;
              if (tile != null)
              {
            var content = tile.Title;
            var album = Itemsource.SongLibrary.Where(x => x.Album == content).ToList();

            SongGrid.ItemsSource = album;
            if (Mplayer.HasAudio)
            {
              GetAlbumart();
            }
            else
            {
              SongGrid.SelectedIndex = 0;
              _selectedSong = SongGrid.SelectedItem as Itemsource.Songs;
              GetAlbumart();
            }
            if (_selectedSong != null && !Mplayer.HasAudio)
            {
              NowPlayingAlbum.Text = content;
              NowPlayingTrack.Text = _selectedSong.Track;
              NowPlayingSong.Content = _selectedSong.Name + " - " + _selectedSong.Artist;
            }
              }
              ScrollViewer.Visibility = Visibility.Hidden;
              SongGrid.Visibility = Visibility.Visible;
        }
Beispiel #12
0
 private void SongGrid_OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     _selectedSong = ((FrameworkElement)e.OriginalSource).DataContext as Itemsource.Songs;
     PlaySong(_selectedSong);
 }