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

 
前台调用代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>视频播放</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <table>

      <tr>
        <td><div id="video_content" runat="server" style=""></div>     </td>
      </tr>
    </table>
    </div>
    </form>
</body>
</html>

后台调用代码

protected void Page_Load(object sender, EventArgs e)
    {
        this.video_content.InnerHtml = PlayMedia.Play("http://136.154.22.100/CamelDirectShow/x.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 "视频文件数据错误";
            }
        }
        ///   <summary>   
        ///   flv格式文件播放   
        ///   </summary>   
        ///   <param   name="url"></param>   
        ///   <returns></returns>   
        private static string flv(string url, int width, int height)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<object   codeBase=/"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,22,87/"   ");
            sb.Append("classid=/"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000/" ");
            sb.Append(" height=/"" + height + "/"   width=/"" + width + "/"   >");
            sb.Append("<param   name=/"FlashVars/"   value=/"vcastr_file="+ url +"&LogoText=www.um173.com&BufferTime=3/">");
            sb.Append("<param   name=/"Movie/"   value=/"http://136.154.22.100/CamelDirectShow/vcastr.swf/">");           
            sb.Append("<param   name=/"allowFullScreen/"   value=/"true/">");
            sb.Append("<param   name=/"WMode/"   value=/"Window/">");
            sb.Append("<param   name=/"Play/"   value=/"1/">");
            sb.Append("<param   name=/"Loop/"   value=/"-1/">");
            sb.Append("<param   name=/"Quality/"   value=/"High/">");
            sb.Append("<param   name=/"SAlign/"   value=/"/">");
            sb.Append("<param   name=/"Menu/"   value=/"0/">");
            sb.Append("<param   name=/"Base/"   value=/"/">");
            sb.Append("<param   name=/"AllowScriptAccess/"   value=/"always/">");
            sb.Append("<param   name=/"Scale/"   value=/"ShowAll/">");
            sb.Append("<param   name=/"DeviceFont/"   value=/"0/">");

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的 ASP.NET MVC 实现搜索功能的代码示例: 首先,在视图中添加一个表单,用于提交搜索请求: ```html @using (Html.BeginForm("Search", "Home", FormMethod.Get)) { <input type="text" name="query" placeholder="Enter search query"> <button type="submit">Search</button> } ``` 这将创建一个简单的搜索表单,其中输入框将用于输入搜索查询,提交按钮将用于提交搜索请求。 接下来,我们需要在控制器中实现搜索操作: ```csharp public ActionResult Search(string query) { var results = new List<string>(); // Replace with your own search algorithm // Pass the search results to the view ViewBag.Results = results; return View(); } ``` 在上面的代码中,我们将搜索查询作为参数传递给 `Search` 操作方法,并使用自己的搜索算法(在此代码示例中未显示)来获取搜索结果。然后,我们将搜索结果存储在 `ViewBag` 中,并将其传递给视图。 最后,在视图中显示搜索结果: ```html @if (ViewBag.Results != null && ViewBag.Results.Count > 0) { <h2>Search Results:</h2> <ul> @foreach (var result in ViewBag.Results) { <li>@result</li> } </ul> } else { <p>No results found.</p> } ``` 在上面的代码中,我们首先检查是否有搜索结果可供显示,然后使用循环遍历所有搜索结果,并将它们显示为无序列表。如果没有结果,则会显示一条消息表明没有结果可供显示。 这就是一个简单的 ASP.NET MVC 实现搜索功能的完整代码示例。请注意,此示例仅用于演示目的,实际生产环境中的搜索实现可能会更为复杂和高级。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值