Jump to content

Recommended Posts

Hello All,

 

I am attempting to create some audio tags via JS. I am using the following code.

 

   

<script>
      var audioElement = document.createElement('audio');
      audioElement.setAttribute('src', '/lib/audio/01Gen002.ogg');
  audioElement.currentTime = 10;
      audioElement.play();
</script>

 

When I drop out the audioElement.currentTime line it works just fine, but that line produces the following error....

Error: uncaught exception: [Exception... "An attempt was made to use an object that is not, or is no longer, usable" 
code: "11" nsresult: "0x8053000b (NS_ERROR_DOM_INVALID_STATE_ERR)"  location: "http://base/bible/index/25 Line: 75"]

 

 

I am attempting to play the audio from a specific point and I am not having any luck. Am I using this element wrong?

 

Thanks in advance for the help.

Link to comment
https://forums.phpfreaks.com/topic/220673-audio-via-html5/
Share on other sites

Well I figured it out.

 

For the last 4 or 5 questions I posted on here, I got no response from really anyone.

 

So for anyone who might be helped by my solution, an event has to fire to bring this object back to a state where the currentTime property can be set.

 

Nate

 

Link to comment
https://forums.phpfreaks.com/topic/220673-audio-via-html5/#findComment-1143336
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.