ASP.NET实现在线播放FLV视频件的代码
前台调用代码
后台调用代码
protected void Page_Load(object sender, EventArgs e)
{
this.video_content.InnerHtml = PlayMedia.Play("http://hot.tudou.com/flv/005/680/205/5680205.flv", 472,385);
}
视频播放类:
using System;
using System.Collections.Generic;
using System.Text;
namespace Common
{
public class PlayMedia
{
public PlayMedia()
{
//
// TOD 在此处添加构造函数逻辑
//
}
public static string Play(string url, int width, int height)
{
string strTmp = url.ToLower();
if (strTmp.EndsWith(".wmv") || strTmp.EndsWith(".mp3") || strTmp.EndsWith(".wma") || strTmp.EndsWith(".avi") || strTmp.EndsWith(".asf") || strTmp.EndsWith(".mpg"))
{
return wmv(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(".flv"))
{
return flv(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 "视频文件数据错误";
}
}
///
/// flv格式文件播放
///
///
///
private static string flv(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
return sb.ToString();
}
///
/// wmv格式文件播放
///
///
///
private static string wmv(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("
/n");
return sb.ToString();
}
private static string wma(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("
sb.Append("");
return sb.ToString();
}
///
/// avi格式文件播放
///
///
///
private static string avi(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
return sb.ToString();
}
private static string mpg(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
return sb.ToString();
}
private static string rm(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
return sb.ToString();
}
private static string swf(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
return sb.ToString();
}
private static string mp3(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
sb.Append("");
return sb.ToString();
}
private static string img(string url, int width, int height)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
return sb.ToString();
}
}
}