using System.Text;

public class MediaHelper
{
private static MediaHelper media = null; private MediaHelper()
{
} public static MediaHelper Current
{
get
{
if (media == null)
media = new MediaHelper(); return media;
}
} public string FLV(string url, string flvPlayerpath, string width, string height)
{
StringBuilder sb = new StringBuilder();
sb.Append("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
sb.Append(" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"");
sb.Append(" width=\"" + width + "\"");
sb.Append(" height=\"" + height + "\">");
sb.Append("\r\n\t<param name=\"movie\" value=\"" + flvPlayerpath + "\" />");
sb.Append("\r\n\t<param name=\"quality\" value=\"high\" />");
sb.Append("\r\n\t<param name=\"allowFullScreen\" value=\"true\" />");
sb.Append("\r\n\t<param name=\"FlashVars\" value=\"vcastr_file=" + url + "\" />");
sb.Append("\r\n\t<embed src=\"" + flvPlayerpath + "\" allowfullscreen=\"true\" flashvars=\"vcastr_file=" + url + "\"");
sb.Append(" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\"></embed>");
sb.Append("</object>");
return sb.ToString();
} public string Play(string url, string width, string height)
{
string strTmp = url.ToLower();
if (strTmp.EndsWith(".wmv") || strTmp.EndsWith(".asf") || strTmp.EndsWith(".avi"))
{
return wmv(url, width, height);
}
else if (strTmp.EndsWith(".wma"))
{
return wma(url, width, height);
}
else if (strTmp.EndsWith(".avi"))
{
return avi(url, width, height);
}
else if (strTmp.EndsWith(".mpg"))
{
return mpg(url, width, height);
}
else if (strTmp.EndsWith(".mp3"))
{
return mp3(url, width, height);
}
else if (strTmp.EndsWith(".swf"))
{
return swf(url, width, height);
}
else if (strTmp.EndsWith(".jpg") || strTmp.EndsWith(".gif"))
{
return img(url, width, height);
}
else if (strTmp.EndsWith(".rm"))
{
return rm(url, width, height);
}
else
{
return "数据错误";
}
} /// <summary>
/// avi格式文件播放
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
private string avi(string url, string width, string height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<object id=\"WMPlay\" width=\"400\" height=\"200\" border=\"0\" classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\">");
sb.Append("<param name=\"ShowDisplay\" value=\"0\">");
sb.Append("<param name=\"ShowControls\" value=\"1\">");
sb.Append("<param name=\"AutoStart\" value=\"1\">");
sb.Append("<param name=\"AutoRewind\" value=\"0\">");
sb.Append("<param name=\"PlayCount\" value=\"0\">");
sb.Append("<param name=\"Appearance value=\"0 value=\"\"\">");
sb.Append("<param name=\"BorderStyle value=\"0 value=\"\"\">");
sb.Append("<param name=\"MovieWindowHeight\" value=\"240\">");
sb.Append("<param name=\"MovieWindowWidth\" value=\"320\">");
sb.Append("<param name=\"FileName\" value=\"" + url + "\">");
sb.Append("</object>"); return sb.ToString();
} private string img(string url, string width, string height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<img src=\"" + url + "\" height=\"" + height + "\" width=\"" + width + "\" border=\"0\">");
return sb.ToString();
} /// <summary>
/// 播放mp3
/// </summary>
/// <param name="url"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
private string mp3(string url, string width, string height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<object classid=\"WMPlay\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715\" type=\"application/x-oleobject\" width=\" + width + \" height=\" + height + \" hspace=\"0\" standby=\"Loading Microsoft Windows Media Player components...\" id=\"NSPlay\">"); sb.Append("<param name=\"AutoRewind\" value=\"0\">");
sb.Append("<param name=\"FileName\" value=\" + url + \">");
sb.Append("<param name=\"ShowControls\" value=\"1\">");
sb.Append("<param name=\"ShowPositionControls\" value=\"0\">");
sb.Append("<param name=\"ShowAudioControls\" value=\"1\">");
sb.Append("<param name=\"ShowTracker\" value=\"0\">");
sb.Append("<param name=\"ShowDisplay\" value=\"0\">");
sb.Append("<param name=\"ShowStatusBar\" value=\"1\">");
sb.Append("<param name=\"ShowGotoBar\" value=\"0\">");
sb.Append("<param name=\"ShowCaptioning\" value=\"0\">");
sb.Append("<param name=\"AutoStart\" value=\"1\">");
sb.Append("<param name=\"Volume\" value=\"-2500\">");
sb.Append("<param name=\"AnimationAtStart\" value=\"0\">");
sb.Append("<param name=\"TransparentAtStart\" value=\"0\">");
sb.Append("<param name=\"AllowChangeDisplaySize\" value=\"0\">");
sb.Append("<param name=\"AllowScan\" value=\"0\">");
sb.Append("<param name=\"EnableContextMenu\" value=\"0\">");
sb.Append("<param name=\"ClickToPlay\" value=\"0\">"); sb.Append("</object>");
return sb.ToString();
} /// <summary>
/// 播放mpg格式的文件
/// </summary>
/// <param name="url"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
private string mpg(string url, string width, string height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<object classid=\"clsid:05589FA1-C356-11CE-BF01-00AA0055595A\" id=\"WMPlay\" width=\"239\" height=\"250\">");
sb.Append("<param name=\"Filename\" value=\"" + url + "\" valuetype=\"ref\">");
sb.Append("<param name=\"Appearance\" value=\"0\">");
sb.Append("<param name=\"AutoStart\" value=\"-1\">");
sb.Append("<param name=\"AllowChangeDisplayMode\" value=\"-1\">");
sb.Append("<param name=\"AllowHideDisplay\" value=\"0\">");
sb.Append("<param name=\"AllowHideControls\" value=\"-1\">");
sb.Append("<param name=\"AutoRewind\" value=\"-1\">");
sb.Append("<param name=\"Balance\" value=\"0\">");
sb.Append("<param name=\"CurrentPosition\" value=\"0\">");
sb.Append("<param name=\"DisplayBackColor\" value=\"0\">");
sb.Append("<param name=\"DisplayForeColor\" value=\"16777215\">");
sb.Append("<param name=\"DisplayMode\" value=\"0\">");
sb.Append("<param name=\"Enabled\" value=\"-1\">");
sb.Append("<param name=\"EnableContextMenu\" value=\"-1\">");
sb.Append("<param name=\"EnablePositionControls\" value=\"-1\">");
sb.Append("<param name=\"EnableSelectionControls\" value=\"0\">");
sb.Append("<param name=\"EnableTracker\" value=\"-1\">"); sb.Append("<param name=\"FullScreenMode\" value=\"0\">");
sb.Append("<param name=\"MovieWindowSize\" value=\"0\">");
sb.Append("<param name=\"PlayCount\" value=\"1\">");
sb.Append("<param name=\"Rate\" value=\"1\">");
sb.Append("<param name=\"SelectionStart\" value=\"-1\">");
sb.Append("<param name=\"SelectionEnd\" value=\"-1\">");
sb.Append("<param name=\"ShowControls\" value=\"-1\">");
sb.Append("<param name=\"ShowDisplay\" value=\"-1\">");
sb.Append("<param name=\"ShowPositionControls\" value=\"0\">");
sb.Append("<param name=\"ShowTracker\" value=\"-1\">");
sb.Append("<param name=\"Volume\" value=\"-480\">");
sb.Append("</object>"); return sb.ToString();
} /// <summary>
/// 播放rm格式的文件
/// </summary>
/// <param name="url"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
private string rm(string url, string width, string height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<OBJECT ID=\"WMPlay\" codebase=\"downloads/RealPlayer10-5GOLD_cn0302.exe\" CLASSID=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" HEIGHT=" + height + " WIDTH=" + width + ">");
sb.Append("<param name=\"SRC\" value=\"" + url + "\">");
//sb.Append("<param name=\"_ExtentX\" value=\"9313\">");
//sb.Append("<param name=\"_ExtentY\" value=\"7620\">");
sb.Append("<param name=\"AUTOSTART\" value=\"0\">");
sb.Append("<param name=\"SHUFFLE\" value=\"0\">");
sb.Append("<param name=\"PREFETCH\" value=\"0\">");
sb.Append("<param name=\"NOLABELS\" value=\"0\">");
sb.Append("<param name=\"CONTROLS\" value=\"ImageWindow,ControlPanel,statusbar\">");
sb.Append("<param name=\"CONSOLE\" value=\"Clip1\">");
sb.Append("<param name=\"LOOP\" value=\"0\">");
sb.Append("<param name=\"NUMLOOP\" value=\"0\">");
sb.Append("<param name=\"CENTER\" value=\"0\">");
sb.Append("<param name=\"MAINTAINASPECT\" value=\"0\">");
sb.Append("<param name=\"BACKGROUNDCOLOR\" value=\"#000000\">");
//sb.Append("<embed SRC type=\"audio/x-pn-realaudio-plugin\" CONSOLE=\"Clip1\" CONTROLS=\"ImageWindow\" HEIGHT=\"250\" WIDTH=\"354\" AUTOSTART=\"false\">");
sb.Append("</OBJECT>"); return sb.ToString();
} /// <summary>
/// 播放swf格式的文件
/// </summary>
/// <param name="url"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
private string swf(string url, string width, string height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (width == "")
width = "100%";
if (height == "")
height = ""; sb.Append("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"" + width + "\" height=\"" + height + "\" id=\"movie_name\" align=\"middle\">");
sb.Append(" <param name=\"movie\" value=\"" + url + "\"/>");
sb.Append(" <!--[if !IE]>-->");
sb.Append(" <object type=\"application/x-shockwave-flash\" data=\"" + url + "\" width=\"" + width + "\" height=\"" + height + "\">");
sb.Append(" <param name=\"movie\" value=\"movie_name.swf\"/>");
sb.Append(" <!--<![endif]-->");
sb.Append(" <a href=\"http://www.adobe.com/go/getflash\">");
sb.Append(" <img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\"/>");
sb.Append(" </a>");
sb.Append(" <!--[if !IE]>-->");
sb.Append(" </object>");
sb.Append(" <!--<![endif]-->");
sb.Append("</object>");
return sb.ToString();
} /// <summary>
/// 播放wma格式文件
/// </summary>
/// <param name="url">文件地址</param>
/// <param name="width">宽度</param>
/// <param name="height">高度</param>
/// <returns></returns>
private string wma(string url, string width, string height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<object id=\"WMPlay\" classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" style=\"Z-INDEX: 101; LEFT: 40px; WIDTH: 240px; POSITION: absolute; TOP: 32px; HEIGHT: 248px\" >");
sb.Append("<param name=\"Filename\" value=\"" + url + "\">");
sb.Append("<param name=\"PlayCount\" value=\"1\">");
sb.Append("<param name=\"AutoStart\" value=\"0\">");
sb.Append("<param name=\"ClickToPlay\" value=\"1\">");
//sb.Append("<param name=\"DisplaySize\" value=\"0\">");
sb.Append("<param name=\"EnableFullScreen Controls\" value=\"1\">");
sb.Append("<param name=\"ShowAudio Controls\" value=\"1\">");
sb.Append("<param name=\"EnableContext Menu\" value=\"1\">");
sb.Append("<param name=\"ShowDisplay\" value=\"1\">"); sb.Append("</object>"); return sb.ToString();
} /// <summary>
/// wmv格式文件播放
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
private string wmv(string url, string width, string height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<object id=\"WMPlay\" style=\"WIDTH: " + width + "px;height:" + height + "px\" \n");
sb.Append("classid=\"CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6\" type=application/x-oleobject standby=\"Loading Windows Media Player components...\"");
sb.Append("codebase=\"downloads/mediaplayer10.0_cn.exe\" VIEWASTEXT>\n");
sb.Append("<param name=\"URL\" value='" + url + "'>\n");
sb.Append("<param name=\"controls\" value=\"ControlPanel,StatusBa\">");
//<PARAM NAME="CONTROLS" VALUE="ControlPanel,StatusBar">
sb.Append("<param name=\"hidden\" value=\"1\">");
sb.Append("<param name=\"ShowControls\" VALUE=\"0\">");
sb.Append("<param name=\"rate\" value=\"1\">\n");
sb.Append("<param name=\"balance\" value=\"0\">\n");
sb.Append("<param name=\"currentPosition\" value=\"-1\">\n");
sb.Append("<param name=\"defaultFrame\" value=\"\">\n");
sb.Append("<param name=\"playCount\" value=\"100\">\n");
sb.Append("<param name=\"autoStart\" value=\"-1\">\n");
sb.Append("<param name=\"currentMarker\" value=\"0\">\n");
sb.Append("<param name=\"invokeURLs\" value=\"-1\">\n");
sb.Append("<param name=\"baseURL\" value=\"\">\n");
sb.Append("<param name=\"volume\" value=\"85\">\n");
sb.Append("<param name=\"mute\" value=\"0\">\n");
sb.Append("<param name=\"uiMode\" value=\"mini\">\n");
sb.Append("<param name=\"stretchToFit\" value=\"0\">\n");
sb.Append("<param name=\"windowlessVideo\" value=\"0\">\n");
sb.Append("<param name=\"enabled\" value=\"-1\">\n");
sb.Append("<param name=\"enableContextMenu\" value=\"false\">\n");
sb.Append("<param name=\"fullScreen\" value=\"0\">\n");
sb.Append("<param name=\"SAMIStyle\" value=\"\">\n");
sb.Append("<param name=\"SAMILang\" value=\"\">\n");
sb.Append("<param name=\"SAMIFilename\" value=\"\">\n");
sb.Append("<param name=\"captioningID\" value=\"\">\n"); sb.Append("</object><br>\n"); return sb.ToString();
}
}

