Breaking News

Editors Picks

Tuesday, October 4, 2011

Play video from You tube url in asp.net C#


this code add on aspx page
 
<% GetYouTubeScript(dtPoll.Rows[Count]["PollVideoURL"].ToString());%>
<asp:Literal ID="Literal1" runat="server">asp:Literal>


and this code add on aspx.cs page 
public void GetYouTubeScript(string id)
{
if (id.Contains("="))
{
string[] video = id.Split('=');
if (video.Length > 1)
id = video[1].ToString();
else
id = video[0].ToString();
}
else
{
if (id.Contains("/"))
{
string[] video = id.Split('/');
id = video[3].ToString();
}
else
{ }
}
string scr = @" ";

scr = scr + @" ";

scr = scr + @" ";

scr = scr + @" ";

scr = scr + @";

scr = scr + @"type='application/x-shockwave-flash' allowscriptaccess='always' ";

scr = scr + @"allowfullscreen='true' width='250' height='220'> ";

scr = scr + @"

"
;
Literal1.Text = scr;
}

No comments :

Post a Comment

Contact Us

Name

Email *

Message *