Windows Forms: How to Add or Embed Youtube Video into a Windows Form in C#
By FoxLearn 7/27/2017 7:43:18 PM 5.66K
How to Add or Embed Youtube Video into a Windows Form in C#.
Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "EmbedYoutube" and then click OK
Step 2: Design your form as below
Step 3: Add code to handle your form as below
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; namespace EmbedYoutube { public partial class Form1 : Form { public Form1() { InitializeComponent(); } string _ytUrl; //Get video id public string VideoId { get { var ytMatch = new Regex(@"youtu(?:\.be|be\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)").Match(_ytUrl); return ytMatch.Success ? ytMatch.Groups[1].Value : string.Empty; } } private void btnGo_Click(object sender, EventArgs e) { _ytUrl = txtUrl.Text; webBrowser.Navigate($"http://youtube.com/v/{VideoId}?version=3"); } } }
VIDEO TUTORIALS
- How to make a Notepad in C#
- How to Receive SMS from WhatsApp in C#
- How to Add Combobox to DataGridView in C#
- How to Create Multiple pages on the Form using Panel control in C#
- How to insert Math Equation to RichTextBox in C#
- How to Send and Receive email in Microsoft Outlook using C#
- How to Print Windows Form in C#
- How to Use Form Load and Button click Event in C#
Categories
Popular Posts
How to sign a powershell script
10/03/2024
How to get Credentials in PowerShell?
10/03/2024
How to implement Jint in C#
09/14/2024