C# MediaHelper的更多相关文章

  1. 微信公众账号开发之N个坑(二)

    上篇说到微信公众账号的几个坑,前面五个,已经说到菜单,宝宝继续往下赘述了.可惜,还不知道宝宝的宝宝到底是不是心疼宝宝呢,完了,我凌乱了... 回到正题,我们就不吐槽其他的了,上一篇说到微信的菜单了,那 ...

  2. ASP.NET(C#)中的try catch异常处理机制

    在开发一个Umbraco平台系统的过程中,遇到了问题. 写的代码如下 fileUrl = MediaHelper.GetMediaUrl(Convert.ToInt32(publishedConten ...

  3. java程序设计原则

    前言: 前言:java这种面向对象的的语言其实是很符合人的生活思维模式的,因为它以对象作为自己的研究对象,所谓"万物皆对象".一个人.一颗苹果.一只蚂蚁都是对象.所以它的设计原则和 ...

  4. kentico api

    http://devnet.kentico.com/docs/10_0/api/html/R_Project_Kentico_API.htm ScriptHelper.RegisterClientSc ...

随机推荐

  1. FromData获取表单数据

    一般想要不刷新页面提交数据时,可以使用ajax提交.如果数据量不大可以自己写json数据用ajax提交到后台服务,但是数据量多且需要动态添加数据时,自己写json格式数据就有点麻烦了,这时候就需要Fo ...

  2. Unity3D料槽设备旋转(一)

    1.使用C#创建控制游戏对象的的脚本语言, 第一步: 在project师徒中create 一个C#脚本,将其按照自己的设备名称进行命名,这里我将其简单的命名成zhuaquanzhou.cs 使用编辑器 ...

  3. Java+selenium之WebDriver模拟鼠标键盘操作(六)

    org.openqa.selenium.interactions.Actions类,主要定义了一些模拟用户的鼠标mouse,键盘keyboard操作.对于这些操作,使用 perform()方法进行执行 ...

  4. openstack 基础

    一:openstack起源: 1.rackspace和NASA(美国国家航空航天局)共同发起的开源项目 1.1/rackspace:贡献的swaft子项目(存储组件) 1.2/NASA:贡献了nova ...

  5. Java享元模式

    定义:提供了减少对象数量从而改善应用所需的对象结构的方式 运用共享技术有效支持大量细微度的对象 类型:结构型 应用场景:系统底层的开发啊,以便解决系统的性能问题 系统有大量的相似对象,需要缓存池的场景 ...

  6. C# 中的readonly属性

    例如我们这里有一个类 class TestClass2 { private int someValue; public void ChangeValue(int newValue) { someVal ...

  7. C++类中的静态成员变量和静态成员函数的作用

    数据成员可以分为静态变量.非静态变量两种. 静态成员:静态类中的成员加入static 修饰符,即是静态成员,可以使用类名+静态成员名访问此静态成员,因为静态成员存在于内存,非静态成员需要实例化才会分配 ...

  8. 【BZOJ3782】上学路线

    题解: 这个容斥以前做过 到i点的所有方案显然是个组合数 然后要减去不合法的方案数 我们可以考虑成减去到每个障碍点为第一次遇到的障碍然后之后乱走就可以了 因为模数不是质数,所以crt合并

  9. 【bzoj3589】动态树 树链剖分+树链的并

    题解: 树链剖分是显然的 问题在于求树链的并 比较简单的方法是 用线段树打标记覆盖,查询标记区间大小 Qlog^2n 代码: #include <bits/stdc++.h> using ...

  10. Docker 启动tomcat

    docker run -d --name jinrong_beijingbank -p 8081:8081 -v /application/docker_hub/java/pypaltform2018 ...