private static List <SongEx> GetActualSongList() { var list = new List <SongEx>(); MediaLibrary lib = new MediaLibrary(); if (lib != null) { uint hMediaList = InteropSvc.InteropLib.Instance.ZMediaLibrary_GetSongs(); int count = lib.Songs.Count; for (int x = 0; x < count; x++) { var song = lib.Songs[x]; if (!song.IsProtected) { var songEx = new SongEx(song); uint hash = InteropSvc.InteropLib.Instance.ZMediaList_GetHash(hMediaList, x); string hashStr = String.Format("{0:X}", hash).PadLeft(8, '0'); string path = "\\My Documents\\Zune\\Content\\" + hashStr.Substring(0, 4) + "\\" + hashStr.Substring(4, 2) + "\\" + hashStr.Substring(6, 2); if (InteropSvc.InteropLib.Instance.GetFileAttributes7(path + ".mp3") != 0xFFFFFFFFU) { path += ".mp3"; } else { path += ".wma"; } songEx.FilePath = path; list.Add(songEx); } } InteropSvc.InteropLib.Instance.ZMediaList_Release(hMediaList); lib.Dispose(); list.Sort(new SongExComparer()); } return(list); }
string CutTheSong(SongEx song, int start, int end) { if (song.FilePath.ToLower().EndsWith(".mp3")) { if (InteropSvc.InteropLib.Instance.GetFileAttributes7("\\Applications\\Data\\9cefc0bf-7060-45b0-ba66-2d1dcad8dc3c\\Data\\IsolatedStore\\Song.mp3") != 0xFFFFFFFF) { InteropSvc.InteropLib.Instance.MoveFile7("\\Applications\\Data\\9cefc0bf-7060-45b0-ba66-2d1dcad8dc3c\\Data\\IsolatedStore\\Song.mp3", "\\Applications\\Data\\9cefc0bf-7060-45b0-ba66-2d1dcad8dc3c\\Data\\IsolatedStore\\Song2.mp3"); InteropSvc.InteropLib.Instance.DeleteFile7("\\Applications\\Data\\9cefc0bf-7060-45b0-ba66-2d1dcad8dc3c\\Data\\IsolatedStore\\Song2.mp3"); } bool res = InteropSvc.InteropLib.Instance.CopyFile7(song.FilePath, "\\Applications\\Data\\9cefc0bf-7060-45b0-ba66-2d1dcad8dc3c\\Data\\IsolatedStore\\Song.mp3", false); if (res) { SplitMp3("Song.mp3", "SongNew.mp3", start, end); return("\\Applications\\Data\\9cefc0bf-7060-45b0-ba66-2d1dcad8dc3c\\Data\\IsolatedStore\\SongNew.mp3"); } return(null); } else { return(song.FilePath); } }