匿名者,
如果您仍然遇到此问题,请尝试以下代码...
在 aspx 中:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:AsyncFileUpload ID="AsyncFileUpload1" runat="server" CompleteBackColor="White"
OnUploadedComplete="AsyncFileUpload1_UploadedComplete" OnUploadedFileError="AsyncFileUpload1_UploadedFileError"
OnClientUploadComplete="Success" OnClientUploadError="Error" />
</div>
<div>
<asp:Button runat="server" ID="btnUpload" Text="Upload" Width="84px" OnClick="btnUpload_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<!--STYLE SELECTOR-->
<div>
<h3>
VMB Explaining the stage
</h3>
</div>
</div>
<!-- MEDIA PLAYER -->
<sil:MediaPlayer ID="MediaPlayer1" runat="server" Width="600" Height="440" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
还注册程序集
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="sil" %> // Video Player
在 aspx.cs 中
protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
//Fired on the server side when the file successfully uploaded
if (AsyncFileUpload1.HasFile)
{
_strFilePath = AppDomain.CurrentDomain.BaseDirectory + "Uploads\\" + AsyncFileUpload1.FileName;
AsyncFileUpload1.SaveAs(_strFilePath);
Label1.Text = "Received " + AsyncFileUpload1.FileName + " Content Type " + AsyncFileUpload1.PostedFile.ContentType;
PlayUploadedFile();
}
}
private void PlayUploadedFile()
{
//Here is my Code
#region Media Player initial settings
MediaPlayer1.AutoPlay = true;
MediaPlayer1.ScaleMode = System.Web.UI.SilverlightControls.ScaleMode.Zoom;
MediaPlayer1.MediaSource = _strFilePath;
MediaPlayer1.MediaSkinSource = "~/skin/Custom.xaml";
#endregion
}
protected void AsyncFileUpload1_UploadedFileError(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
Label1.Text = "Error!!";
//Fired on the server side when the loaded file is corrupted
//Display some error message here
}
对于视频播放器,您最初必须对此进行调查
您需要参考 SilverlightApplication.Web.dll 和 System.Web.Silverlight.dll
就这样。
希望这将彻底解决您的问题:)