Search code examples
javascriptfirefox-os

Firefox OS - Busted XMLHttpRequest arraybuffer requests on physical hardware


I received a Flame device at MozFest in London a couple weeks back. Excited, I decided to port one of the projects we workshoped to the new device.

I'm having a couple last minute issues finishing up the app (http://hearushere.nl/app/). Effectively the audio requests are not processed on the physical device (it works great in the Firefox OS 2.1 simulator, and in Firefox proper/desktop). The requests as follows never return:

  function handleTrackDetail() {
    var detail = JSON.parse(this.responseText);
    var request = new XMLHttpRequest();
    var url = detail.stream_url + '?client_id=' + scClientId;
    console.log(url);
    request.open("GET", url, true);
    request.responseType = "arraybuffer";
    request.onload = function() {
      console.log('GOT AUDIO DATA!');
      context.decodeAudioData(request.response, function(buffer) {
        var track = tracksDict[detail.id];
        console.log(track.id + ' buffered and decoded...');
        track.source = context.createBufferSource();
        track.source.buffer = buffer;
        track.source.loop = true;
        track.gainNode = context.createGain();
        track.source.connect(track.gainNode);
        track.gainNode.connect(context.destination);
        track.gainNode.gain.value = 0.0;
        track.source.start(0);
      }, function(error) {
        console.log('ERROR...');
      });
    }
    request.send();
  }

Maybe "arraybuffer" type?

Bonus points if someone can explain to me why the geolocation request works only SOMETIMES, and is mostly complete shit:

navigator.geolocation.watchPosition(function(position) {
  console.log('Latitude: ' + position.coords.latitude + ' Longitude: ' + position.coords.longitude);
} 

Solution

  • I flashed to 2.2 from 2.1, and the problem. . .just went away.