Click here to Skip to main content
15,891,722 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have written a code to fetch uploaded videos from the folder and play it on the webpage . i am using WMP . it show only a midia player but not play the video in IE.and in other browsers it even does not show the midia player . what could be the reson .please help. hare is the code.
HTML



What I have tried:

Code in ASPX
<body>
<form id="form1" runat="server">


<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />
<asp:Literal ID="ItPlayer" runat="server">


</form>
</body>


Code in .CS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace Final
{
public partial class index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnUpload_Click(object sender, EventArgs e)
{
if(FileUpload1.HasFile)
{
string fileName = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("/Uploads/" + fileName));
StringBuilder sb = new StringBuilder();

string value = "http://localhost:17998/Final/Uploads/" + fileName;
sb.Append("<object classid='clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6' id= 'Player1' width='424'height='379'>");
sb.Append("<param name="URL" value="" +="" ""="" />");
sb.Append("<param name="AutoStart" value="true" />");
sb.Append("<param name="ShowControls" value="true" />");
sb.Append("<param name="ShowStatusBar" value="true" />");
sb.Append("<param name="allowfullscreen" value="true" />");
sb.Append("<param name="animationatstart" value="true" />");
sb.Append("<param name="transparentatstart" value="true" />");
sb.Append("<param name="ShowDisplay" value="true" />");
sb.Append("<param name="stretchToFit" value="true" />");
sb.Append("<embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/' width='500' height='350' filename='" + value + "' src='" + value + "' autostart='1' showcontrols='1' showstatusbar='1' showdisplay='1'>");
sb.Append("</embed>");
sb.Append("</object>");
ItPlayer.Text = sb.ToString();
}

}
}
}
Posted
Comments
[no name] 29-Jun-16 4:09am    
I don't know, if WMP is supported in actual web browser. If you use browser other than IE, then you need to install extra plugin for that. Too bad. The better way is to use HTML5 video and is supported in all modern browser.
Member 12603716 29-Jun-16 22:33pm    
Sir i have tried HTML5 video tag in asp.net but it gives only controls on the webpage and does not play the video.hare is the code

<body>
<form id="form1" runat="server">
<div>




<video src="C:\Users\FRENDZ\Downloads\Video\a.mp4" controls="controls">
</video>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900