void player_PlayBegin(PlayListItem item) { try { ClearLabels("NowPlaying"); VideoInfo info = item.MusicTag as VideoInfo; if (info == null) { return; } Log.Debug("YouTube.fm playback started"); YouTubeEntry en = info.Entry; item.FileName = Youtube2MP.StreamPlaybackUrl(en, info); Song song = Youtube2MP.YoutubeEntry2Song(en); Youtube2MP.NowPlayingEntry = en; Youtube2MP.NowPlayingSong = song; SetLabels(en, "NowPlaying"); if (listControl != null) { GUIControl.ClearControl(GetID, listControl.GetID); relatated.Clear(); } infoTimer.Enabled = true; } catch { } }
void player_PlayBegin(YoutubePlaylistPlayer playlit, PlayListItem item) { try { //ClearLabels("NowPlaying"); VideoInfo info = item.MusicTag as VideoInfo; if (info == null) { return; } Log.Debug("YouTube.fm playback started"); YouTubeEntry en = info.Entry; if (en.Authors.Count == 0) { Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + Youtube2MP.GetVideoId(en)); try { Video video = Youtube2MP.request.Retrieve <Video>(videoEntryUrl); en = video.YouTubeEntry; } catch (Exception) { //vid = null; } } en.Title.Text = item.Description; item.FileName = Youtube2MP.StreamPlaybackUrl(en, info); ClearLabels("NowPlaying", true); ClearLabels("Next", true); Youtube2MP.NowPlayingEntry = en; Youtube2MP.NextPlayingEntry = null; //ArtistManager.Instance.SetSkinProperties(Youtube2MP.NextPlayingEntry, "NowPlaying", false, false); if (playlit.GetNextItem() != null) { VideoInfo nextinfo = playlit.GetNextItem().MusicTag as VideoInfo; if (nextinfo != null) { Youtube2MP.NextPlayingEntry = nextinfo.Entry; //ArtistManager.Instance.SetSkinProperties(Youtube2MP.NextPlayingEntry, "Next", false, false); } } BackgroundWorker playBeginWorker = new BackgroundWorker(); playBeginWorker.DoWork += playBeginWorker_DoWork; playBeginWorker.RunWorkerAsync(); Youtube2MP.YouTubePlaying = true; GUIPropertyManager.SetProperty("#Youtube.fm.FullScreen.ShowTitle", "true"); GUIPropertyManager.SetProperty("#Youtube.fm.FullScreen.ShowNextTitle", Youtube2MP.NextPlayingEntry != null ? "true" : "false"); _labelTimer.Stop(); _labelTimer.Start(); } catch (Exception exception) { Log.Error("Youtube play begin exception"); Log.Error(exception); } }
public override void Play(SearchResultItem resultItem) { YouTubeEntry entry = resultItem.MetaData["entry"] as YouTubeEntry; YoutubeGUIBase.SetLabels(entry, "NowPlaying"); Youtube2MP.NowPlayingEntry = entry; VideoInfo info = new VideoInfo(); g_Player.PlayVideoStream(Youtube2MP.StreamPlaybackUrl(entry, info)); if (g_Player.Playing) { if (Youtube2MP._settings.ShowNowPlaying) { GUIWindowManager.ActivateWindow(29052); } else { g_Player.ShowFullScreenWindow(); } } if (!g_Player.Playing) { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlgOK != null) { dlgOK.SetHeading(25660); dlgOK.SetLine(1, "Unable to playback the item ! "); dlgOK.SetLine(2, ""); dlgOK.DoModal(GUIWindowManager.ActiveWindow); } } }
/// <summary> /// Called when [show context menu]. /// </summary> protected override void OnShowContextMenu() { GUIListItem selectedItem = listControl.SelectedListItem; YouTubeEntry videoEntry; LocalFileStruct file = selectedItem.MusicTag as LocalFileStruct; if (file != null) { Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + file.VideoId); Video video = Youtube2MP.request.Retrieve <Video>(videoEntryUrl); videoEntry = video.YouTubeEntry; } else { videoEntry = selectedItem.MusicTag as YouTubeEntry; } if (videoEntry == null) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu dlg.Add("Related Videos"); dlg.Add("Video responses for this video"); dlg.Add("All videos from this user : "******"Add to playlist"); dlg.Add("Add All to playlist"); dlg.Add("Add to favorites"); dlg.Add("Options"); dlg.Add("Download Video"); dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedLabel) { case 0: //relatated { if (videoEntry.RelatedVideosUri != null) { YouTubeQuery query = new YouTubeQuery(videoEntry.RelatedVideosUri.Content); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No item was found !"); } } } break; case 1: //respponse { if (videoEntry.VideoResponsesUri != null) { YouTubeQuery query = new YouTubeQuery(videoEntry.VideoResponsesUri.Content); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No response was found !"); } } } break; case 2: //relatated { if (videoEntry.RelatedVideosUri != null) { Video video = Youtube2MP.request.Retrieve <Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoEntry.VideoId)); YouTubeQuery query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", video.Author)); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No item was found !"); } } } break; case 3: { VideoInfo inf = SelectQuality(videoEntry); if (inf.Quality != VideoQuality.Unknow) { AddItemToPlayList(selectedItem, inf); } } break; case 4: { VideoInfo inf = SelectQuality(videoEntry); inf.Items = new Dictionary <string, string>(); foreach (GUIListItem item in listControl.ListView.ListItems) { AddItemToPlayList(item, new VideoInfo(inf)); } } break; case 5: { try { service.Insert(new Uri(YouTubeQuery.CreateFavoritesUri(null)), videoEntry); } catch (Exception) { Err_message("Wrong request or wrong user identification"); } } break; case 6: DoOptions(); break; case 7: // download { if (Youtube2MP._settings.LocalFile.Get(videoEntry.VideoId) != null) { Err_message("Item already downloaded !"); } else { if (VideoDownloader.IsBusy) { Err_message("Another donwnload is in progress"); dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetHeading("Download progress"); dlgProgress.SetLine(1, ""); dlgProgress.SetLine(2, ""); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); dlgProgress.DoModal(GetID); } } else { VideoInfo inf = SelectQuality(videoEntry); string streamurl = Youtube2MP.StreamPlaybackUrl(videoEntry, inf); VideoDownloader.AsyncDownload(streamurl, Youtube2MP._settings.DownloadFolder + "\\" + Utils.GetFilename(videoEntry.Title.Text + "{" + videoEntry.VideoId + "}") + Path.GetExtension(streamurl)); VideoDownloader.Entry = videoEntry; } } } break; } }
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(); } }