private void textChangedEventHandler(object sender, TextChangedEventArgs e) { string youtubeURL = TextBox_YoutubeURL.Text; if (youtubeURL != "") { if (!youtubeURL.Contains("embed")) { string ID = youtubeURL.Substring(youtubeURL.IndexOf('=') + 1); youtubeURL = String.Format("https://www.youtube.com/embed/{0}", ID); } Button_AddMedia.IsEnabled = false; string html = "<html><title></title>"; html += "<iframe width='560' height='315' " + $"src='{youtubeURL}' " + "frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'></iframe>"; html += "</html>"; YoutubeElement.NavigateToString(html); } else { Button_AddMedia.IsEnabled = true; } }
public AddRecipeMediaWindow() { InitializeComponent(); //Set IE browser version if (!InternetExplorerBrowserEmulation.IsBrowserEmulationSet()) { InternetExplorerBrowserEmulation.SetBrowserEmulationVersion(); } //Stop media from playing after closing this.Closing += new CancelEventHandler( (object sender, CancelEventArgs e) => { YoutubeElement.Dispose(); }); }