ASP.NET实现在线播放FLV视频件的代码

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("             sb.Append("classid=/"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000/" ");
            sb.Append(" height=/"" + height + "/"   width=/"" + width + "/"   >");
            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("");
            sb.Append("");
            sb.Append("");
            sb.Append("");
            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("             sb.Append("classid=/"CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6/"   type=application/x-oleobject   standby=/"Loading   Windows   Media   Player   components.../"");
            sb.Append("codebase=/"downloads/mediaplayer9.0_cn.exe/"   VIEWASTEXT>/n");
            sb.Append("/n");
            sb.Append("");
            //   
            sb.Append("");
            sb.Append("");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            sb.Append("/n");
            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("");
            sb.Append("");
            sb.Append("");
            sb.Append("");
            //sb.Append("");   
            sb.Append("");
            sb.Append("");
            sb.Append("");
            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("");
            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 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("");
            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 rm(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("");

            return sb.ToString();
        }

 

 


        private static string swf(string url, int width, int height)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();


            sb.Append("             sb.Append("   height=/"" + height + "/"   width=/"" + width + "/"   >");
            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("");
            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();
        }

 

    }
}

你可能感兴趣的:(ASP.NET实现在线播放FLV视频件的代码)