javascript - Firefox OS - save file in the app directory -


i developing audio editing application firefox os (github). uses, playback, howler js (link).

on firefox os, can play audio files within application folder (does not matter where) passing url howler, but, if want create new audio files (recording audio), need save them somewhere on internal memory.

the problem : howler js not support playback of blob files (even when try url - window.url.createobjecturl(blob)).

is there way save files app creates directly withing application folder? (so able reference them using url?)

if not, what's way go?

  1. any file packaged in app can accessed using relative url. means don't have blob or anything.

  2. it won't possible save assets (at runtime) in app folder far can tell. way access app folder requires have webapp-manage permission , application has certified.

  3. it's unlikely howler.js doesn't work blob urls not different other url. there might bug in firefoxos though.

from documentation, said should use "format" property set file format of url if isn't possible url

var sound = new howl({    urls: [url.createobjecturl(blob)],    format: 'mp3',    .... }) 

as side note, have each use of url.createobjecturl(blob), should call url.revokeobjecturl(url). haven't read understand, browser keep blob in memory long url isn't revoked. each call createobjecturl method create new url reference blob. in order free blob, you'll have free urls.

from documentation, urls won't revoked themselves... means if loose reference url created, web application leak memory blob won't freed unless unload event called on document.

so write application, i'd suggest creating pool of urls can manage.

function urlpool() {   this.assets = new map() }  urlpool.prototype.geturl = function (asset, blob) {   var url = this.assets.get(asset)   if (!url) {     url = url.createobjecturl(blob)     this.assets.set(asset, url)   }   return url }  urlpool.prototype.removeurl = function (asset) {   var url = this.assets.get(asset)   if (url) {     url.revokeobjecturl(url)     this.assets.delete(asset)   } } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -