本文介绍了在.NET HTML5视频标签更改SRC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有一种方法可以轻松地在HTML5从codebehind更改视频标签的SRC?
Im wondering if there is a way to easily change the src in the video tag in HTML5 from codebehind?
我的解决方案,现在就是用不同的WebUserControl的,并把它们放在一个占位符,单击其按钮时,但这种快导致了大量的控制的了。
my solution now is to use different WebUserControl's and place them in a PlaceHolder when their button is clicked, but this fast leads to a lot of control's.
必须有一个更好的办法。
There has to be a better way.
也许就像把一个标签某种,绑定在src
maybe like placing a label, bind of some sort in the src
推荐答案
在aspx页面
<asp:PlaceHolder ID="VidModule" runat="server"></asp:PlaceHolder>
这在codebehind
and this in the codebehind
//Video relevant int's
int width {get; set;}
int height { get; set; }
//Video relevant text's
string overskrift { get; set; }
string poster { get; set; }
string titleimg { get; set; }
string ogv { get; set; }
string mp4 { get; set; }
string webm { get; set; }
string reso { get; set; }
string res { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
}
//low 240i resolution player LowD
protected void low240i_Click(object sender, EventArgs e)
{
height = 480;
width = 640;
reso = "240i";
if (reso == "240i")
res = "240i/";
else if (reso == "240p")
res = "240p/";
else if (reso == "480p")
res = "480p/";
else if (reso == "720p")
res = "720p/";
int Data = Convert.ToInt32(Request.QueryString["id"]);
VideoDataContext db = new VideoDataContext();
var fetch = from list in db.VideoDBs
where
list.VidID == Data
select list;
foreach (var list in fetch)
{
overskrift = "\"" + list.Name + "\"";
poster = "\"" + list.IMGAddr + "\"";
titleimg = "\"" + list.IMGAddr + "\"";
if (list.mp4 == true)
mp4 = "\"" + "../Movies/Mov/" + res + list.VIDAddr + ".mp4" + "\"";
else
mp4 = null;
if (list.ogv == true)
ogv = "\"" + "../Movies/Mov/" + res + list.VIDAddr + ".ogv" + "\"";
else
ogv = null;
if (list.webm == true)
webm = "\"" + "../Movies/Mov/" + res + list.VIDAddr + ".webm" + "\"";
else
webm = null;
}
Panel1.Controls.Add(new LiteralControl("<div class=player ><br />"));
Panel1.Controls.Add(new LiteralControl("<h3>" + overskrift + " in " + reso + "</h3><br /><br />"));
Panel1.Controls.Add(new LiteralControl("<video controls=controls id=video width=" + "\"" + width + "\"" + " height=" + "\"" + height + "\"" + " poster=" + poster + " preload=auto >"));
Panel1.Controls.Add(new LiteralControl("<source src=" + mp4 + " type=\"video/mp4; codecs=avc1.42E01E, mp4a.40.2\" title=" + titleimg + " />"));
Panel1.Controls.Add(new LiteralControl("<source src=" + webm + " type=\"video/webm; codecs=vp8, vorbis\" title=" + titleimg + " />"));
Panel1.Controls.Add(new LiteralControl("<source src=" + ogv + " type=\"video/ogg; codecs=theora, vorbis\" title=" + titleimg + " />"));
Panel1.Controls.Add(new LiteralControl("Your browser does not support the video tag."));
Panel1.Controls.Add(new LiteralControl("</video></div>"));
}
这篇关于在.NET HTML5视频标签更改SRC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!