ChoosePlaybackOptions() public method

public ChoosePlaybackOptions ( string defaultUrl, Action resultHandler, bool skipDialog = false ) : void
defaultUrl string
resultHandler Action
skipDialog bool
return void
 public void SelectDetailsVideo(VideoViewModel videoModel)
 {
     if (BackgroundTask.Instance.IsExecuting)
     {
         return;
     }
     BackgroundTask.Instance.Start <List <string> >(
         () =>
     {
         return(SelectedSite.Site.GetMultipleVideoUrls(videoModel.VideoInfo));
     },
         (success, urls) =>
     {
         if (success)
         {
             if (SelectedSite.Site.Settings.Player != PlayerType.Browser)
             {
                 Helpers.UriUtils.RemoveInvalidUrls(urls);
             }
             // if no valid urls were returned show error msg
             if (urls == null || urls.Count == 0)
             {
                 ServiceRegistration.Get <IDialogManager>().ShowDialog("[OnlineVideos.Error]", "[OnlineVideos.UnableToPlayVideo]", DialogType.OkDialog, false, DialogButtonType.Ok);
             }
             else
             {
                 SelectedDetailsVideo = videoModel;
                 SelectedDetailsVideo.ChoosePlaybackOptions(urls[0], (url) => { urls[0] = url; SelectedDetailsVideo.Play(urls); });
             }
         }
     },
         Translation.Instance.GettingPlaybackUrlsForVideo);
 }
        static void SaveVideo_Step2(DownloadList saveItems, List <String> urls, bool?enque)
        {
            Helpers.UriUtils.RemoveInvalidUrls(urls);

            // if no valid urls were returned show error msg
            if (urls == null || urls.Count == 0)
            {
                ServiceRegistration.Get <IDialogManager>().ShowDialog("[OnlineVideos.Error]", "[OnlineVideos.UnableToDownloadVideo]", DialogType.OkDialog, false, DialogButtonType.Ok);
                return;
            }

            // create download list if more than one url
            if (urls.Count > 1)
            {
                saveItems.DownloadItems = new List <DownloadInfo>();
                foreach (string url in urls)
                {
                    VideoInfo vi      = saveItems.CurrentItem.VideoInfo.CloneForPlaylist(url, url == urls[0]);
                    string    url_new = url;
                    if (url == urls[0])
                    {
                        url_new = saveItems.CurrentItem.Util.GetPlaylistItemVideoUrl(vi, string.Empty);
                    }
                    DownloadInfo pli = DownloadInfo.Create(vi, saveItems.CurrentItem.Category, saveItems.CurrentItem.Util);
                    pli.Title            = string.Format("{0} - {1} / {2}", vi.Title, (saveItems.DownloadItems.Count + 1).ToString(), urls.Count);
                    pli.Url              = url_new;
                    pli.OverrideFolder   = saveItems.CurrentItem.OverrideFolder;
                    pli.OverrideFileName = saveItems.CurrentItem.OverrideFileName;
                    saveItems.DownloadItems.Add(pli);
                }
                // make the first item the current to be saved now
                saveItems.CurrentItem = saveItems.DownloadItems[0];
                urls = new List <string>(new string[] { saveItems.CurrentItem.Url });
            }
            // show selection dialog for playback options
            VideoViewModel tempVi = new VideoViewModel(saveItems.CurrentItem.VideoInfo, saveItems.CurrentItem.Category, saveItems.CurrentItem.Util.Settings.Name, saveItems.CurrentItem.Util.Settings.UtilName, false);

            tempVi.ChoosePlaybackOptions(urls[0], (url) => { SaveVideo_Step3(saveItems, url, enque); }, enque == null);             // skip dialog when downloading an item of a queue
        }
		static void SaveVideo_Step2(DownloadList saveItems, List<String> urls, bool? enque)
		{
            Helpers.UriUtils.RemoveInvalidUrls(urls);

			// if no valid urls were returned show error msg
			if (urls == null || urls.Count == 0)
			{				
				ServiceRegistration.Get<IDialogManager>().ShowDialog("[OnlineVideos.Error]", "[OnlineVideos.UnableToDownloadVideo]", DialogType.OkDialog, false, DialogButtonType.Ok);
				return;
			}

			// create download list if more than one url
			if (urls.Count > 1)
			{
				saveItems.DownloadItems = new List<DownloadInfo>();
				foreach (string url in urls)
				{
					VideoInfo vi = saveItems.CurrentItem.VideoInfo.CloneForPlaylist(url, url == urls[0]);
					string url_new = url;
					if (url == urls[0])
					{
						url_new = saveItems.CurrentItem.Util.GetPlaylistItemVideoUrl(vi, string.Empty);
					}
					DownloadInfo pli = DownloadInfo.Create(vi, saveItems.CurrentItem.Category, saveItems.CurrentItem.Util);
					pli.Title = string.Format("{0} - {1} / {2}", vi.Title, (saveItems.DownloadItems.Count + 1).ToString(), urls.Count);
					pli.Url = url_new;
					pli.OverrideFolder = saveItems.CurrentItem.OverrideFolder;
					pli.OverrideFileName = saveItems.CurrentItem.OverrideFileName;
					saveItems.DownloadItems.Add(pli);
				}
				// make the first item the current to be saved now
				saveItems.CurrentItem = saveItems.DownloadItems[0];
				urls = new List<string>(new string[] { saveItems.CurrentItem.Url });
			}
			// show selection dialog for playback options
			VideoViewModel tempVi = new VideoViewModel(saveItems.CurrentItem.VideoInfo, saveItems.CurrentItem.Category, saveItems.CurrentItem.Util.Settings.Name, saveItems.CurrentItem.Util.Settings.UtilName, false);
			tempVi.ChoosePlaybackOptions(urls[0], (url) => { SaveVideo_Step3(saveItems, url, enque); }, enque == null); // skip dialog when downloading an item of a queue
		}
        public void SelectDetailsVideo(VideoViewModel videoModel)
        {
			if (BackgroundTask.Instance.IsExecuting) return;
			BackgroundTask.Instance.Start<List<string>>(
				() =>
                {
					return SelectedSite.Site.GetMultipleVideoUrls(videoModel.VideoInfo);
                },
				(success, urls) =>
                {
					if (success)
					{
						Helpers.UriUtils.RemoveInvalidUrls(urls);
						// if no valid urls were returned show error msg
						if (urls == null || urls.Count == 0)
						{
							ServiceRegistration.Get<IDialogManager>().ShowDialog("[OnlineVideos.Error]", "[OnlineVideos.UnableToPlayVideo]", DialogType.OkDialog, false, DialogButtonType.Ok);
						}
						else
						{
							SelectedDetailsVideo = videoModel;
							SelectedDetailsVideo.ChoosePlaybackOptions(urls[0], (url) => { urls[0] = url; SelectedDetailsVideo.Play(urls); });
						}
					}
                },
                Translation.Instance.GettingPlaybackUrlsForVideo);
        }
		public void SelectVideo(VideoViewModel videoModel)
        {
			if (BackgroundTask.Instance.IsExecuting) return;
			if (videoModel.VideoInfo == null)
            {
                // discover and append next page videos
				BackgroundTask.Instance.Start<List<VideoInfo>>(
					() =>
					{
						return SelectedSite.Site.GetNextPageVideos();
					},
					(success, nextPageVideos) =>
					{
						if (success)
						{
							VideosList.Remove(videoModel);
							int selectNr = VideosList.Count;
							nextPageVideos.ForEach(r => { r.CleanDescriptionAndTitle(); VideosList.Add(new VideoViewModel(r, SelectedCategory != null ? SelectedCategory.Category : null, SelectedSite.Name, SelectedSite.Site.Settings.UtilName, false) { Selected = VideosList.Count == selectNr }); });
							if (SelectedSite.Site.HasNextPage) VideosList.Add(new VideoViewModel(Translation.Instance.NextPage, "NextPage.png"));
							VideosList.FireChange();
							ImageDownloader.GetImages<VideoInfo>(nextPageVideos);
						}
					},
                    Translation.Instance.GettingNextPageVideos);
            }
            else
            {
				if (SelectedSite.Site is Sites.IChoice && videoModel.VideoInfo.HasDetails)
                {
                    // get details videos and show details view
                    BackgroundTask.Instance.Start<List<DetailVideoInfo>>(
						() =>
						{
                            return ((Sites.IChoice)SelectedSite.Site).GetVideoChoices(videoModel.VideoInfo);
                        },
						(success, choices) =>
                        {
							if (success)
							{
								SelectedVideo = videoModel;
								ShowDetails(choices);
							}
                        },
                        Translation.Instance.GettingVideoDetails);
                }
                else
                {
					// get playback urls and play or show dialog to select playback options
					BackgroundTask.Instance.Start<List<string>>(
						() =>
                        {
							return SelectedSite.Site.GetMultipleVideoUrls(videoModel.VideoInfo);
                        },
						(success, urls) =>
						{
							if (success)
							{
								Helpers.UriUtils.RemoveInvalidUrls(urls);
								// if no valid urls were returned show error msg
								if (urls == null || urls.Count == 0)
								{
									ServiceRegistration.Get<IDialogManager>().ShowDialog("[OnlineVideos.Error]", "[OnlineVideos.UnableToPlayVideo]", DialogType.OkDialog, false, DialogButtonType.Ok);
								}
								else
								{
									SelectedVideo = videoModel;
									SelectedVideo.ChoosePlaybackOptions(urls[0], (url) => { urls[0] = url; SelectedVideo.Play(urls); });
								}
							}
						},
                        Translation.Instance.GettingPlaybackUrlsForVideo);
                }
            }
        }
 public void SelectVideo(VideoViewModel videoModel)
 {
     if (BackgroundTask.Instance.IsExecuting)
     {
         return;
     }
     if (videoModel.VideoInfo == null)
     {
         // discover and append next page videos
         BackgroundTask.Instance.Start <List <VideoInfo> >(
             () =>
         {
             return(SelectedSite.Site.GetNextPageVideos());
         },
             (success, nextPageVideos) =>
         {
             if (success)
             {
                 VideosList.Remove(videoModel);
                 int selectNr = VideosList.Count;
                 nextPageVideos.ForEach(r => { r.CleanDescriptionAndTitle(); VideosList.Add(new VideoViewModel(r, SelectedCategory != null ? SelectedCategory.Category : null, SelectedSite.Site.Settings, false)
                     {
                         Selected = VideosList.Count == selectNr
                     }); });
                 if (SelectedSite.Site.HasNextPage)
                 {
                     VideosList.Add(new VideoViewModel(Translation.Instance.NextPage, "NextPage.png"));
                 }
                 VideosList.FireChange();
                 ImageDownloader.GetImages <VideoInfo>(nextPageVideos);
             }
         },
             Translation.Instance.GettingNextPageVideos);
     }
     else
     {
         if (SelectedSite.Site is Sites.IChoice && videoModel.VideoInfo.HasDetails)
         {
             // get details videos and show details view
             BackgroundTask.Instance.Start <List <DetailVideoInfo> >(
                 () =>
             {
                 return(((Sites.IChoice)SelectedSite.Site).GetVideoChoices(videoModel.VideoInfo));
             },
                 (success, choices) =>
             {
                 if (success)
                 {
                     SelectedVideo = videoModel;
                     ShowDetails(choices);
                 }
             },
                 Translation.Instance.GettingVideoDetails);
         }
         else
         {
             // get playback urls and play or show dialog to select playback options
             BackgroundTask.Instance.Start <List <string> >(
                 () =>
             {
                 return(SelectedSite.Site.GetMultipleVideoUrls(videoModel.VideoInfo));
             },
                 (success, urls) =>
             {
                 if (success)
                 {
                     if (SelectedSite.Site.Settings.Player != PlayerType.Browser)
                     {
                         Helpers.UriUtils.RemoveInvalidUrls(urls);
                     }
                     // if no valid urls were returned show error msg
                     if (urls == null || urls.Count == 0)
                     {
                         ServiceRegistration.Get <IDialogManager>().ShowDialog("[OnlineVideos.Error]", "[OnlineVideos.UnableToPlayVideo]", DialogType.OkDialog, false, DialogButtonType.Ok);
                     }
                     else
                     {
                         SelectedVideo = videoModel;
                         SelectedVideo.ChoosePlaybackOptions(urls[0], (url) => { urls[0] = url; SelectedVideo.Play(urls); });
                     }
                 }
             },
                 Translation.Instance.GettingPlaybackUrlsForVideo);
         }
     }
 }