<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 格式,不支持其他格式 我想让这个应用程序支持所有格式
最佳答案
<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>
关于c# - 使用数据列表从 asp.net 中的文件夹绑定(bind)视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22139805/