Beispiel #1
0
        private void song_list_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            /*var s = song_list.SelectedItem as Songs;
             * string path = Mp3Info.GetFilePath(s.Title, recievedAlbum,0);
             * (App.Current as App).nowPlaying_path = path;
             * nowPlaying_Page page = new nowPlaying_Page(false);
             * NavigationService.Navigate(page);
             */
            List <string> paths = new List <string>();

            foreach (var item in song_list.Items)
            {
                var s = item as Songs;
                paths.Add(Mp3Info.GetFilePath(s.Title, recievedAlbum, 0));
            }
            if ((App.Current as App).paths != null)
            {
                (App.Current as App).paths.Clear();
            }
            (App.Current as App).paths      = paths;
            (App.Current as App).startIndex = song_list.SelectedIndex;
            nowPlaying_Page page = new nowPlaying_Page(true);

            NavigationService.Navigate(page);
        }
Beispiel #2
0
        private void AlbumList_Play_Click(object sender, MouseButtonEventArgs e)
        {
            var              s          = album_list.SelectedItem as Albums;
            string           album      = s.Album;
            List <string>    paths      = new List <string>();
            SQLiteConnection connection = new SQLiteConnection("Data Source=database.db;Version=3;New=False;Compress=True;");

            connection.Open();
            SQLiteCommand command = connection.CreateCommand();

            command.CommandText = "select Title, duration from music where album='" + album + "';";
            SQLiteDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                string title = reader.GetString(0);
                paths.Add(Mp3Info.GetFilePath(title));
            }
            if ((App.Current as App).paths != null)
            {
                (App.Current as App).paths.Clear();
            }
            (App.Current as App).paths      = paths;
            (App.Current as App).startIndex = 0;
            nowPlaying_Page page = new nowPlaying_Page(true);

            NavigationService.Navigate(page);
        }
Beispiel #3
0
 private void Page_load(object sender, RoutedEventArgs e)
 {
     Album_label.Content  = recievedAlbum;
     Artist_label.Content = recievedArtist;
     try
     {
         string path = Mp3Info.GetFilePath(recievedAlbum, 0);
         AlbumArt.Source = Mp3Info.GetAlbumArt(path);
     }
     catch { }
     loadSongs();
 }
Beispiel #4
0
        private void loadAlbums()
        {
            List <Albums> list = new List <Albums>();

            SQLiteConnection connection = new SQLiteConnection("Data Source=database.db;Version=3;New=False;Compress=True;");

            connection.Open();
            SQLiteCommand command = connection.CreateCommand();

            command.CommandText = "select Album, artist, year from music group by Album";
            SQLiteDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Albums album = new Albums();
                album.Album  = reader.GetString(0);
                album.Artist = reader.GetString(1);
                try
                {
                    album.image = Mp3Info.GetAlbumArt(Mp3Info.GetFilePath(album.Album, 0));
                }
                catch
                {
                    BitmapImage i = new BitmapImage(new Uri("music-album.png", UriKind.Relative));
                }
                list.Add(album);
            }
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(() =>
                {
                    album_list.ItemsSource = list;
                    //CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(album_list.ItemsSource);
                    //view.SortDescriptions.Add(new SortDescription("Album", ListSortDirection.Ascending));
                });
                return;
            }
            else
            {
                album_list.ItemsSource = list;
                //CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(album_list.ItemsSource);
                //view.SortDescriptions.Add(new SortDescription("Album", ListSortDirection.Ascending));
            }

            connection.Close();
        }
Beispiel #5
0
        private void loadSongs()
        {
            List <Songs> list = new List <Songs>();

            foreach (var item in (App.Current as App).paths)
            {
                Mp3Info info     = new Mp3Info(item);
                string  duration = new TimeSpan(0, 0, info.Duration).ToString(@"mm\:ss");
                list.Add(new Songs()
                {
                    Title = info.Title, Duration = duration
                });
            }
            //if (song_list.ItemsSource != null)
            //    song_list.ItemsSource = null;
            song_list.Items.Clear();
            song_list.ItemsSource   = list;
            song_list.SelectedIndex = (App.Current as App).playlist.PlayIndex;
        }
