Esempio n. 1
0
        public static void Populate(object dataContainer, int libraryId)
        {
            DataProviderObject dataProviderObject = (DataProviderObject)dataContainer;

            object[] fieldValues = new object[15]
            {
                string.Empty,
                TimeSpan.Zero,
                0,
                0,
                string.Empty,
                string.Empty,
                string.Empty,
                0,
                0,
                string.Empty,
                0L,
                string.Empty,
                0,
                0,
                Guid.Empty
            };
            ZuneLibrary.GetFieldValues(libraryId, EListType.eVideoList, ColumnIndexes.Length, ColumnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
            for (int index = 0; index < ColumnIndexes.Length; ++index)
            {
                if (ColumnIndexes[index] == 177)
                {
                    dataProviderObject.SetProperty("MediaType", MediaDescriptions.Map((MediaType)fieldValues[index]));
                }
                dataProviderObject.SetProperty(DataProperties[index], fieldValues[index]);
            }
        }
        private static T GetFieldValue <T>(int mediaId, EListType listType, int atom, T defaultValue)
        {
            int[]    columnIndexes = new int[] { atom };
            object[] fieldValues   = new object[] { defaultValue };
            ZuneLibrary.GetFieldValues(mediaId, listType, 1, columnIndexes, fieldValues,
                                       new QueryPropertyBag());

            return((T)fieldValues[0]);
        }
Esempio n. 3
0
        public static void Populate(object dataContainer, int libraryId)
        {
            DataProviderObject dataProviderObject = (DataProviderObject)dataContainer;

            object[] fieldValues   = (object[])DefaultFieldValues.Clone();
            bool[]   isEmptyValues = new bool[fieldValues.Length];
            ZuneLibrary.GetFieldValues(libraryId, EListType.eAppList, ColumnIndices.Length, ColumnIndices, fieldValues, isEmptyValues, PlaylistManager.Instance.QueryContext);
            for (int index = 0; index < ColumnIndices.Length; ++index)
            {
                dataProviderObject.SetProperty(DataProperties[index], fieldValues[index]);
            }
        }
Esempio n. 4
0
        public static void Populate(object dataContainer, int libraryId)
        {
            DataProviderObject dataProviderObject = (DataProviderObject)dataContainer;

            object[] fieldValues = new object[19]
            {
                string.Empty,
                TimeSpan.Zero,
                0,
                0,
                string.Empty,
                string.Empty,
                string.Empty,
                new ArrayList(),
                string.Empty,
                string.Empty,
                DateTime.MinValue,
                0,
                0,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                0L,
                string.Empty
            };
            bool[] isEmptyValues = new bool[fieldValues.Length];
            ZuneLibrary.GetFieldValues(libraryId, EListType.eTrackList, ColumnIndexes.Length, ColumnIndexes, fieldValues, isEmptyValues, PlaylistManager.Instance.QueryContext);
            for (int index = 0; index < ColumnIndexes.Length; ++index)
            {
                if (ColumnIndexes[index] == 177)
                {
                    fieldValues[index] = MediaDescriptions.Map((MediaType)fieldValues[index]);
                }
                dataProviderObject.SetProperty(DataProperties[index], fieldValues[index]);
            }
        }
        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);
        }
