Comments (17)
Doesn't speaker.destroy()
do this or no? You can create a new Speaker instance once you're ready to start playing audio again.
from node-speaker.
Oh, nvm, speaker.destroy()
doesn't even exist, haha! Ok, so let's add that and then this feature request should be fulfilled.
from node-speaker.
speaker has no method destroy
from node-speaker.
Sorry, does calling speaker.close()
do the trick though?
from node-speaker.
Yes but i get a segfault
from node-speaker.
i guess we could then close this issue as the segfault is a different issue
from node-speaker.
Well that's not good! Can you show me some repro code?
from node-speaker.
It's cool man we can just re-title the issue
from node-speaker.
var lame = require('lame');
var icecast = require('icecast');
var Speaker = require('speaker');
var speaker = new Speaker();
var decoder = new lame.Decoder();
decoder.pipe(speaker);
// URL to a known Icecast stream
var url = 'http://shoutmedia.abc.net.au:10426/';
// connect to the remote stream
var station = icecast.get(url, function (res) {
// log the HTTP response headers
console.error(res.headers);
// log any "metadata" events that happen
res.on('metadata', function (metadata) {
var parsed = icecast.parse(metadata);
console.error(parsed);
});
// Let's play the music (assuming MP3 data).
// lame decodes and Speaker sends to speakers!
res.pipe(decoder);
});
setTimeout(function(){
speaker.close();
}, 5000);
from node-speaker.
this is what i am doing right now - maybe i am being stupid with it
from node-speaker.
I am on mac osx mavericks
from node-speaker.
Side note: use icecast
module instead of radio-stream
. The former replaces the later, and the later is just around for legacy purposes.
from node-speaker.
thanks!
basically what i am trying to do is the icecast example except with a stop that stops playback instantly
from node-speaker.
maybe icecast should have a "stop" on it
from node-speaker.
updated code sample with icecast - segfault on close still.
from node-speaker.
Been doing some more testing and can make the seg fault happen when you fill the speaker.audio_handle with null
I suspect that the binding is not closed yet and the close then clears the buffer so the binding get crap data
from node-speaker.
I was able to repro the segfault easily with the "sine.js" example script, with the diff below:
diff --git a/examples/sine.js b/examples/sine.js
index 2658f05..bd1a22c 100644
--- a/examples/sine.js
+++ b/examples/sine.js
@@ -27,7 +27,11 @@ sine.samplesGenerated = 0;
sine._read = read;
// create a SineWaveGenerator instance and pipe it to the speaker
-sine.pipe(new Speaker());
+var s = new Speaker();
+sine.pipe(s);
+setTimeout(function() {
+ s.close();
+}, 500);
// the Readable "_read()" callback function
function read (n) {
from node-speaker.
Related Issues (20)
- TypeScript missing "device" option
- Memory Leak HOT 1
- Mac OS install error HOT 1
- Failed to install with another backend on Linux
- "binding.node" is not a valid Win32 appliaction
- Cannot use this module from TypeScript HOT 2
- Noise at the beginning of playback
- Change audio output device on Win32 Backend HOT 1
- Does Not Work With Node.js 15+ HOT 3
- Crashes when using in electron app HOT 3
- License listed as MIT, but some of the source lists LGPL HOT 5
- Can't install: mpg123_cpu not defined HOT 2
- Support M1 macOS HOT 6
- Need help for a setup HOT 2
- Trouble installing with M2 chip for Mac HOT 1
- npm install error
- Raspberry Pi 4 (Debian) node-gyp build fails HOT 6
- Installation Error om mac M2 HOT 2
- issues in installing node-speaker
- 'Error: Module did not self-register.' with Worker Threads
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-speaker.