public void ResetToFirstView() { selectedSitesGroup = null; SelectedSite = null; selectedCategory = null; selectedVideo = null; currentVideoList = new List<VideoInfo>(); currentTrailerList = new List<DetailVideoInfo>(); currentNavigationContextSwitch = null; currentPlaylist = null; currentPlayingItem = null; CurrentState = State.groups; }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (Gui2UtilConnector.Instance.IsBusy || BufferingPlayerFactory != null) return; // wait for any background action e.g. dynamic category discovery to finish if (control == GUI_facadeView) { if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { currentFilter.Clear(); GUIPropertyManager.SetProperty("#OnlineVideos.filter", string.Empty); switch (CurrentState) { case State.groups: selectedSitesGroup = GUI_facadeView.SelectedListItem as OnlineVideosGuiListItem; if (selectedSitesGroup.Item is SitesGroup) DisplaySites(); else { SelectedSite = selectedSitesGroup.Item as Sites.SiteUtilBase; DisplayCategories(null, true); } break; case State.sites: if (GUI_facadeView.SelectedListItem.Label == "..") { ShowPreviousMenu(); } else { SelectedSite = (GUI_facadeView.SelectedListItem as OnlineVideosGuiListItem).Item as Sites.SiteUtilBase; DisplayCategories(null, true); } break; case State.categories: if (GUI_facadeView.SelectedListItem.Label == "..") { ShowPreviousMenu(); } else { Category categoryToDisplay = (GUI_facadeView.SelectedListItem as OnlineVideosGuiListItem).Item as Category; if (categoryToDisplay is NextPageCategory) { DisplayCategories_NextPage(categoryToDisplay as NextPageCategory); } else if (categoryToDisplay is Sites.FavoriteUtil.FavoriteCategory) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate() { var favCat = categoryToDisplay as Sites.FavoriteUtil.FavoriteCategory; if (favCat.SiteCategory == null) favCat.DiscoverSiteCategory(); return favCat; }, delegate(bool success, object result) { if (success) { var favCat = result as Sites.FavoriteUtil.FavoriteCategory; if (favCat != null && favCat.SiteCategory != null) { currentNavigationContextSwitch = new NavigationContextSwitch() { ReturnToUtil = SelectedSite, ReturnToCategory = categoryToDisplay.ParentCategory, GoToUtil = favCat.Site, GoToCategory = favCat.SiteCategory, BridgeCategory = favCat }; SelectedSite = currentNavigationContextSwitch.GoToUtil; if (currentNavigationContextSwitch.GoToCategory.HasSubCategories) DisplayCategories(currentNavigationContextSwitch.GoToCategory, true); else DisplayVideos_Category(currentNavigationContextSwitch.GoToCategory, false); } else { GUIDialogNotify dlg_error = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlg_error != null) { dlg_error.Reset(); dlg_error.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon")); dlg_error.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg_error.SetText(string.Format("{0}: {1}", Translation.Instance.Error, Translation.Instance.CategoryNotFound)); dlg_error.DoModal(GUIWindowManager.ActiveWindow); } } } }, Translation.Instance.GettingDynamicCategories, true); } else if (categoryToDisplay.HasSubCategories) { DisplayCategories(categoryToDisplay, true); } else { DisplayVideos_Category(categoryToDisplay, false); } } break; case State.videos: ImageDownloader.StopDownload = true; if (GUI_facadeView.SelectedListItem.Label == "..") { ShowPreviousMenu(); } else if (GUI_facadeView.SelectedListItem.Label == Translation.Instance.NextPage) { DisplayVideos_NextPage(); } else { selectedVideo = (GUI_facadeView.SelectedListItem as OnlineVideosGuiListItem).Item as VideoInfo; if (SelectedSite is IChoice && selectedVideo.HasDetails) { // show details view DisplayDetails(); } else if (SelectedSite is Sites.FavoriteUtil && selectedVideo.HasDetails && (selectedCategory is Sites.FavoriteUtil.FavoriteCategory && (selectedCategory as Sites.FavoriteUtil.FavoriteCategory).Site is IChoice)) { SelectedSite = (selectedCategory as Sites.FavoriteUtil.FavoriteCategory).Site; // show details view DisplayDetails(); } else { //play the video currentPlaylist = null; currentPlayingItem = null; Play_Step1(new PlayListItem(null, null) { Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.VideoStream, Video = selectedVideo, Util = selectedSite is Sites.FavoriteUtil ? OnlineVideoSettings.Instance.SiteUtilsList[(selectedVideo as FavoriteDbVideoInfo).SiteName] : selectedSite }, true); } } break; } } else if (CurrentState == State.videos && !(SelectedSite is IChoice && selectedVideo.HasDetails) && (actionType == Action.ActionType.ACTION_MUSIC_PLAY || actionType == Action.ActionType.ACTION_PLAY)) { VideoInfo videoPressedPlayOn = (GUI_facadeView.SelectedListItem as OnlineVideosGuiListItem).Item as VideoInfo; if (videoPressedPlayOn != null) { ImageDownloader.StopDownload = true; currentFilter.Clear(); GUIPropertyManager.SetProperty("#OnlineVideos.filter", string.Empty); selectedVideo = videoPressedPlayOn; //play the video currentPlaylist = null; currentPlayingItem = null; Play_Step1(new PlayListItem(null, null) { Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.VideoStream, Video = selectedVideo, Util = selectedSite is Sites.FavoriteUtil ? OnlineVideoSettings.Instance.SiteUtilsList[(selectedVideo as FavoriteDbVideoInfo).SiteName] : selectedSite }, true, true); } } else if (CurrentState == State.videos && actionType == Action.ActionType.ACTION_SHOW_INFO) { // toggles showing detailed info about a selectected video - is automatically reset when leaving videos view ExtendedVideoInfo = !ExtendedVideoInfo; } } else if (control == GUI_infoList && CurrentState == State.details && (actionType == Action.ActionType.ACTION_SELECT_ITEM || actionType == Action.ActionType.ACTION_MUSIC_PLAY || actionType == Action.ActionType.ACTION_PLAY)) { ImageDownloader.StopDownload = true; if (GUI_infoList.SelectedListItemIndex == 0) { ShowPreviousMenu(); } else { selectedClipIndex = GUI_infoList.SelectedListItemIndex; //play the video currentPlaylist = null; currentPlayingItem = null; Play_Step1(new PlayListItem(null, null) { Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.VideoStream, Video = (GUI_infoList.SelectedListItem as OnlineVideosGuiListItem).Item as VideoInfo, Util = selectedSite is Sites.FavoriteUtil ? OnlineVideoSettings.Instance.SiteUtilsList[(selectedVideo as FavoriteDbVideoInfo).SiteName] : selectedSite }, true, actionType != Action.ActionType.ACTION_SELECT_ITEM); } } else if (control == GUI_btnViewAs) { ToggleFacadeViewMode(); // store as preferred layout in DB if (SelectedSite != null && PluginConfiguration.Instance.StoreLayoutPerCategory && (currentState == State.categories || currentState == State.videos)) { FavoritesDatabase.Instance.SetPreferredLayout(SelectedSite.Settings.Name, selectedCategory, (int)currentView); } } else if (control == GUI_btnMaxResult) { GUIControl.SelectItemControl(GetID, GUI_btnMaxResult.GetID, GUI_btnMaxResult.SelectedItem); } else if (control == GUI_btnOrderBy) { GUIControl.SelectItemControl(GetID, GUI_btnOrderBy.GetID, GUI_btnOrderBy.SelectedItem); if (CurrentState == State.sites) PluginConfiguration.Instance.siteOrder = (PluginConfiguration.SiteOrder)GUI_btnOrderBy.SelectedItem; } else if (control == GUI_btnTimeFrame) { GUIControl.SelectItemControl(GetID, GUI_btnTimeFrame.GetID, GUI_btnTimeFrame.SelectedItem); } else if (control == GUI_btnUpdate) { GUIControl.UnfocusControl(GetID, GUI_btnUpdate.GetID); switch (CurrentState) { case State.sites: DisplaySites(); break; case State.videos: DisplayVideos_Filter(); break; } } else if (control == GUI_btnSearchCategories) { GUIControl.SelectItemControl(GetID, GUI_btnSearchCategories.GetID, GUI_btnSearchCategories.SelectedItem); } else if (control == GUI_btnSearch) { Display_SearchResults(); } else if (control == GUI_btnEnterPin) { string pin = String.Empty; if (GetUserInputString(ref pin, true)) { if (pin == PluginConfiguration.Instance.pinAgeConfirmation) { OnlineVideoSettings.Instance.AgeConfirmed = true; GUIControl.UnfocusControl(GetID, GUI_btnEnterPin.GetID); if (CurrentState == State.groups) DisplayGroups(); else DisplaySites(); } } } else if (control == GUI_btnCurrentDownloads) { // go to current downloads Sites.SiteUtilBase aSite = null; if (OnlineVideoSettings.Instance.SiteUtilsList.TryGetValue(Translation.Instance.DownloadedVideos, out aSite)) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(delegate() { if (!aSite.Settings.DynamicCategoriesDiscovered) { Log.Instance.Info("Looking for dynamic categories on Site '{0}'", aSite.Settings.Name); int foundCategories = aSite.DiscoverDynamicCategories(); Log.Instance.Info("Found {0} dynamic categories on Site '{1}'", foundCategories, aSite.Settings.Name); } return aSite.Settings.Categories; }, delegate(bool success, object result) { if (success) { Category aCategory = aSite.Settings.Categories.FirstOrDefault(c => c.Name == Translation.Instance.Downloading); if (aCategory != null) { SelectedSite = aSite; selectedCategory = aCategory; DisplayVideos_Category(aCategory, true); } } }, Translation.Instance.GettingDynamicCategories, true); } } base.OnClicked(controlId, control, actionType); }
protected override void OnShowContextMenu() { if (Gui2UtilConnector.Instance.IsBusy || BufferingPlayerFactory != null) return; // wait for any background action e.g. getting next page videos to finish if (CurrentState == State.sites && GetFocusControlId() == GUI_facadeView.GetID) { // handle a site's context menu OnlineVideosGuiListItem selectedItem = GUI_facadeView.SelectedListItem as OnlineVideosGuiListItem; if (selectedItem == null || selectedItem.Item == null) return; // only context menu for items with an object backing them Sites.SiteUtilBase aSite = selectedItem.Item as Sites.SiteUtilBase; if (aSite != null) { selectedSite = SiteUserSettingsDialog.ShowDialog(aSite); selectedItem.Item = selectedSite; } } else if (CurrentState == State.categories && GetFocusControlId() == GUI_facadeView.GetID) { // handle a category's context menu OnlineVideosGuiListItem selectedItem = GUI_facadeView.SelectedListItem as OnlineVideosGuiListItem; if (selectedItem == null || selectedItem.Item == null) return; // only context menu for items with an object backing them Category aCategory = selectedItem.Item as Category; if (aCategory != null && !(aCategory is NextPageCategory)) { GUIDialogMenu dlgCat = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlgCat == null) return; dlgCat.Reset(); dlgCat.SetHeading(Translation.Instance.Actions); List<KeyValuePair<string, Sites.ContextMenuEntry>> dialogOptions = new List<KeyValuePair<string, Sites.ContextMenuEntry>>(); if (!(SelectedSite is Sites.FavoriteUtil)) { if (selectedItem.IsPlayed) { dlgCat.Add(Translation.Instance.RemoveFromFavorites); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>(Translation.Instance.RemoveFromFavorites, null)); } else { dlgCat.Add(Translation.Instance.AddToFavourites); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>(Translation.Instance.AddToFavourites, null)); } } foreach (var entry in SelectedSite.GetContextMenuEntries(aCategory, null)) { dlgCat.Add(entry.DisplayText); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>(entry.DisplayText, entry)); } dlgCat.DoModal(GUIWindowManager.ActiveWindow); if (dlgCat.SelectedId == -1) return; else { var selectedOption = dialogOptions[dlgCat.SelectedId - 1]; if (selectedOption.Value == null) { if (dlgCat.SelectedLabelText == Translation.Instance.AddToFavourites) { bool result = OnlineVideoSettings.Instance.FavDB.AddFavoriteCategory(aCategory, SelectedSite.Settings.Name); if (result) { cachedFavoritedCategoriesOfSelectedSite = default(KeyValuePair<string, List<string>>); selectedItem.IsPlayed = true; selectedItem.PinImage = SiteImageExistenceCache.GetImageForSite(Translation.Instance.Favourites, type: "Icon"); } } else if (dlgCat.SelectedLabelText == Translation.Instance.RemoveFromFavorites) { bool result = OnlineVideoSettings.Instance.FavDB.RemoveFavoriteCategory(SelectedSite.Settings.Name, aCategory.RecursiveName("|")); if (result) { cachedFavoritedCategoriesOfSelectedSite = default(KeyValuePair<string, List<string>>); selectedItem.IsPlayed = false; selectedItem.PinImage = ""; selectedItem.RefreshCoverArt(); } } } else { HandleCustomContextMenuEntry(selectedOption.Value, aCategory, null); } } } } else if ((CurrentState == State.videos && GetFocusControlId() == GUI_facadeView.GetID) || (CurrentState == State.details && GetFocusControlId() == GUI_infoList.GetID)) { // handle a video's context menu int numItemsShown = (CurrentState == State.videos ? GUI_facadeView.Count : GUI_infoList.Count) - 1; // first item is always ".." OnlineVideosGuiListItem selectedItem = CurrentState == State.videos ? GUI_facadeView.SelectedListItem as OnlineVideosGuiListItem : GUI_infoList.SelectedListItem as OnlineVideosGuiListItem; if (selectedItem == null || selectedItem.Item == null) return; // only context menu for items with an object backing them VideoInfo aVideo = selectedItem.Item as VideoInfo; if (aVideo != null) { GUIDialogMenu dlgSel = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlgSel == null) return; dlgSel.Reset(); dlgSel.SetHeading(Translation.Instance.Actions); List<KeyValuePair<string, Sites.ContextMenuEntry>> dialogOptions = new List<KeyValuePair<string, Sites.ContextMenuEntry>>(); // these context menu entries should only show if the item will not go to the details view if (!(SelectedSite is IChoice && CurrentState == State.videos && aVideo.HasDetails)) { if (!(SelectedSite is Sites.FavoriteUtil && aVideo.HasDetails && (selectedCategory is Sites.FavoriteUtil.FavoriteCategory && (selectedCategory as Sites.FavoriteUtil.FavoriteCategory).Site is IChoice))) { dlgSel.Add(Translation.Instance.PlayWith); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("PlayWith", null)); if (numItemsShown > 1) { dlgSel.Add(Translation.Instance.PlayAll); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("PlayAll", null)); dlgSel.Add(Translation.Instance.PlayAllFromHere); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("PlayAllFromHere", null)); dlgSel.Add(Translation.Instance.PlayAllRandom); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("PlayAllRandom", null)); } if (SelectedSite.CanSearch) { // Add context keyword search dlgSel.Add(Translation.Instance.SearchRelatedKeywords); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("SearchKeywords", null)); } if (!(SelectedSite is Sites.FavoriteUtil) && !(SelectedSite is Sites.DownloadedVideoUtil)) { dlgSel.Add(Translation.Instance.AddToFavourites); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("AddToFav", null)); } if (!(SelectedSite is Sites.DownloadedVideoUtil)) { dlgSel.Add(string.Format("{0} ({1})", Translation.Instance.Download, Translation.Instance.Concurrent)); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("DownloadConcurrent", null)); dlgSel.Add(string.Format("{0} ({1})", Translation.Instance.Download, Translation.Instance.Queued)); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("DownloadQueued", null)); if (loadParamInfo != null && !string.IsNullOrEmpty(loadParamInfo.DownloadDir) && Directory.Exists(loadParamInfo.DownloadDir)) { if (string.IsNullOrEmpty(loadParamInfo.DownloadMenuEntry)) dlgSel.Add(Translation.Instance.DownloadUserdefined); else dlgSel.Add(loadParamInfo.DownloadMenuEntry); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("UserdefinedDownload", null)); } } foreach (var entry in SelectedSite.GetContextMenuEntries(selectedCategory, aVideo)) { dlgSel.Add(entry.DisplayText); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>(entry.DisplayText, entry)); } } } // always allow the VK filtering in videos view if (CurrentState == State.videos && numItemsShown > 1) { dlgSel.Add(Translation.Instance.Filter); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>("Filter", null)); } if (dialogOptions.Count > 0) { dlgSel.DoModal(GUIWindowManager.ActiveWindow); if (dlgSel.SelectedId == -1) return; else { switch (dialogOptions[dlgSel.SelectedId - 1].Key) { case "PlayWith": dialogOptions.Clear(); dlgSel.Reset(); dlgSel.SetHeading(Translation.Instance.Actions); dlgSel.Add("MediaPortal"); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>(OnlineVideos.PlayerType.Internal.ToString(), null)); dlgSel.Add("Windows Media Player"); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>(OnlineVideos.PlayerType.WMP.ToString(), null)); if (VLCPlayer.IsInstalled) { dlgSel.Add("VLC media player"); dialogOptions.Add(new KeyValuePair<string, Sites.ContextMenuEntry>(OnlineVideos.PlayerType.VLC.ToString(), null)); } dlgSel.DoModal(GUIWindowManager.ActiveWindow); if (dlgSel.SelectedId == -1) return; else { OnlineVideos.PlayerType forcedPlayer = (OnlineVideos.PlayerType)Enum.Parse(typeof(OnlineVideos.PlayerType), dialogOptions[dlgSel.SelectedId - 1].Key); if (CurrentState == State.videos) selectedVideo = aVideo; else selectedClipIndex = GUI_infoList.SelectedListItemIndex; //play the video currentPlaylist = null; currentPlayingItem = null; Play_Step1(new PlayListItem(null, null) { Type = MediaPortal.Playlists.PlayListItem.PlayListItemType.VideoStream, Video = aVideo, Util = selectedSite is Sites.FavoriteUtil ? OnlineVideoSettings.Instance.SiteUtilsList[(selectedVideo as FavoriteDbVideoInfo).SiteName] : selectedSite, ForcedPlayer = forcedPlayer }, true); } break; case "PlayAll": PlayAll(); break; case "PlayAllFromHere": PlayAll(false, aVideo); break; case "PlayAllRandom": PlayAll(true); break; case "SearchKeywords": List<string> searchexpressions = new List<string> { selectedItem.Label }; if (selectedItem.Description.Length > 0) searchexpressions.Add(selectedItem.Description); ContextKeywordSelection(searchexpressions); break; case "AddToFav": string suggestedTitle = SelectedSite.GetFileNameForDownload(aVideo, selectedCategory, null); bool successAddingToFavs = OnlineVideoSettings.Instance.FavDB.AddFavoriteVideo(aVideo, suggestedTitle, SelectedSite.Settings.Name); 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(successAddingToFavs ? Translation.Instance.Success : Translation.Instance.Error); dlg.SetText(Translation.Instance.AddingToFavorites); dlg.DoModal(GUIWindowManager.ActiveWindow); } break; case "DownloadConcurrent": SaveVideo_Step1(DownloadList.Create(DownloadInfo.Create(aVideo, selectedCategory, selectedSite))); break; case "DownloadQueued": SaveVideo_Step1(DownloadList.Create(DownloadInfo.Create(aVideo, selectedCategory, selectedSite)), true); break; case "UserdefinedDownload": var dlInfo = DownloadInfo.Create(aVideo, selectedCategory, selectedSite); dlInfo.OverrideFolder = loadParamInfo.DownloadDir; dlInfo.OverrideFileName = loadParamInfo.DownloadFilename; SaveVideo_Step1(DownloadList.Create(dlInfo)); break; case "Filter": if (GetUserInputString(ref videosVKfilter, false)) SetVideosToFacade(currentVideoList, currentVideosDisplayMode); break; default: HandleCustomContextMenuEntry(dialogOptions[dlgSel.SelectedId - 1].Value, selectedCategory, aVideo); break; } } } } } }
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); } }
void PlayNextPlaylistItem() { int currentPlaylistIndex = currentPlayingItem != null ? currentPlaylist.IndexOf(currentPlayingItem) : 0; if (currentPlaylist.Count > currentPlaylistIndex + 1) { // if playing a playlist item, move to the next currentPlaylistIndex++; Play_Step1(currentPlaylist[currentPlaylistIndex], GUIWindowManager.ActiveWindow == GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO); } else { // if last item -> clear the list TrackPlayback(); currentPlaylist = null; currentPlayingItem = null; } }
void g_Player_PlayBackEnded(g_Player.MediaType type, string filename) { try { if (currentPlayingItem != null && currentPlayingItem.Util != null) { double percent = g_Player.Duration > 0 ? g_Player.CurrentPosition / g_Player.Duration : 0; currentPlayingItem.Util.OnPlaybackEnded(currentPlayingItem.Video, currentPlayingItem.FileName, percent, false); } } catch (Exception ex) { Log.Instance.Warn("Error on Util.OnPlaybackEnded: {0}", ex); } if (currentPlaylist != null) { if ((g_Player.Player != null && g_Player.Player.GetType().Assembly == typeof(GUIOnlineVideos).Assembly) || g_Player.Player == null && (filename == "http://localhost/OnlineVideo.mp4" || (currentPlayingItem != null && filename == currentPlayingItem.FileName))) { PlayNextPlaylistItem(); } else { // some other playback ended, and a playlist is still set here -> clear it currentPlaylist = null; currentPlayingItem = null; } } else { TrackPlayback(); currentPlayingItem = null; } }