Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nw.js and audio-play #20

Open
RichardFoss opened this issue Apr 10, 2019 · 1 comment
Open

nw.js and audio-play #20

RichardFoss opened this issue Apr 10, 2019 · 1 comment

Comments

@RichardFoss
Copy link

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
Copy link
Author

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();
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant