0

I'm trying to integrate the file-uploader-service Filepicker.io into a processing.js sketch I already made. It is fully functional locally, where you could choose a audio source from your computer and it does magic things with this audio. Now I'd like to let the user choose a file locally (no uploads) and process the same online, but I can't get it to work to read the file (I can get the api-key of the file)

My index.html

<!DOCTYPE html>
<html>
<head>
    <script src="processing-1.4.1.min.js"></script>
    <script type="text/javascript" src="//api.filepicker.io/v1/filepicker.js"></script>
</head>
<body>
    <input type="filepicker" data-fp-apikey="*******" 
    data-fp-mimetypes="audio/wav, audio/mpeg" data-fp-container="modal" 
    data-fp-services="BOX,COMPUTER,DROPBOX"
    onchange="alert(event.fpfile.url)">

    <canvas data-processing-sources="minimFFT_test.pde Freqdot.pde Spec.pde"></canvas>
</body>
</html>

and my minimFFT_test.pde, note the minim.loadFile()(javadoc) method below:

import ddf.minim.analysis.*;
import ddf.minim.*;

Minim minim;
AudioPlayer song;

void setup() {
  size(960, 1000);
  minim = new Minim(this);
  //***it should read here the path to the selected file***
  song = minim.loadFile(PATHTOFILE);  
  song.loop();   
}
dh762
  • 2,259
  • 4
  • 25
  • 44
  • what do you mean with "can't get it to work"? Where does it break down? Are there console errors that tell us which function is failing, are you mixing protocols that cause CORS errors, etc (remember that an http:// site is generally forbidden to access file:/// resources)? Where is `PATHTOFILE` coming from? (it doesn't look like it's being passed in, the minim initialization code might need to be in its own `loadFile(String filename)` function, called by JavaScript after the filepicker does its job). Lots of questions before an answer can be given. – Mike 'Pomax' Kamermans Jun 09 '13 at 14:44
  • Honestly, I don't know how to approach this. The PATHTOFILE is just the local path. Yes I don't know how to pass it in. – dh762 Jun 10 '13 at 10:34
  • 2
    If you're doing web/Processing mixing, have a look at http://processingjs.org/articles/PomaxGuide.html for how to make your page JS and the sketch code talk to each other. – Mike 'Pomax' Kamermans Jun 10 '13 at 12:00

0 Answers0