protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == infobutton) { YoutubeGuiInfoEx scr = (YoutubeGuiInfoEx)GUIWindowManager.GetWindow(29053); scr.YouTubeEntry = Youtube2MP.NowPlayingEntry; GUIWindowManager.ActivateWindow(29053); } }
protected override void OnShowContextMenu() { if (listControl == null || listControl.SelectedListItem == null) { return; } GUIListItem selectedItem = listControl.SelectedListItem; YouTubeEntry videoEntry = selectedItem.MusicTag as YouTubeEntry; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu if (Youtube2MP.player.CurrentSong > -1 || Youtube2MP.temp_player.CurrentSong > -1) { dlg.Add(Translation.PlayNext); } dlg.Add(Translation.ShowPreviousWindow); dlg.Add(Translation.Fullscreen); if (videoEntry != null) { dlg.Add(Translation.AddPlaylist); dlg.Add(Translation.AddAllPlaylist); dlg.Add(Translation.Info); if (Youtube2MP.service.Credentials != null) { dlg.Add(Translation.AddFavorites); dlg.Add(Translation.AddWatchLater); } } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (dlg.SelectedLabelText == Translation.ShowPreviousWindow) { GUIWindowManager.ShowPreviousWindow(); } else if (dlg.SelectedLabelText == Translation.Fullscreen) { g_Player.ShowFullScreenWindow(); } else if (dlg.SelectedLabelText == Translation.AddPlaylist) { VideoInfo inf = SelectQuality(videoEntry); if (inf.Quality != VideoQuality.Unknow) { AddItemToPlayList(selectedItem, inf); } } else if (dlg.SelectedLabelText == Translation.AddAllPlaylist) { VideoInfo inf = SelectQuality(videoEntry); inf.Items = new Dictionary <string, string>(); if (inf.Quality != VideoQuality.Unknow) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetHeading(Translation.AddAllPlaylist); dlgProgress.SetLine(1, ""); dlgProgress.SetLine(2, ""); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); dlgProgress.StartModal(GetID); } int i = 0; for (int j = 0; j < listControl.Count; j++) { GUIListItem item = listControl[j]; if (dlgProgress != null) { double pr = ((double)i / (double)listControl.Count) * 100; dlgProgress.SetLine(1, item.Label); dlgProgress.SetLine(2, i.ToString() + "/" + listControl.Count.ToString()); dlgProgress.SetPercentage((int)pr); dlgProgress.Progress(); if (dlgProgress.IsCanceled) { break; } } i++; AddItemToPlayList(item, new VideoInfo(inf)); } if (dlgProgress != null) { dlgProgress.Close(); } } } else if (dlg.SelectedLabelText == Translation.AddFavorites) { try { Youtube2MP.service.Insert(new Uri(YouTubeQuery.CreateFavoritesUri(null)), videoEntry); } catch (Exception) { Err_message(Translation.WrongRequestWrongUser); } } else if (dlg.SelectedLabelText == Translation.AddWatchLater) { PlayListMember pm = new PlayListMember(); pm.Id = videoEntry.VideoId; Youtube2MP.request.Insert(new Uri("https://gdata.youtube.com/feeds/api/users/default/watch_later"), pm); } else if (dlg.SelectedLabelText == Translation.Info) { YoutubeGuiInfoEx scr = (YoutubeGuiInfoEx)GUIWindowManager.GetWindow(29053); scr.YouTubeEntry = videoEntry; //if (entry!=null) //{ // ArtistItem artistItem=ent //} GUIWindowManager.ActivateWindow(29053); } else if (dlg.SelectedLabelText == Translation.PlayNext) { PlayNext(videoEntry); } }
protected override void OnShowContextMenu() { if (Youtube2MP.NowPlayingEntry == null) { base.OnShowContextMenu(); return; } YouTubeEntry videoEntry = Youtube2MP.NowPlayingEntry; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(Translation.ContextMenu); // menu dlg.AddLocalizedString(941); dlg.AddLocalizedString(970); dlg.Add(Translation.Info); if (Youtube2MP.service.Credentials != null) { dlg.Add(Translation.AddFavorites); } dlg.Add(Translation.DownloadVideo); dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (dlg.SelectedLabelText == Translation.Info) { YoutubeGuiInfoEx scr = (YoutubeGuiInfoEx)GUIWindowManager.GetWindow(29053); scr.YouTubeEntry = videoEntry; GUIWindowManager.ActivateWindow(29053); } if (dlg.SelectedLabelText == Translation.AddFavorites) { try { Youtube2MP.service.Insert(new Uri(YouTubeQuery.CreateFavoritesUri(null)), videoEntry); } catch (Exception) { Youtube2MP.Err_message(Translation.WrongRequestWrongUser); } } if (dlg.SelectedLabelText == Translation.DownloadVideo) { LocalFileStruct fil = Youtube2MP._settings.LocalFile.Get(Youtube2MP.GetVideoId(videoEntry)); if (fil != null && File.Exists(fil.LocalFile)) { Youtube2MP.Err_message(Translation.ItemAlreadyDownloaded); } else { if (Youtube2MP.VideoDownloader.IsBusy) { Youtube2MP.Err_message(Translation.AnotherDonwnloadProgress); } else { VideoInfo inf = Youtube2MP.SelectQuality(videoEntry); string streamurl = Youtube2MP.StreamPlaybackUrl(videoEntry, inf); Youtube2MP.VideoDownloader.AsyncDownload(streamurl, Youtube2MP._settings.DownloadFolder + "\\" + Utils.MakeFileName(Utils.GetFilename(videoEntry.Title.Text + "{" + Youtube2MP.GetVideoId(videoEntry) + "}")) + Path.GetExtension(streamurl) + ".___"); GUIPropertyManager.SetProperty("#Youtube.fm.IsDownloading", "true"); GUIPropertyManager.SetProperty("#Youtube.fm.Download.Progress", "0"); GUIPropertyManager.SetProperty("#Youtube.fm.Download.Item", videoEntry.Title.Text); DatabaseProvider.InstanInstance.Save(videoEntry); Youtube2MP.VideoDownloader.Entry = videoEntry; } } } if (dlg.SelectedId == 941) { ShowAspectRatioMenu(); } if (dlg.SelectedId == 970) { GUIWindowManager.IsOsdVisible = false; GUIGraphicsContext.IsFullScreenVideo = false; GUIWindowManager.ShowPreviousWindow(); } }