public bool LoadPlaylist()
        {
            IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>();
            IContentDirectory        cd  = scm.ContentDirectory;

            if (cd == null)
            {
                ShowServerNotConnectedDialog();
                return(false);
            }
            PlaylistRawData playlistData = cd.ExportPlaylist(_playlistId);

            _mediaItems = cd.LoadCustomPlaylist(playlistData.MediaItemIds, Consts.NECESSARY_AUDIO_MIAS, Consts.EMPTY_GUID_ENUMERATION);
            return(true);
        }
        public void LoadPlaylist()
        {
            IDialogManager dialogManager = ServiceRegistration.Get <IDialogManager>();

            if (_playlist == null)
            {
                dialogManager.ShowDialog(SkinBase.General.Consts.RES_SYSTEM_ERROR, Consts.RES_PLAYLIST_LOAD_NO_PLAYLIST, DialogType.OkDialog, false, null);
                return;
            }
            IContentDirectory cd     = ServiceRegistration.Get <IServerConnectionManager>().ContentDirectory;
            AVType?           avType = ConvertPlaylistTypeToAVType(_playlist.PlaylistType);

            if (cd == null || !avType.HasValue)
            {
                dialogManager.ShowDialog(SkinBase.General.Consts.RES_SYSTEM_ERROR, Consts.RES_PLAYLIST_LOAD_ERROR_LOADING, DialogType.OkDialog, false, null);
                return;
            }
            Guid[] necessaryMIATypes = new Guid[]
            {
                ProviderResourceAspect.ASPECT_ID,
                MediaAspect.ASPECT_ID,
            };
            Guid[] optionalMIATypes = new Guid[]
            {
                AudioAspect.ASPECT_ID,
                VideoAspect.ASPECT_ID,
                ImageAspect.ASPECT_ID,
            };
            // Big playlists cannot be loaded in one single step. We have several problems if we try to do so:
            // 1) Loading the playlist at once at the server results in one huge SQL IN statement which might break the SQL engine
            // 2) The time to load the playlist might lead the UPnP call to break because of the timeout when calling methods
            // 3) The resulting UPnP XML document might be too big to fit into memory

            // For that reason, we load the playlist in two steps:
            // 1) Load media item ids in the playlist
            // 2) Load media items in clusters - for each cluster, an own query will be executed at the content directory
            PlaylistRawData playlistData = cd.ExportPlaylist(_playlist.PlaylistId);

            PlayItemsModel.CheckQueryPlayAction(() => CollectionUtils.Cluster(playlistData.MediaItemIds, 1000).SelectMany(itemIds =>
                                                                                                                          cd.LoadCustomPlaylist(itemIds, necessaryMIATypes, optionalMIATypes)), avType.Value);
        }