0

Is it possible to force an Opening of Audacity when a user of my website clicks on a link to a .wav file?

I got somethink like this on my website:

<a href="link/to/wav/on/server">Click to Listen this awesome track</a>

I use AngularJs for the Front-End and NodeJs as a backend Server. The wav lays in a Subdirectory of the NodeJs server.

GuyWithCookies
  • 630
  • 2
  • 8
  • 21
  • It would be possible if Audacity had implemented a custom URL scheme, for example `audacity://` (similar to magnet links). – Midas Jun 08 '16 at 16:10

1 Answers1

0

You can't force the computer to launch Audacity in itself, this is up to users preference. What you can do, is prompt a download of the file to the client, whom browser will probably propose him to open it via a list of application that handle the file extension or to download it. You can achieve that like this:

var mime = require('mime'),
    fs = require('fs');

app.get('link/to/wav/on/server', function(req, res){

  var file = 'filelocationOnTheServer.wav';

  res.setHeader('Content-disposition', 'attachment; filename=nameYouWantToGiveit.wav');
  res.setHeader('Content-type', 'audio/wav'); // This will make the browser to use the most appropriate app according to it's preference.
  // res.setHeader('Content-type', 'application/octet-stream'); // This will never match to anything and will push the browser to ask the user what to do and to download it.

  fs.createReadStream(file).pipe(res);
});
rels
  • 715
  • 2
  • 7
  • 22