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

  • Home
  • SEARCH
  • 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 7094115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:31:25+00:00 2026-05-28T08:31:25+00:00

How does one get the HTML5 Audio tag to work in a webworks app

  • 0

How does one get the HTML5 Audio tag to work in a webworks app with the Autoplay option?

Ex:
On document load Audio element’s src changed via javascript then audioElement.play() – this doesn’t work, you have to bind the click of another link or button to audioElement.play() and click AGAIN…

Any ideas?

function playSongNow(currentID) {
    var audioElement = document.createElement('audio');
    audioElement.setAttribute('autoplay', 'true');
    audioElement.setAttribute('preload', 'true');
    audioElement.setAttribute('src', 'http://' + sessionStorage.url + ':' + sessionStorage.port + '/rest/stream.view?u=' + sessionStorage.user + '&p=' + sessionStorage.pass + '&v=1.6.0&c=BerrySonic&id=' + currentID);
    audioElement.load();
    audioElement.addEventListener("load", function() {
        audioElement.play();
        $(".duration span").html(audioElement.duration);
        $(".filename span").html(audioElement.src);
    }, true);
    $('.play').click(function() {
        audioElement.play();
    });
    $('.pause').click(function() {
        audioElement.pause();
    });
    $('.volumeMax').click(function() {
        audioElement.volume=1;
    });
    $('.volumestop').click(function() {
        audioElement.volume=0;
    });
    $('.stop').click(function() {
        audioElement.pause();
        audioElement.currentTime = 0;
    });
    $('.playatTime').click(function() {
        audioElement.currentTime= 35; //Testing skipping so used 35
        audioElement.play();
    });
}

playSongNow is called by the HTML:

<a onclick="playSongNow('2f6d656469612f52616964426f782f4d757369632f4164656c652f32312f4164656c65202d2052756d6f7572204861732049742e6d7033');"><li>Rumour Has It</li></a>

NEW: Actually I think I’ve narrowed the issue down to :

audioElement.addEventListener("load", function() {
    audioElement.play();
    $(".duration span").html(audioElement.duration);
    $(".filename span").html(audioElement.src);
}, true);

I tried using “canplaythrough”
But neither works to determine when enough data has passed in to actually play because if you do:

audioElement.load();
audioElement.play();

I tried the following event:

audioElement.addEventListener('canplay', function() {
    alert('canplay');
    audioElement.play();
});

And this works but this doesn’t mean that the audio can play without buffering does it? It also immidiately fires the “canplaythrough” event.

Some guidance on these events would be handy.

  • 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-05-28T08:31:25+00:00Added an answer on May 28, 2026 at 8:31 am

    You can handle this with the ended event like the following :

    audioElement.addEventListener('ended', function(){
    playSongNow(......)
    }, false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does any one know if its possible to animate app.current.mainwindow.width so that you get
How does one get a slider working with jQuery. HTML: <head> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js></script> <script
How does one get a list of running applications as shown in the "Applications"
does any one know how to get the current motherboard, processor or HD temperature
When making a call to jQuery get , how does one specify HTML elements
Given: http://www.foo.com/bar.html#baz How does one get the baz ? I can't find this as
Given that acronym is removed in HTML 5, how does one get standards support
How does one get in the value of request.user into a TemplateTag? In the
does one perform better over the other in terms of indexing/quering etc ? e.g.
How does one go about authoring a Regular Expression that matches against all strings

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.