Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7891509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:38:10+00:00 2026-06-03T06:38:10+00:00

I want create a html5 audio in dynamic and play it,here is the code:

  • 0

I want create a html5 audio in dynamic and play it,here is the code:

 function playAnotherMusic(playUrl){
                var audioElement = document.createElement('audio'); 
                audioElement.setAttribute('src', playUrl); 
                audioElement.setAttribute('controls', true); 
                audioElement.setAttribute('preload', true); 
                audioElement.setAttribute('type', 'audio/mpeg'); 


                audioElement.addEventListener("load", function() { 
                audioElement.play(); 
                }, true);

                console.log(playUrl);
                audioElement.load();

  }

However it doesn’t work,the firebug assigin me “HTTP "Content-Type" of "audio/mpeg" is not supported.“

how can I solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:38:12+00:00Added an answer on June 3, 2026 at 6:38 am

    You need to append the audio element to the an existing element.
    This would be something like

    document.getElementById("my_audio_div").appendChild(audioElement);
    

    Idealy, this should be done before you add the event listener, but after setting all the attributes

    Also try audio/mp3 instead:
    audioElement.setAttribute(‘type’, ‘audio/mp3’);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a standalone HTML5 document that utilizes SQlite. I want to
Can anyone help me create a javascript/jquery function to control the HTML5 audio tag
I want to create a new element with html5 data attributes defined, however they
I want to create screen-in-screen functionality in my HTML5 game, and to do this
I want to create a multi file uploder using HTML5 and PHP5. I don't
I want to create two vertical divs using HTML5, CSS3 and JQuery. One Div
I'm trying to create a standalone HTML5 document that utilizes SQlite or some other
I have created an HTML5 audio player but basically I want it to be
i am new in html5 , i want to create a event listener on
I want to create a chat room using HTML5 web sockets, but am pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.