Esempio n. 6
0
 public LibraryAlbumInfo(
     LibraryPlaybackTrack track,
     int thumbnailMaxWidth,
     int thumbnailMaxHeight,
     ICommand onAsyncUpdateAlbumArtUrlCompleted)
 {
     this._onAsyncUpdateAlbumArtUrlCompleted = onAsyncUpdateAlbumArtUrlCompleted == null ? new Command(this) : onAsyncUpdateAlbumArtUrlCompleted;
     if (track.MediaType == MediaType.Track)
     {
         this._trackId    = track.MediaId;
         this._trackTitle = track.Title;
         int[] columnIndexes1 = new int[2] {
             11, 78
         };
         object[] fieldValues1 = new object[2]
         {
             -1,
             -1
         };
         ZuneLibrary.GetFieldValues(this._trackId, EListType.eTrackList, columnIndexes1.Length, columnIndexes1, fieldValues1, PlaylistManager.Instance.QueryContext);
         int albumId  = (int)fieldValues1[0];
         int iMediaId = (int)fieldValues1[1];
         if (albumId >= 0)
         {
             int[] columnIndexes2 = new int[2] {
                 382, 451
             };
             object[] fieldValues2 = new object[2];
             ZuneLibrary.GetFieldValues(albumId, EListType.eAlbumList, columnIndexes2.Length, columnIndexes2, fieldValues2, PlaylistManager.Instance.QueryContext);
             this._albumTitle  = (string)fieldValues2[0];
             this._zuneMediaId = GuidHelper.CreateFromString((string)fieldValues2[1]);
             ThreadPool.QueueUserWorkItem(args =>
             {
                 string str = LibraryDataProviderItemBase.GetArtUrl(albumId, "Album", false);
                 if (!string.IsNullOrEmpty(str))
                 {
                     str = "file://" + str;
                 }
                 Application.DeferredInvoke(new DeferredInvokeHandler(this.AsyncUpdateAlbumArtUrl), str);
             }, null);
         }
         if (iMediaId < 0)
         {
             return;
         }
         int[] columnIndexes3 = new int[1] {
             138
         };
         object[] fieldValues3 = new object[1];
         ZuneLibrary.GetFieldValues(iMediaId, EListType.eArtistList, columnIndexes3.Length, columnIndexes3, fieldValues3, PlaylistManager.Instance.QueryContext);
         this._artistName = (string)fieldValues3[0];
     }
     else if (track.MediaType == MediaType.PodcastEpisode)
     {
         this._trackId    = track.MediaId;
         this._trackTitle = track.Title;
         int[] columnIndexes1 = new int[2] {
             311, 24
         };
         object[] fieldValues1 = new object[2]
         {
             -1,
             null
         };
         ZuneLibrary.GetFieldValues(this._trackId, EListType.ePodcastEpisodeList, columnIndexes1.Length, columnIndexes1, fieldValues1, PlaylistManager.Instance.QueryContext);
         int iMediaId = (int)fieldValues1[0];
         this._artistName = (string)fieldValues1[1];
         if (iMediaId < 0)
         {
             return;
         }
         int[] columnIndexes2 = new int[2] {
             344, 17
         };
         object[] fieldValues2 = new object[2];
         ZuneLibrary.GetFieldValues(iMediaId, EListType.ePodcastList, columnIndexes2.Length, columnIndexes2, fieldValues2, PlaylistManager.Instance.QueryContext);
         this._albumTitle  = (string)fieldValues2[0];
         this._albumArtUrl = (string)fieldValues2[1];
     }
     else
     {
         if (track.MediaType != MediaType.Video)
         {
             return;
         }
         this._trackId    = track.MediaId;
         this._trackTitle = track.Title;
         int[] columnIndexes = new int[3] {
             380, 382, 312
         };
         object[] fieldValues = new object[3];
         ZuneLibrary.GetFieldValues(this._trackId, EListType.eVideoList, columnIndexes.Length, columnIndexes, fieldValues, PlaylistManager.Instance.QueryContext);
         this._artistName = (string)fieldValues[0];
         this._albumTitle = (string)fieldValues[1];
         if (string.IsNullOrEmpty(this._albumTitle))
         {
             this._albumTitle = (string)fieldValues[2];
         }
         if (Application.RenderingType != RenderingType.GDI)
         {
             return;
         }
         ThreadPool.QueueUserWorkItem(args =>
         {
             string artUrl = LibraryDataProviderItemBase.GetArtUrl(this._trackId, "Video", false);
             if (string.IsNullOrEmpty(artUrl))
             {
                 return;
             }
             Application.DeferredInvoke(new DeferredInvokeHandler(this.AsyncUpdateThumbnailUrl), "file://" + artUrl);
         }, null);
     }
 }