文件没有被媒体播放器播放. [英] File not playing by media palyer.

查看:66
本文介绍了文件没有被媒体播放器播放.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置src = Session ["url1"].ToString()

单击链接按钮以播放视频的CS文件

How to set src=Session["url1"].ToString()

CS file from which linkbutton clicked to play video</b>

protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
   {
       if (e.CommandName == &quot;select&quot;)
       {

           SqlConnection cnn = new SqlConnection(connectionString);
           string selectSQL = &quot;SELECT url FROM electronicmedia where url=&#39;&quot; + e.CommandArgument.ToString() + &quot;&#39;&quot;;
           //SqlDataAdapter adp = new SqlDataAdapter(selectSQL, cnn);
           //DataTable dt = new DataTable();
           //adp.Fill(dt);
           //DataRow dr = dt.Rows[0];
           cnn.Open();
           SqlCommand cmd = new SqlCommand(selectSQL, cnn);
           SqlDataReader dr = cmd.ExecuteReader();

           if (dr.Read())
           {
               Session[&quot;url1&quot;] = dr[0].ToString();
              // System.Diagnostics.Process.Start(&quot;wmplayer.exe&quot;,dr[0].ToString());
           }
           cnn.Close();
           Response.Redirect(&quot;~/meiaplayer.aspx&quot;);


    }




ASPX页面




ASPX page

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<embed type="application/x-mplayer2"

 pluginspage="http://www.microsoft.com/Winows/MediaPlayer/" name="mediaplayer1" ShowStatusBar="true"

EnableContextMenu="false" autostart="true" loop="true" src='<%Session[url1].ToString();> %>' style="width: 471px; height: 273px" />
</asp:Content> //It does'nt work


If i put src=direct path of file then it is palyed correctly.But url that comes from database does not played by palyer.
cs page
<pre lang="CS">
public partial class meiaplayer : System.Web.UI.Page
{
    public string link = "";
    protected void Page_Load(object sender, EventArgs e)
    {
      link = Session["url1"].ToString();

    }
}

推荐答案

如果HyperLink位于DataList中,则必须在DataList1_ItemCommand方法中设置Hyperlink的目标代替Response.Redirect()
If the HyperLink is in your DataList, then you must set the Hyperlink''s target in your DataList1_ItemCommand method instead of a Response.Redirect()


这篇关于文件没有被媒体播放器播放.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