<asp:DataList ID="dtlVideos" runat="server">
<ItemTemplate>
<table>
<tr>
<td>
<video controls="controls" width="200" height="200" src='<%# Eval ("Name","videos/{0}") %>'>"/>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
public partial class videos : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDataList();
}
}
protected void BindDataList()
{
DirectoryInfo dir = new DirectoryInfo(MapPath("~/videos"));
FileInfo[] files = dir.GetFiles();
ArrayList listItems = new ArrayList();
foreach (FileInfo info in files)
{
listItems.Add(info);
}
dtlVideos.DataSource = listItems;
dtlVideos .DataBind();
}
}
无法在Chrome或浏览器中播放视频,而mozilla仅支持.mp4格式而非其他格式 我想让这个应用程序支持所有格式
答案 0 :(得分:0)
<video controls="controls" width="200" height="200" src='<%# Eval ("Name","videos/{0}") %>'>"/>
应该是
<video controls="controls" width="200" height="200" src='<%# Eval ("Name","videos/{0}") %>'></video>
或
<video controls="controls" width="200" height="200" src='<%# Eval ("Name","videos/{0}") %>'/>
Media formats supported by the HTML audio and video elements
要制作适用于所有主流浏览器最新版本的HTML5视频,您可以使用source元素以WebM格式和MPEG H.264 AAC格式提供视频:
<video controls>
<source src="somevideo.webm" type="video/webm">
<source src="somevideo.mp4" type="video/mp4">
I'm sorry; your browser doesn't support HTML5 video in WebM with VP8 or MP4 with H.264.
<!-- You can embed a Flash player here, to play your mp4 video in older browsers -->
</video>