Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

HTML element <audio> not working in OSWeb > 2.1.0

Hi,

I developed a task which has an inline_html page with an <audio> element in OSWeb 2.0.1.0, and it works as intended. However, after I updated OSWeb to 2.1.0, it stopped working. I also tried the latest release of OSWeb, version 2.1.0.2.

I downgraded to 2.0.1.0, and it works fine again.

Comments

  • Hi,

    I have the same problem. Just to add more information, I found that actually no audio object methods no longer works as intended. For instance, a simple code like the one below (which check the user's sound) now returns an error: Uncaught TypeError: mySound.play is not a function

    <img id="check_sound" onClick="mySound.play();"></img>
    
    <script>
    var mySound = pool['mySound.mp3'].data;
    </script>
    

    This was not the case in earlier versions of OSWeb and downgrading makes it work again as signaled by SpacePenguins.

  • Hi again,

    I think I managed to find why audio tags are no longer functioning in OSWeb 2.1. In OSWeb 2.0.x, audio files have the audio type in the file pool. In OSWeb 2.1, audio files have the audioBuffer type, which explains why classic audio tags/methods are not functioning. Compare below the data type for the same file for both versions of OSWeb.

    OSWeb 2.0.x:

    OSWeb 2.1:

    I am not really familiar with the audioBuffer type but I found a work-around to play audio files, thank to this page on Mozilla's web docs. Everything can be done with a bit of javascript and the specific methods for the audioBuffer type, see below. The main idea is to create an audio source, then link the audio file to the audio source and finally link the audio source to the browser audio "manager".

    // Tell the browser that we intend to play audio files
    const audio_context = new (windo.AudioContext || window.webkitAudioContext)();
    const test_sound = pool["whathever_sound.wav"].data;
    
    // Functions
    function playSound(mySound) {
      // Create an audio source
      var source = audio_context.createBufferSource();
      // Tell the source which sound to play
      source.buffer = mySound;
      // Connect the audio source to the destination (source --> audio_context --> speakers)
      source.connect(audio_context.destination);
      // Play the audio source
      source.start(0);
    }
    
    playSound(test_sound)
    

    I've attached a minimal working example that works with OSWeb 2.1 (not tested with OSWeb 2.0.x). I hope this can help you.

  • I just tested the latest version of OSweb, 2.1.2.0 and the <audio> element dose not work in this version either.

  • Hi @SpacePenguins & @Silk,

    It canm be done with eveything inside an inline_HTML object. I've tested the following task with OSWeb 2.1.2.0 and again after updating to 2.2.1.1, using Chrome and using Edge in Windows. Worked without any issue. Not sure all browsers would run it, though (remains to be tested...).

    Hope this helps,

    Fab.

    Buy Me A Coffee

  • Hi @Fab @SpacePenguins @Silk ,

    Just as a little background to this. Indeed, as of OSWeb 2.1, the (newer) WebAudio API is used instead of the (classic) <audio> tags. The reason for this is that <audio> tags didn't work reliably on Safari and all iOS browsers, apparently because these implement certain security policies differently. (I'm not 100% sure about that, but it caused issues in any case.)

    — Sebastiaan

Sign In or Register to comment.