Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

<audio> elements fail to load/play content #42

Open
kennystrawnmusic opened this issue Sep 28, 2014 · 2 comments
Open

<audio> elements fail to load/play content #42

kennystrawnmusic opened this issue Sep 28, 2014 · 2 comments

Comments

@kennystrawnmusic
Copy link

As per @Swader's report in the CDE bug tracker, elements seem to work fine on the desktop... but unfortunately not in the mobile CADT. Definitely an issue that needs to be worked out...

@mmocny
Copy link
Member

mmocny commented Nov 3, 2014

This is related to MobileChromeApps/mobile-chrome-apps/issues/184 I think.

In the mean time, as a workaround, you can play local files programmatically by loading them with XHR and using an audioContext:

    var audioCtx = new window.AudioContext;
    function play(url) {
      var request = new XMLHttpRequest();
      request.open('GET', url, true);
      request.responseType = 'arraybuffer';

      request.onload = function() {
        audioCtx.decodeAudioData(request.response, function(buffer) {
          var source = audioCtx.createBufferSource();
          source.buffer = buffer;
          source.connect(audioCtx.destination);
          source.start(0);
        }, function(e) {
          console.log('Error decoding audio', e);
        });
      }

      request.send();
    }

(Note: do make sure not to create a new audioContext each time, as there is a firm limit on how many can be open)

@Swader
Copy link

Swader commented Dec 12, 2014

What is the status of this? Will it be fixed in the foreseeable future, or should we rely on the workaround?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants