怎么做播放器

yujiayou 2010-10-11 11:40:59
在.net中要实现播放器的功能怎么实现,给个思路
最好有代码 谢谢
...全文
154 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yujiayou 2010-10-12
  • 打赏
  • 举报
回复
就是能播放视频的
七爷 2010-10-12
  • 打赏
  • 举报
回复
要播放视频的地方放一个Lable就OK了
七爷 2010-10-12
  • 打赏
  • 举报
回复
我原来写的一个东西,不过不能判断真实的文件后缀名,如果把文件后缀名该掉可能不起作用

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//this.Response.Write("<script>alert('aaaa!!');</script>");
string path = "flash/love.rm";
this.lblFlash.Text = GetPlayHtml(path, "188", "130");

}
}
/// <summary>
/// 生成视频播放器的HTML源码
/// </summary>
/// <remarks>
/// 调用方法<div><%=playHtml %></div>
/// </remarks>
/// <param name="strUrl">视频存放路径</param>
/// <param name="strWidth">播放器宽度</param>
/// <param name="strHeight">播放器高度</param>
/// <returns></returns>
public static string GetPlayHtml(string strUrl, string strWidth, string strHeight)
{
string resultHtml = "";
if (strUrl != "")
{
string Exts = "avi,wmv,asf,mov,rm,ra,ram";
string isExt = "";
if (strUrl != "")
{
isExt = strUrl.Substring(strUrl.LastIndexOf(".") + 1);//获取后缀名
}
if (!Exts.Contains(isExt))
{
resultHtml = "非法视频文件";
}
else
{
switch (isExt)
{
case "avi":
case "wmv":
case "asf":
case "mov":
resultHtml += "<EMBED id=MediaPlayer src=" + "\"" + strUrl + "\"" + " width=" + strWidth + " height=" + strHeight + " loop='false' autostart='true'></EMBED>";
break;
//case "mov":
case "rm":
case "ra":
case "ram":
resultHtml += "<OBJECT height=" + strHeight + " width=" + strWidth + " classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA>";
break;
}
resultHtml += "<PARAM NAME='_ExtentX' VALUE='12700'>";
resultHtml += "<PARAM NAME='_ExtentY' VALUE='9525'>";
resultHtml += "<PARAM NAME='AUTOSTART' VALUE='-1'>";//VALUE='-1'
resultHtml += "<PARAM NAME='SHUFFLE' VALUE='0'>";
resultHtml += "<PARAM NAME='PREFETCH' VALUE='0'>";
resultHtml += "<PARAM NAME='NOLABELS' VALUE='0'>";
resultHtml += "<PARAM NAME='SRC' VALUE='" + strUrl + "'>";
resultHtml += "<PARAM NAME='CONTROLS' VALUE='ImageWindow'>";
resultHtml += "<PARAM NAME='CONSOLE' VALUE='Clip'>";
resultHtml += "<PARAM NAME='LOOP' VALUE='0'>";
resultHtml += "<PARAM NAME='NUMLOOP' VALUE='0'>";
resultHtml += "<PARAM NAME='CENTER' VALUE='0'>";
resultHtml += "<PARAM NAME='MAINTAINASPECT' VALUE='0'>";
resultHtml += "<PARAM NAME='BACKGROUNDCOLOR' VALUE='#000000'>";
resultHtml += "</OBJECT>";
resultHtml += "<BR>";
resultHtml += "<OBJECT height=32 width=" + strWidth + " classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA>";
resultHtml += "<PARAM NAME='_ExtentX' VALUE='12700'>";
resultHtml += "<PARAM NAME='_ExtentY' VALUE='847'>";
resultHtml += "<PARAM NAME='AUTOSTART' VALUE='0'>";
resultHtml += "<PARAM NAME='SHUFFLE' VALUE='0'>";
resultHtml += "<PARAM NAME='PREFETCH' VALUE='0'>";
resultHtml += "<PARAM NAME='NOLABELS' VALUE='0'>";
resultHtml += "<PARAM NAME='CONTROLS' VALUE='ControlPanel,StatusBar'>";
resultHtml += "<PARAM NAME='CONSOLE' VALUE='Clip'>";
resultHtml += "<PARAM NAME='LOOP' VALUE='0'>";
resultHtml += "<PARAM NAME='NUMLOOP' VALUE='0'>";
resultHtml += "<PARAM NAME='CENTER' VALUE='0'>";
resultHtml += "<PARAM NAME='MAINTAINASPECT' VALUE='0'>";
resultHtml += "<PARAM NAME='BACKGROUNDCOLOR' VALUE='#000000'>";
resultHtml += "</OBJECT>";
}
}
return resultHtml;
}
willpanLY 2010-10-12
  • 打赏
  • 举报
回复
用silverlight,具体的百度搜一下
wanghuaide 2010-10-11
  • 打赏
  • 举报
回复
播放器有专门的组件吧
quanpp 2010-10-11
  • 打赏
  • 举报
回复
看你做什么播放器了,flash比较绚丽一点,呵呵,前提你会的情况下,貌似这个东西不是太难。
我这有一个flv播放器看看对你有没有帮助

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="500" height="400">
<param name="movie" value="Flvplayer.swf" />
<param name="quality" value="high" />
<param name="allowFullScreen" value="true" />
<param name="FlashVars" value="vcastr_file=http://www.***.com/123.flv&LogoText=www.***.com&BufferTime=3" />
<embed src="Flvplayer.swf" allowfullscreen="true" flashvars="vcastr_file=http://www.***.com/123.flv&LogoText=www.***.com" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="500" height="400"></embed>
</object>

500 :播放器的宽度。

400:播放器的高度。

Flvplayer.swf :播放器文件,必须的。

http://www.***.com/123.flv:flv文件地址(也就是你要比方视频的文件地址)。

www.***.com :播放器顶部标志,可缺省。

Flvplayer.swf 这是FLV播放器,也就是上面下载的播放文件,很重要,路径一定要对,否则播放错误,可以放其他目录,如果放在 img目录就是:img/Flvplayer.swf ,前面不带“/”。
http://help.powereasy.net/help/SiteWeaver/2052.html

Flvplayer.swf 文件到上边这个地址下一个,里面还有详细的讲解!

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