怎么在HTML网页中插入视频

怎么在HTML网页中插入视频,第1张

向HTML中插入视频有两种方法,一种是古老的object标签,一种是html5中的video标签。

前者兼容性相对好些,后者兼容性让人头疼。

示例如下:

<video width="602px" height="345px" controls="controls">

<source src="public/video/test.mp4" type="video/mp4"></source>

<source src="public/video/test.ogg" type="video/ogg"></source>

your browser does not support the video tag

</video>

当前,video 元素支持三种视频格式:

格式 IE Firefox Opera Chrome Safari

Ogg No 3.5+ 10.5+ 5.0+ No

MPEG 4 9.0+ No No 5.0+ 3.0+

WebM No 4.0+ 10.6+ 6.0+ No 

Ogg = 带有 Theora 视频编码和 Vorbis 音频编码的 Ogg 文件 

MPEG4 = 带有 H.264 视频编码和 AAC 音频编码的 MPEG 4 文件 

WebM = 带有 VP8 视频编码和 Vorbis 音频编码的 WebM 文件 

注:格式必须符合上面三条详细要求,比如MPEG 4,必须是H.264视频和AAC音频。

扩展资料:

HTML

超文本标记语言,标准通用标记语言下的一个应用。

超文本”就是指页面内可以包含图片、链接,甚至音乐、程序等非文字元素。

超文本标记语言的结构包括“头”部分(英语:Head)、和“主体”部分(英语:Body),其中“头”部提供关于网页的信息,“主体”部分提供网页的具体内容。

参考链接:HTML_百度百科

wmv格式的文件不是流媒体,能用网页播放的,通常只有flv、MP4,以及类似于MP4格式的文件,

wmv格式的文件通常需要有本地播放器的支持才能播放,不能直接在网页中播放的。

在前台直接调用

比如你路径放在 E:\1.wmv,

<%=SelPlay(@"E:\1.wmv", 500, 400)%>这样就ok了

.cs文件 直接拷贝,,

/// <summary>

/// 视频播放器(支持avi,wmv,asf,mov,rm,ra,ram),前台使用<%=SelPlay(strUrl, strWidth, StrHeight) %>

/// </summary>

/// <param name="strUrl">视频文件路径</param>

/// <param name="strWidth">播放器显示宽度</param>

/// <param name="StrHeight">播放器显示高度</param>

/// <returns>播放器内容</returns>

public string SelPlay(string strUrl, int strWidth, int StrHeight)

{

// 播放器内容

string html = ""

string Exts = string.Empty

string isExt = string.Empty

if (strUrl != "")

{

isExt = strUrl.Substring(strUrl.LastIndexOf('.') + 1).ToLower()

}

else

{

isExt = ""

}

Exts = "avi,wmv,asf,mov,rm,ra,ram"

if (Exts.IndexOf("isExt") >= -1)

{

switch (isExt)

{

case "avi":

case "wmv":

case "asf":

case "mov":

html += "<EMBED id=MediaPlayer src=" + strUrl + " width=" + strWidth + " height=" + StrHeight + " loop=false autostart=true ></EMBED>"

break

case "rm":

case "ra":

case "ram":

case "rmvb":

html += "<OBJECT height=" + StrHeight + " width=" + strWidth + " classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA>"

html += "<PARAM NAME=_ExtentX VALUE=12700>"

html += "<PARAM NAME=_ExtentY VALUE=9525>"

html += "<PARAM NAME=AUTOSTART VALUE=-1>"

html += "<PARAM NAME=SHUFFLE VALUE=0>"

html += "<PARAM NAME=PREFETCH VALUE=0>"

html += "<PARAM NAME=NOLABELS VALUE=0>"

html += "<PARAM NAME=SRC VALUE=" + strUrl + ">"

html += "<PARAM NAME=CONTROLS VALUE=ImageWindow>"

html += "<PARAM NAME=CONSOLE VALUE=Clip>"

html += "<PARAM NAME=LOOP VALUE=0>"

html += "<PARAM NAME=NUMLOOP VALUE=0>"

html += "<PARAM NAME=CENTER VALUE=0>"

html += "<PARAM NAME=MAINTAINASPECT VALUE=0>"

html += "<PARAM NAME=BACKGROUNDCOLOR VALUE=#000000>"

html += "</OBJECT>"

html += "<BR>"

html += "<OBJECT height=50 width=" + strWidth + " classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA>"

html += "<PARAM NAME=_ExtentX VALUE=12700>"

html += "<PARAM NAME=_ExtentY VALUE=847>"

html += "<PARAM NAME=AUTOSTART VALUE=0>"

html += "<PARAM NAME=SHUFFLE VALUE=0>"

html += "<PARAM NAME=PREFETCH VALUE=0>"

html += "<PARAM NAME=NOLABELS VALUE=0>"

html += "<PARAM NAME=CONTROLS VALUE=ControlPanel,StatusBar>"

html += "<PARAM NAME=CONSOLE VALUE=Clip>"

html += "<PARAM NAME=LOOP VALUE=0>"

html += "<PARAM NAME=NUMLOOP VALUE=0>"

html += "<PARAM NAME=CENTER VALUE=0>"

html += "<PARAM NAME=MAINTAINASPECT VALUE=0>"

html += "<PARAM NAME=BACKGROUNDCOLOR VALUE=#000000>"

html += "</OBJECT>"

break

}

}

else

{

html += "非法视频文件"

}

return html

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7063721.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-01
下一篇 2023-04-01

发表评论

登录后才能评论

评论列表(0条)

保存