Comments (7)
The recorder object is intended to be reused and thus holds onto the stream
and the users permissions. The code you provided will stop the stream
properly, if you want the memory to be freed, you should also remove all
your event listeners as well. Javascript doesn't provide a nice way to
destroy objects so I left it out. When the recorder stops, the workers are
destroyed and the audio nodes disconnected from the destination so the
memory usage should minimal, and no extraneous events should be firing. Let
me know if this is in line with what you experience.
On 4 May 2015 at 16:09, Kequc [email protected] wrote:
The first time an instance of Recorder is created, the user is asked for
access to their microphone. In chrome this adds a red icon to the tab.
There isn't any way seemingly to end the stream.In my application I'm creating a new Recorder instance each time I want to
record, is this an incorrect way to do things? I've added this.recorder.addEventListener 'stop', =>
if recorder && recorder.stream
recorder.stream.stop()It would be nice if I could de-initialise the stream as an intended
feature of the library.—
Reply to this email directly or view it on GitHub
#13.
from opus-recorder.
Forgot to say thanks for your comment, and I will consider adding a destroy() method if It could be implemented nicely.
from opus-recorder.
The reason I suppose I bring it up is that users might be confused and think their browser is still listening to them. Which it could. I love this library by the way, I was dealing with just raw pcm before I found this. Good work, everyone past and present who has worked on it.
from opus-recorder.
Here is my solution to do what I wanted. Taking into consideration that you said the Recorder is intended to be reused.
_closeStream: =>
# Close recorder stream
if @recorder && @recorder.stream
@recorder.stream.stop()
@status.ready = false
start: =>
# Start recording
return false if @status.active || @status.ready
@status.active = true
if @recorder
@recorder.initStream()
else
@recorder = new Recorder
recordOpus:
stream: true
@recorder.addEventListener 'streamReady', =>
if @status.active
@status.ready = true
@recorder.start()
else
@_closeStream()
@recorder.addEventListener 'stop', =>
@_closeStream()
true
stop: =>
# Stop recording
return false unless @status.active
@status.active = false
if @recorder
@recorder.stop()
true
The idea is that a stream is closed when the recorder is stopped and a new stream is initialised on start. This serves my needs. I hope it's not too messy looking.
from opus-recorder.
Looks good. I believe you can safely call start and stop and if recorder
is not in the right state nothing will happen. Recorder is also storing its
state in recorder.state (inactive, recording, or paused) if you want to
read from it as well.
On 5 May 2015 at 11:55, Kequc [email protected] wrote:
Here is my solution to do what I wanted. Taking into consideration that
you said the Recorder is intended to be reused._closeStream: =>
Close recorder stream
if @recorder && @recorder.stream
@recorder.stream.stop()
@status.ready = falsestart: =>
Start recording
return false if @status.active || @status.ready
@status.active = true
if @recorder
@recorder.initStream()else
@recorder = new Recorder
recordOpus:
stream: true@recorder.addEventListener 'streamReady', => if @status.active @status.ready = true @recorder.start() else @_closeStream() @recorder.addEventListener 'stop', => @_closeStream()
stop: =>
Stop recording
return false unless @status.active
@status.active = false
@recorder.stop()
The idea is that a stream is closed when the recorder is stopped and a new
stream is initialised on start. This serves my needs. I hope it's not too
messy looking.—
Reply to this email directly or view it on GitHub
#13 (comment)
.
from opus-recorder.
Heads-up that i have experienced empty buffers when starting recording
immediately after initializing the stream. Which is one of the reasons I
initialize the stream on init instead of recording start.
On 5 May 2015 at 14:52, Chris Rudmin [email protected] wrote:
Looks good. I believe you can safely call start and stop and if recorder
is not in the right state nothing will happen. Recorder is also storing its
state in recorder.state (inactive, recording, or paused) if you want to
read from it as well.On 5 May 2015 at 11:55, Kequc [email protected] wrote:
Here is my solution to do what I wanted. Taking into consideration that
you said the Recorder is intended to be reused._closeStream: =>
Close recorder stream
if @recorder && @recorder.stream
@recorder.stream.stop()
@status.ready = falsestart: =>
Start recording
return false if @status.active || @status.ready
@status.active = true
if @recorder
@recorder.initStream()else
@recorder = new Recorder
recordOpus:
stream: true@recorder.addEventListener 'streamReady', => if @status.active @status.ready = true @recorder.start() else @_closeStream() @recorder.addEventListener 'stop', => @_closeStream()
stop: =>
Stop recording
return false unless @status.active
@status.active = false
@recorder.stop()
The idea is that a stream is closed when the recorder is stopped and a
new stream is initialised on start. This serves my needs. I hope it's not
too messy looking.—
Reply to this email directly or view it on GitHub
#13 (comment)
.
from opus-recorder.
Stream now stops when recording is finished.
from opus-recorder.
Related Issues (20)
- How to use with Vite? HOT 5
- The first recording is not saved in Safari on IOS 15.1 HOT 1
- Robotic, torn audio on IOS 15.1 HOT 3
- Issue while using decoder with React application HOT 11
- Recorder output file size too small - Vue.js HOT 4
- building and running on windows 10 HOT 4
- Error running waveRecorder.html example HOT 3
- using waveform-playlist with opus-recorder HOT 1
- Uncaught TypeError: Cannot read properties of undefined (reading 'length')
- Not working with Vite + Vue 3
- wasm streaming compile failed: TypeError: Could not download wasm module falling back to ArrayBuffer instantiation how can i resolve this issue ? HOT 3
- Convert 16 bit signed int to 32 bit float HOT 8
- Audio distorted after 30 seconds HOT 6
- few seconds of recording are missing at the beginning (especially on IOS)
- Play pages real-time HOT 2
- ondataavailable not fired with waveWorker
- TypeScript definitions HOT 1
- Opus Player
- Is it possible to Decode two audio sources HOT 4
- Error webassembly.compile HOT 1
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 opus-recorder.