我已编写代码从服务器文件夹中获取视频并在网页上播放。我正在使用flowplayer.it显示带有控件但不播放视频的视频播放器。可能是什么问题。代码附后
aspx中的代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="WebsiteTaskAsp.index" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="FlowPlayer/flowplayer-3.2.12.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 73px">
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Label ID="lblFilename" runat="server" Text="File Name :"></asp:Label>
<asp:Label ID="lblUploadMsg" runat="server"></asp:Label>
<asp:TextBox ID="videoNameTextbox" runat="server"></asp:TextBox>
<asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload" /><br /><br />
</div>
<div>
<hr />
<asp:DataList ID="DataList1" Visible="true" runat="server" AutoGenerateColumns="false"
RepeatColumns="2" CellSpacing="5">
<ItemTemplate>
<u>
<%# Eval("vname") %></u>
<hr />
<a class="player" style="height: 300px; width: 300px; display: block" href='<%# Eval("vpath") %>'>
</a>
</ItemTemplate>
</asp:DataList>
<script src="FlowPlayer/flowplayer-3.2.12.min.js" type="text/javascript"></script>
<script type="text/javascript">
flowplayer("a.player", "FlowPlayer/flowplayer-3.2.16.swf", {
plugins: {
pseudo: { url: "FlowPlayer/flowplayer.pseudostreaming-3.2.12.swf" }
},
clip: { provider: 'pseudo', autoPlay: false },
});
</script>
</div>
</form>
</body>
</html>
**Code in aspx.cs**
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
namespace WebsiteTaskAsp
{
public partial class index : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=Khawaja\\SQLEXPRESS;Initial Catalog=TaskDB;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
using (SqlConnection con = new SqlConnection("Data Source=Khawaja\\SQLEXPRESS;Initial Catalog=TaskDB;Integrated Security=True"))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select * from videos";
cmd.Connection = con;
con.Open();
DataList1.DataSource = cmd.ExecuteReader();
DataList1.DataBind();
con.Close();
}
}
}
protected void btnUpload_Click(object sender, EventArgs e)
{
if(FileUpload1.HasFile)
{
string str = FileUpload1.FileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath(".") + "//UploadedVideos//"+str);
string path = "~//UploadedVideos//"+str.ToString();
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO videos VALUES('"+videoNameTextbox.Text+"','"+path+"')",con);
cmd.ExecuteNonQuery();
con.Close();
lblUploadMsg.Text = "Video Uploaded Successfully";
}
}
}
}