private void PlayAll(bool random = false, VideoInfo startWith = null) { currentPlaylist = new Player.PlayList() { IsPlayAll = true }; currentPlayingItem = null; var videos = (SelectedSite is IChoice && currentState == State.details) ? currentTrailerList.ConvertAll(v => (VideoInfo)v) : currentVideoList; bool startVideoFound = startWith == null; foreach (VideoInfo video in videos) { // when not in details view of a site with details view only include videos that don't have details if (currentState != State.details && SelectedSite is IChoice && video.HasDetails) continue; // filter out by the current filter if (!currentFilter.Matches(video.Title) || FilterOut(video.Title) || FilterOut(video.Description)) continue; if (!string.IsNullOrEmpty(videosVKfilter) && !video.Title.ToLower().Contains(videosVKfilter.ToLower())) continue; if (!startVideoFound && video != startWith) continue; else startVideoFound = true; currentPlaylist.Add(new Player.PlayListItem(video.Title, null) { Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.VideoStream, Video = video, Util = selectedSite is Sites.FavoriteUtil ? OnlineVideoSettings.Instance.SiteUtilsList[(video as FavoriteDbVideoInfo).SiteName] : SelectedSite }); } if (currentPlaylist.Count > 0) { if (random) ((List<PlayListItem>)currentPlaylist).Randomize(); Play_Step1(currentPlaylist[0], true); } }
private void Play_Step2(PlayListItem playItem, List<String> loUrlList, bool goFullScreen, bool skipPlaybackOptionsDialog) { if (playItem.Util.Settings.Player != PlayerType.Browser) Helpers.UriUtils.RemoveInvalidUrls(loUrlList); // if no valid urls were returned show error msg if (loUrlList == null || loUrlList.Count == 0) { GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlg != null) { dlg.Reset(); dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon")); dlg.SetHeading(Translation.Instance.Error); dlg.SetText(Translation.Instance.UnableToPlayVideo); dlg.DoModal(GUIWindowManager.ActiveWindow); } return; } // create playlist entries if more than one url if (loUrlList.Count > 1) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate() { Player.PlayList playbackItems = new Player.PlayList(); foreach (string url in loUrlList) { VideoInfo vi = playItem.Video.CloneForPlaylist(url, url == loUrlList[0]); string url_new = url; if (url == loUrlList[0]) { url_new = SelectedSite.GetPlaylistItemVideoUrl(vi, string.Empty, currentPlaylist != null && currentPlaylist.IsPlayAll); } PlayListItem pli = new PlayListItem(string.Format("{0} - {1} / {2}", playItem.Video.Title, (playbackItems.Count + 1).ToString(), loUrlList.Count), url_new); pli.Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.VideoStream; pli.Video = vi; pli.Util = playItem.Util; pli.ForcedPlayer = playItem.ForcedPlayer; playbackItems.Add(pli); } if (currentPlaylist == null) { currentPlaylist = playbackItems; } else { int currentPlaylistIndex = currentPlayingItem != null ? currentPlaylist.IndexOf(currentPlayingItem) : 0; currentPlaylist.InsertRange(currentPlaylistIndex, playbackItems); } // make the first item the current to be played now playItem = playbackItems[0]; loUrlList = new List<string>(new string[] { playItem.FileName }); return null; }, delegate(bool success, object result) { if (success) Play_Step3(playItem, loUrlList, goFullScreen, skipPlaybackOptionsDialog); else currentPlaylist = null; } , Translation.Instance.GettingPlaybackUrlsForVideo, true); } else { Play_Step3(playItem, loUrlList, goFullScreen, skipPlaybackOptionsDialog); } }