Beispiel #6
0
 private void searchEntry_TextBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (searchEntry_TextBox.SelectedIndex >= 0)
     {
         string title = searchEntry_TextBox.SelectedItem.ToString();
         string path  = Mp3Info.GetFilePath(title);
         //(App.Current as App).paths.Clear();
         (App.Current as App).paths = new List <string>();
         (App.Current as App).paths.Add(path);
         (App.Current as App).startIndex = 0;
         //(App.Current as App).nowPlaying_path = path;
         nowPlaying_Page page = new nowPlaying_Page(true);
         NavigationService.Navigate(page);
         searchEntry_TextBox.Text = "";
     }
     else
     {
         //searchEntry_TextBox.Items.Clear();
         searchEntry_TextBox.IsDropDownOpen = false;
     }
 }
Beispiel #7
0
        public void createDatabase()
        {
            var fileList = listAllFilePaths();

            //creating log file for all music file paths
            File.WriteAllLines("files.mus", fileList);

            //creating database using sqlite
            SQLiteConnection connection = new SQLiteConnection("Data Source=database_temp.db;Version=3;New=True;Compress=False;");

            connection.Open();
            SQLiteCommand command = connection.CreateCommand();

            //creating table
            command.CommandText = "CREATE TABLE music (id integer , Title varchar(30),Album varchar(30),Artist varchar(30),Genre varchar(30),duration integer, year varchar(5))";
            command.ExecuteNonQuery();
            //inserting file information
            int i = 0;

            foreach (var file in fileList)
            {
                try
                {
                    Mp3Info info = new Mp3Info(file);
                    command.CommandText = "INSERT INTO music VALUES (" + i + ",'" + info.Title + "', '" + info.Album + "', '" + info.Artist + "', '" + info.Genre + "', " + info.Duration + ", " + info.Year.ToString() + ");";
                    command.ExecuteNonQuery();
                }
                catch { }
                i++;
            }
            connection.Close();
            //replacing original data file with temporary file (newly created)
            if (File.Exists("database.db"))
            {
                File.Delete("database.db");
            }
            File.Move("database_temp.db", "database.db");
        }
Beispiel #8
0
        private void init(string path)
        {
            song_list.SelectedIndex = (App.Current as App).playlist.PlayIndex;
            song = TagLib.File.Create(path);
            nowPlaying_Title.Content  = song.Tag.Title;
            nowPlaying_Artist.Content = song.Tag.FirstAlbumArtist + " | " + song.Tag.Album;
            timeSpan_Label.Content    = song.Properties.Duration.ToString(@"mm\:ss");
            //progress bar setup
            timeElapsed_progressBar.Maximum = (int)song.Properties.Duration.TotalSeconds;
            timeElapsed_progressBar.Minimum = timeElapsed_progressBar.Value = 0;
            //starting timer
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += timer_Tick;
            timer.Start();
            try
            {
                nowPlaying_AlbumArt.Source = Background_image.Source = Mp3Info.GetAlbumArt(path);
            }
            catch { }
            (App.Current as App).player.Volume = volume_Slider.Value;

            //getting lyrics
            try
            {
                //AzLyrics lyrics = new AzLyrics(song.Tag.FirstAlbumArtist, song.Tag.Title);
                //Lyrics_textBlock.Text = lyrics.GetLyris();
                LyricsWikia lyrics = new LyricsWikia(song.Tag.FirstAlbumArtist, song.Tag.Title);
                Lyrics_textBlock.Text = lyrics.GetLyris();
            }
            catch (System.Net.WebException)
            {
                Lyrics_textBlock.Text = "Lyrics not found!";
            }
            catch (Exception ex)
            {
                Lyrics_textBlock.Text = ex.ToString();
            }
        }
Beispiel #9
0
 public PlaylistEventArgs(string path)
 {
     info = new Mp3Info(path);
     Path = path;
 }