private static T GetTrackValue <T>(ZuneQueryItem item, string fieldName) { var result = item.GetFieldValue(typeof(T), (uint)ZuneQueryList.AtomNameToAtom(fieldName)); if (result != null) { return((T)result); } return(default(T)); }
public void RemoveAlbumFromDatabase(int albumId) { ZuneQueryList zuneQueryList = _zuneLibrary.GetTracksByAlbum(0, albumId, EQuerySortType.eQuerySortOrderAscending, (uint)SchemaMap.kiIndex_AlbumID); for (int i = 0; i < zuneQueryList.Count; i++) { var track = new ZuneQueryItem(zuneQueryList, i); //TODO: see if we can delete the actual album _zuneLibrary.DeleteMedia(new[] { track.ID }, EMediaTypes.eMediaTypeAudio, false); } _zuneLibrary.CleanupTransientMedia(); zuneQueryList.Dispose(); }
public IEnumerable <DbTrack> GetTracksForAlbum(int albumId) { ZuneQueryList zuneQueryList = _zuneLibrary.GetTracksByAlbum(0, albumId, EQuerySortType.eQuerySortOrderAscending, (uint)SchemaMap.kiIndex_AlbumID); for (int i = 0; i < zuneQueryList.Count; i++) { var track = new ZuneQueryItem(zuneQueryList, i); //for (int j = 0; j < 2000; j++) //{ // try // { // var test = track.GetFieldValue(typeof(long), (uint)j); // if (test != null) // { // Trace.WriteLine(ZuneQueryList.AtomToAtomName(j)); // Trace.WriteLine(test); // } // } // catch (Exception ex) // { // Trace.WriteLine("FAILED ON"); // } //} yield return(new DbTrack { FilePath = GetTrackValue <string>(track, "SourceURL"), MediaId = GetTrackValue <Guid>(track, "ZuneMediaID"), Title = GetTrackValue <string>(track, "Title"), TrackNumber = GetTrackValue <long>(track, "WM/TrackNumber").ToString() }); } zuneQueryList.Dispose(); }