I'm trying to create a simple audio player with ASP.NET and C#. I'd like to use the audio tag of html5 to do so (I only target html5 for this sample) but my problem is that I can't access it with C#.
I'm working with visual studio, but I can't find any audio tag in the toolbox. So I tried putting in the audio tag as follows:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<audio controls="controls" autoplay="autoplay" id="audioplayer">
<source src="SeeU.mp3" type="audio/mpeg" />
<!-- if one source fails (e.g. cause browser does not support file format) automatically tries next source -->
<source src="SeeU.ogg" type="audio/ogg" />
Your browser does not support the audio element.
</audio>
</form>
</body>
</html>
But I can't access the audio element in c# like I would with asp elements:
audioplayer.pause();
I searched alot, but all samples on the audio tag I find never even specify an ID for it, much less explain how it's used in ASP.NET. My intent is to create some other buttons that will make the music play/pause/stop/change source etc.
EDIT: Alright, so now I know that the audio tag is client side only, I'll just leave the question like this in case someone else missed the notice too and finds this. Anyway, with the audio files being on the server side how would I request/send them from the server to my client html file?
To access the audio control on server side you can add the attribute runat=server inside the audio tag.
And you can access it and add Source file from server side Like this audioplayer.Src="your source file"