Hello I asked for help before on my program on adding http:// or not to a link that I would put in my textbox(if the link already contained http:// it would not add it, but, if it did not have http:// in the link it would add it ). I got it working just great with help of ocn members, I decided on embedding some youtube videos to my program. The videos may change once in a while, and I am trying to get it working when I add a youtube link to my textbox and have it work in the embed video.
(this code is really messy I apologize)
Basically when I add a youtube link I want it to check for http and if there is one it will play the youtube video in embed format (it seems I have to have http for links to work in C# webBrowser feature unless you can tell me if there is a loophole where I don't need http at all.)
(this code is really messy I apologize)
Basically when I add a youtube link I want it to check for http and if there is one it will play the youtube video in embed format (it seems I have to have http for links to work in C# webBrowser feature unless you can tell me if there is a loophole where I don't need http at all.)
Code:
public void button1_Click(object sender, EventArgs e)
{
string schemeHttp = string.Format("{0}://", Uri.UriSchemeHttp);
string userUrl = textBox1.Text;
StreamWriter sw = new StreamWriter("utube.html");
string PlayString = textBox1.Text.Trim().Replace("watch?v=", "v/");
string Finalplaycode = "<embed src=" + PlayString + "?autoplay=1" + "&hl=en&fs=1& type=application/x-shockwave-flash allowscriptaccess=always allowfullscreen=true width=425 height=344></embed>";
sw.Write(Finalplaycode);
sw.Close();
string PathToNavigate = Directory.GetParent(Application.ExecutablePath) + @"\utube.html";
if (!userUrl.StartsWith(schemeHttp, StringComparison.OrdinalIgnoreCase))
{
userUrl = string.Format("{0}{1}", schemeHttp, userUrl);
}
webBrowser1.Navigate(PathToNavigate);
//webBrowser1.Navigate(new Uri(userUrl));
webBrowser1.ScriptErrorsSuppressed = true;
}








