Last post Jul 13, 2018 07:19 PM by mudassarkhan
Jul 13, 2018 06:47 AM|vijaylakshmi|LINK
I have the following code in code behind
query = "";
query = "SELECT audio FROM Temple_learning ORDER By NEWID()";
cmd = new SqlCommand(query, conn);
SqlDataAdapter rs1 = new SqlDataAdapter(cmd);
DataSet ds1 = new DataSet();
DataTable dt1 = ds1.Tables;
audio = dt1.Rows.ToString(); // audio variable declared as public to be able accessed in the front end
why is not playing..
In the frontend
<div class="col-md-8"><audio src="<%=audio" type="audio/mp3" controls="controls"></audio>
Jul 13, 2018 06:53 AM|XIII|LINK
I noticed that you type: <%=audio but you don't close it with %>
Jul 13, 2018 09:06 AM|vijaylakshmi|LINK
Thats a typo error sir,
i recitified it.. it is still not coming
Jul 13, 2018 10:50 AM|PatriceSc|LINK
And you are 100% sure the src value is correct (you could use "view source" in your browser).
Also F12 Network allows to see what happens for the http query to this audio file and F12 Console may show messages. It's IMO best to always start by using this kind of simple tool to see what actually happens rather than trying to guess from the code.
Edit: audio is an url rather than actual audio data ? Not directly related but you could use SELECT TOP 1 audio to get a single row rather than maybe loading in memory multiple rows while using only the first one.
Jul 13, 2018 12:09 PM|mudassarkhan|LINK
How you have stored the Audio? Is it a FilePath or File as Binary data
Jul 13, 2018 01:14 PM|XIII|LINK
it is still not coming
When you replace that part of the code with the url that comes from your database query and simply make it as plain HTML, does it work then? First try to make it work with regular HTML then customize it to make it work with your database. In case of doubt,
start with the basics.
Jul 13, 2018 07:19 PM|mudassarkhan|LINK
Upload and Play MP3 Audio files
from Database using HTML5 Audio Player in ASP.Net