It could very well be that the deviceStorage API doesn't work well
from chrome. It so far has only been tested when running as part of an
app.

/ Jonas

On Fri, Dec 28, 2012 at 9:53 AM, Gasten Sauzande
<[email protected]> wrote:
> Sexta-feira, 28 de Dezembro de 2012 4:13:51 UTC+2, Jonas Sicking escreveu:
>> On Wed, Dec 26, 2012 at 2:47 PM,  <[email protected]> wrote:
>>
>> > So i am trying to develop a app and i need to get every single song that 
>> > the user has and how often they listen to each one and other sorts of 
>> > statistics, but mainly just get the songs into my app. I am using the B2G 
>> > extension for Firefox Browser. How can i do that?
>>
>>
>>
>> You can use the DeviceStorage API [1] to get the "music" folder and
>>
>> enumerate all the files in that folder.
>>
>>
>>
>> The resulting code would look something like:
>>
>>
>>
>> var music = navigator.getDeviceStorage("music");
>>
>> var musicBlobs = [];
>>
>> var enum = music.enumerate();
>>
>> enum.onsuccess = function(e) {
>>
>>   blob = enum.result;
>>
>>   if (!blob) {
>>
>>     return; // done enumerating
>>
>>   }
>>
>>   musicBlobs.push(blob);
>>
>>   enum.continue();
>>
>> }
>>
>>
>>
>>
>>
>> [1] https://wiki.mozilla.org/WebAPI/DeviceStorageAPI
>>
>>
>>
>> / Jonas
>
> So i found something on the web that allows me to read the data in a mp3 so i 
> think that i can use that method to do what i want in B2G with the code that 
> you gave me, but i am having another problem, i can't output data to an 
> element on the B2G simulator. Here is the code that i am using and the 
> problems are commented in the code:
>
> <script type="text/javascript" src="scripts/binaryajax.js" ></script>
> <script type="text/javascript" src="scripts/id3.js" ></script>
> <span class="artist1" id="output"><button 
> onclick="test1()">Details</button></span>
> </div>
> <script>
> var music = navigator.getDeviceStorage("music");
> var musicBlobs = [];
> var enu = music.enumerate();
> enu.onsuccess = function(e) {
>   blob = enu.result;
>   if (!blob) {
>     return; //
>   }
>   musicBlobs.push(blob);  enu.continue();
> }
> document.getElementById("someTag").innerHTML+="<p>"+musicBlobs+"</p>";/*This 
> isn't working on the simulator and on my browser(because getDeviceStorage() 
> isn't available in chrome).*/
> function test1() {
>         var file = "monomania.mp3";/*Just getting a random mp3 in the same 
> directory to print it's details*/
>
>         var out = document.getElementById("output");
>         out.innerHTML = "Loading file \"" + file + "\"..\r\n";
> /*This works on my browser(Chrome24 beta-m) perfectly but when i go to the 
> B2G simulator
> it doesn't show anything. I can't change the content on "output" via 
> innerHTML, i don't
>  know if it's something that B2G does or if there is something that i'm doing 
> wrong.*/
> /*START: Getting the song data and printing it*/
>         function callback() {
>                 out.innerHTML += "Getting all tags\r\n";
>
>                 var tags = ID3.getAllTags(file);
>
>                 out.innerHTML += "Found: \r\n"
>                         + "artist: " + tags["artist"] + "\r\n"
>                         + "title: " + tags["title"] + "\r\n"
>                         + "album: " + tags["album"] + "\r\n"
>                         + "year: " + tags["year"] + "\r\n"
>                         + "comment: " + tags["comment"] + "\r\n"
>                         + "genre: " + tags["genre"] + "\r\n"
>                         + "track: " + tags["track"] + "\r\n"
>         };
>
>         ID3.loadTags(file, callback);
> }
> /*END: Getting the song data and printing it*/
> _______________________________________________
> dev-b2g mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-b2g
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to