audio-play icon indicating copy to clipboard operation
audio-play copied to clipboard

nw.js and audio-play

Open RichardFoss opened this issue 5 years ago • 1 comments

I have been trying to play an mp3 under nw.js (26.2) in Windows, and haven't had any success. I rebuilt (node-gyp) the speaker module, giving it the correct nw.js version, but still no luck. My code is simple:

const playBeep = require('audio-play'); // npm module to play beep for configuration const loadBeep = require('audio-loader'); . . loadBeep('./solemn.mp3').then(playBeep); // play the beep

But I would like to play multichannel wav files as well. Has it been tested under nw.js, and is there something I should be modifying/adding?

RichardFoss avatar Apr 10 '19 15:04 RichardFoss

I have solved my nw.js playback issue by using browserify (thanks to Sean Devonport), but am now confronting playback of multichannel wav files under Windows (10). Here is an object that I wrote, in particular setting the 'numberOfChannels' of the audio buffer to 8. However, I only get 2 channels playing.

// WAV player object var WAVPlayer = { sampleBuffer: 0, player: 0, load: function(wavFile) { window.audioPlay.load(wavFile) .then((buffer) => { this.sampleBuffer = buffer; this.sampleBuffer.numberOfChannels = 8; console.log("file loaded into buffer", wavFile); this.playWav(); fileLoaded = 1; }); }, playWav: function() { console.log("Playing file"); quarterFrames = 0; // reset quarter frames this.player = window.audioPlay.play(this.sampleBuffer, {volume: 1 }, () => { console.log('Played Wav file'); mySocket.emit('wavFileEnd'); }); wavTimer.setInterval(onQuarterFrame, '', '8333u'); // start quarter frame interval timer }, stop: function() { // Stop play back of current wav file this.player.pause(); wavTimer.clearInterval(); } }

RichardFoss avatar Apr 11 '19 16:04 RichardFoss