private List <ListItemSong> FillSongsFolders() { List <ListItemSong> list = new List <ListItemSong>(); ListItemSong listItemSong = null; RestoreSongsList(); List <string> paths = ListItemsRecycler.Select(a => a.Value.getSongPath()).ToList(); paths = paths.Distinct().ToList(); for (int i = 0; i < paths.Count; i++) { string path = paths[i]; string parentPathName = GetFolderNameFromPath(path); try { string songsCount = ListItemsRecycler.Count(a => a.Value.getSongPath() == path).ToString() + " " + "שירים"; listItemSong = new ListItemSong(); listItemSong.setSongName(parentPathName); // First line listItemSong.setArtist(songsCount.ToString()); // Second line - Song count listItemSong.setSongPath(path); // Third line list.Add(listItemSong); } catch (Exception ex) { string msg = ex.Message; } } listItemSong = new ListItemSong(); listItemSong.setSongName("כל השירים"); // First line listItemSong.setArtist(ListItemsRecycler.Count.ToString() + " " + "שירים"); // Second line - Song count listItemSong.setSongPath(MUSIC_PATH); // Third line list.Insert(0, listItemSong); return(list); }
private void LoadSongsFilesFromPhone() { //Java.IO.File[] jjj = context.GetExternalFilesDirs("MUSIC"); //Java.IO.File[] mmm = context.GetExternalMediaDirs(); //string zzz = System.Environment.SystemDirectory; //string aaa = System.Environment.CurrentDirectory; //string bbb = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonMusic); //string fff = System.IO.Directory.GetCurrentDirectory(); //string hjhj = LOG_FILE_PATH = System.IO.Directory.GetCurrentDirectory(); //Java.IO.File hdhd = Android.OS.Environment.DataDirectory; //string folderNameDocuments = Android.OS.Environment.DirectoryDocuments; //Java.IO.File externalPath = Android.OS.Environment.ExternalStorageDirectory; string folderBackup = Android.OS.Environment.DirectoryMusic; // "ProjTaskReminder" ////MUSIC_PATH = Android.OS.Environment.GetExternalStoragePublicDirectory(folderBackup).AbsolutePath; lblSongName.Text = "טוען שירים ..."; MH_Utils.Utils.GetFolderFiles(MUSIC_PATH, "*.mp3", true, "*.jpg"); lblSongName.Text = ""; ListItemsPath = MH_Utils.Utils.FilesExtra; if (ListItemsPath == null) { return; } ListItemsRecycler = new List <KeyValuePair <string, ListItemSong> >(); for (int i = 0; i < ListItemsPath.Count; i++) { string fileFullName = ListItemsPath[i].Key; string path = Directory.GetParent(fileFullName).FullName; string fileName = fileFullName.Substring(path.Length + 1); string artist = "Artist " + (i + 1).ToString(); string album = Directory.GetParent(fileFullName).Name; // GetFolderNameFromPath(path); fileName = MH_Utils.Utils.FixSongName(fileName); fileName = fileName.Substring(0, fileName.Length - 4); int pos = fileName.IndexOf("-"); if (pos > -1) { if (pos < 4) { artist = album; } else { artist = fileName.Substring(0, pos - 1); } } ListItemSong listItemSong = new ListItemSong(fileName, artist, album); listItemSong.setSongPath(path); listItemSong.setSongPathFull(fileFullName); ListItemsRecycler.Add(new KeyValuePair <string, ListItemSong>(fileFullName, listItemSong)); } ListItemsPath = ListItemsPath.OrderBy(a => a.Key).ToList(); ListItemsRecycler = ListItemsRecycler.OrderBy(a => a.Key).ToList(); BackupSongList(); }