locked
Audio controls not working RRS feed

  • Question

  • User219039814 posted

    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();
    rs1.Fill(ds1);
    DataTable dt1 = ds1.Tables[0];


    audio = dt1.Rows[0][0].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>

    Friday, July 13, 2018 6:47 AM

Answers

  • User-1171043462 posted

    How you have stored the Audio? Is it a FilePath or File as Binary data

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 13, 2018 12:09 PM
  • User541108374 posted

    Hi,

    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.

    Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 13, 2018 1:14 PM

All replies

  • User541108374 posted

    Hi,

    I noticed that you type: <%=audio but you don't close it with %>

    Kris.

    Friday, July 13, 2018 6:53 AM
  • User219039814 posted

    Thats a typo error sir,

    i recitified it.. it is still not coming

    Friday, July 13, 2018 9:06 AM
  • User753101303 posted

    Hi,

    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.

    Friday, July 13, 2018 10:50 AM
  • User-1171043462 posted

    How you have stored the Audio? Is it a FilePath or File as Binary data

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 13, 2018 12:09 PM
  • User541108374 posted

    Hi,

    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.

    Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 13, 2018 1:14 PM