Пример #1
0
 public static Guid GetMediaGuidForLibraryId(int id, MediaType type)
 {
     if (type == MediaType.PodcastEpisode)
     {
         id = PlaylistManager.GetFieldValue(id, PlaylistManager.MediaTypeToListType(type), 311, 0);
     }
     return(PlaylistManager.GetFieldValue(id, PlaylistManager.MediaTypeToListType(type), 451, Guid.Empty));
 }
 public LibraryPlaybackTrack(
     int mediaId,
     MediaType mediaType,
     ContainerPlayMarker containerPlayMarker)
 {
     this._mediaId             = mediaId;
     this._mediaType           = mediaType;
     this._listType            = PlaylistManager.MediaTypeToListType(mediaType);
     this._containerPlayMarker = containerPlayMarker;
     ThreadPool.QueueUserWorkItem(args =>
     {
         this._isInCollection = PlaylistManager.IsInCollection(this._mediaId, this._mediaType);
         Application.DeferredInvoke(delegate
         {
             this.RatingChanged.Invoke();
         }, null);
     }, null);
 }
Пример #3
0
 public void AddToCollection(IList items)
 {
     ZuneApplication.Service.Download(items, EDownloadFlags.Subscription, null, this.ClientContextEvent, this.ClientContextEventValue, new DownloadEventHandler(this.OnDownloadEvent), new DownloadEventProgressHandler(this.OnDownloadProgressEvent), new EventHandler(this.OnAllPending));
     foreach (object obj in items)
     {
         if (obj is DataProviderObject)
         {
             DataProviderObject dataProviderObject = (DataProviderObject)obj;
             if (dataProviderObject.TypeName == "PlaylistContentItem")
             {
                 PlaylistManager.GetPlaylistId((int)dataProviderObject.GetProperty("LibraryId"));
                 UsageDataService.ReportTrackAddToCollection((Guid)dataProviderObject.GetProperty("ZuneMediaId"), PlaylistManager.GetFieldValue((int)dataProviderObject.GetProperty("MediaId"), EListType.eTrackList, 358, 0).ToString());
             }
             else if (dataProviderObject is Track)
             {
                 Track track = (Track)dataProviderObject;
                 UsageDataService.ReportTrackAddToCollection(track.Id, track.ReferrerContext);
             }
         }
     }
 }
        public override HRESULT GetURI(out string uri)
        {
            string  uriOut  = null;
            HRESULT hresult = HRESULT._S_OK;

            Microsoft.Zune.Service.EContentType eContentType;
            if (PlaylistManager.GetFieldValue(this._mediaId, this._listType, 177, -1) == 43)
            {
                eContentType = Microsoft.Zune.Service.EContentType.Video;
            }
            else
            {
                eContentType = Microsoft.Zune.Service.EContentType.MusicTrack;
                uriOut       = PlaylistManager.GetFieldValue(this._mediaId, this._listType, 317, (string)null);
                if (!string.IsNullOrEmpty(uriOut))
                {
                    try
                    {
                        if (new Uri(uriOut).Scheme == Uri.UriSchemeFile)
                        {
                            if (!ZuneLibrary.DoesFileExist(uriOut))
                            {
                                uriOut = null;
                            }
                        }
                    }
                    catch (UriFormatException ex)
                    {
                    }
                }
            }
            if (string.IsNullOrEmpty(uriOut) && this.ZuneMediaId != Guid.Empty)
            {
                hresult = ZuneApplication.Service.GetContentUri(this.ZuneMediaId, eContentType, Microsoft.Zune.Service.EContentUriFlags.None, out uriOut, out this._zuneMediaInstanceId);
            }
            uri = uriOut;
            return(hresult);
        }
        private static void UpdatePlayedStatesWorker(object o)
        {
            if (!(o is UpdatePlayedStatesTask playedStatesTask))
            {
                return;
            }
            int num1 = 0;
            int num2 = 0;
            int num3 = 0;

            int[]    columnIndexes = new int[7];
            object[] fieldValues   = new object[7];
            if (playedStatesTask.IncrementPlayCount)
            {
                columnIndexes[0] = 367;
                fieldValues[0]   = 0;
                ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                num2             = (int)fieldValues[0];
                columnIndexes[0] = 366;
                fieldValues[0]   = 0;
                ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                num1 = (int)fieldValues[0];
            }
            if (playedStatesTask.IncrementSkipCount)
            {
                columnIndexes[0] = 374;
                fieldValues[0]   = 0;
                ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                num3 = (int)fieldValues[0];
            }
            int cValues = 0;

            if (playedStatesTask.MarkPlayed)
            {
                columnIndexes[cValues] = 262;
                fieldValues[cValues]   = 1;
                ++cValues;
            }
            if (playedStatesTask.IncrementPlayCount)
            {
                int num4 = num2 + 1;
                columnIndexes[cValues] = 367;
                fieldValues[cValues]   = num4;
                int index1 = cValues + 1;
                int num5   = num1 + 1;
                columnIndexes[index1] = 366;
                fieldValues[index1]   = num5;
                int index2 = index1 + 1;
                columnIndexes[index2] = 363;
                fieldValues[index2]   = DateTime.UtcNow;
                cValues = index2 + 1;
            }
            if (playedStatesTask.IncrementSkipCount)
            {
                int num4 = num3 + 1;
                columnIndexes[cValues] = 374;
                fieldValues[cValues]   = num4;
                int index = cValues + 1;
                columnIndexes[index] = 365;
                fieldValues[index]   = DateTime.UtcNow;
                cValues = index + 1;
            }
            if (cValues > 0)
            {
                ZuneLibrary.SetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, cValues, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
            }
            if (!playedStatesTask.IncrementPlayCount || playedStatesTask.ContainerPlayMarker == null)
            {
                return;
            }
            bool flag = false;

            lock (playedStatesTask.ContainerPlayMarker)
            {
                if (!playedStatesTask.ContainerPlayMarker.Marked)
                {
                    playedStatesTask.ContainerPlayMarker.Marked = true;
                    flag = true;
                }
            }
            if (!flag)
            {
                return;
            }
            if (playedStatesTask.ContainerPlayMarker.LibraryId == -1 && playedStatesTask.ListType == EListType.eTrackList)
            {
                fieldValues[0] = -1;
                if (playedStatesTask.ContainerPlayMarker.MediaType == MediaType.Album)
                {
                    columnIndexes[0] = 11;
                    ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                    playedStatesTask.ContainerPlayMarker.LibraryId = (int)fieldValues[0];
                }
                else if (playedStatesTask.ContainerPlayMarker.MediaType == MediaType.Genre)
                {
                    columnIndexes[0] = 399;
                    ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                    playedStatesTask.ContainerPlayMarker.LibraryId = (int)fieldValues[0];
                }
                else if (playedStatesTask.ContainerPlayMarker.MediaType == MediaType.Artist)
                {
                    columnIndexes[0] = 11;
                    ZuneLibrary.GetFieldValues(playedStatesTask.MediaID, playedStatesTask.ListType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                    int iMediaId = (int)fieldValues[0];
                    fieldValues[0]   = -1;
                    columnIndexes[0] = 78;
                    ZuneLibrary.GetFieldValues(iMediaId, EListType.eAlbumList, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
                    playedStatesTask.ContainerPlayMarker.LibraryId = (int)fieldValues[0];
                }
            }
            if (playedStatesTask.ContainerPlayMarker.LibraryId == -1)
            {
                return;
            }
            columnIndexes[0] = 363;
            fieldValues[0]   = DateTime.UtcNow;
            EListType listType = PlaylistManager.MediaTypeToListType(playedStatesTask.ContainerPlayMarker.MediaType);

            ZuneLibrary.SetFieldValues(playedStatesTask.ContainerPlayMarker.LibraryId, listType, 1, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
        }
Пример #6
0
 public static Guid GetZuneMediaId(MediaType type, int libraryId) => PlaylistManager.GetFieldValue(libraryId, PlaylistManager.MediaTypeToListType(type), 233, Guid.Empty);
Пример #7
0
 public static Guid GetServiceId(int mediaId) => PlaylistManager.GetFieldValue(mediaId, EListType.eTrackList, 451, Guid.Empty);
Пример #8
0
 public static void SetGenreHelper(DataProviderObject item, string genre) => PlaylistManager.SetFieldValue((int)item.GetProperty("LibraryId"), EListType.eTrackList, 398, genre);
Пример #9
0
 public static string GetEpisodeUrlForLibraryId(int id) => PlaylistManager.GetFieldValue(id, PlaylistManager.MediaTypeToListType(MediaType.PodcastEpisode), 317, string.Empty);