3

This is how I can include a audio file via html:

<audio controls>
  <source  src="audio/was_ist_ist.ogg" />
</audio>

Now I want to do the same only using javascript. I have this so far:

var audioElement = new Audio("audio/was_ist_ist.ogg");

How do I enable the default controls here?

2

2 Answers 2

3
var au = new Audio("http://...ogg");
au.controls = true;
document.body.appendChild(au);

example fiddle: http://jsfiddle.net/QKUgX/

Sign up to request clarification or add additional context in comments.

Comments

1
var audio= new Audio(url);
audio.attr('controls',true).appendTo(selector);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.