在我的项目中,有一个视频标签和两个按钮。我试图这样做,当我单击button1然后开始播放视频,而当我单击另一个按钮然后开始播放其他视频时。这两个视频都在我项目的video文件夹中。
这是test.aspx文件:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" href="css/test.css" media="all" />
</head>
<body>
<form id="form1" runat="server">
<div>
<video id="videoplr" width="500" controls="controls" runat="server"></video>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
</div>
</form>
</body>
</html>
这是c#文件背后的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
videoplr.Attributes["src"] = "C:\\Users\\Punam\\Desktop\\Project\\videos\\personal_talk.MP4";
}
protected void Button2_Click(object sender, EventArgs e)
{
videoplr.Attributes["src"] = "C:\\Users\\Punam\\Desktop\\Project\\videos\\Tags.MP4";
}
}
当我单击按钮时,则无法播放视频。我是asp.net的新手。