node-mac-recorder 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +52 -5
- package/package.json +1 -1
- package/test-audio-controls.js +104 -0
package/index.js
CHANGED
|
@@ -37,7 +37,7 @@ class MacRecorder extends EventEmitter {
|
|
|
37
37
|
|
|
38
38
|
this.options = {
|
|
39
39
|
includeMicrophone: false, // Default olarak mikrofon kapalı
|
|
40
|
-
includeSystemAudio:
|
|
40
|
+
includeSystemAudio: false, // Default olarak sistem sesi kapalı - kullanıcı explicit olarak açmalı
|
|
41
41
|
quality: "medium",
|
|
42
42
|
frameRate: 30,
|
|
43
43
|
captureArea: null, // { x, y, width, height }
|
|
@@ -110,8 +110,8 @@ class MacRecorder extends EventEmitter {
|
|
|
110
110
|
*/
|
|
111
111
|
setOptions(options = {}) {
|
|
112
112
|
this.options = {
|
|
113
|
-
includeMicrophone: options.includeMicrophone
|
|
114
|
-
includeSystemAudio: options.includeSystemAudio
|
|
113
|
+
includeMicrophone: options.includeMicrophone === true, // Explicit true required, default false
|
|
114
|
+
includeSystemAudio: options.includeSystemAudio === true, // Explicit true required, default false
|
|
115
115
|
captureCursor: options.captureCursor || false,
|
|
116
116
|
displayId: options.displayId || null, // null = ana ekran
|
|
117
117
|
windowId: options.windowId || null, // null = tam ekran
|
|
@@ -121,6 +121,53 @@ class MacRecorder extends EventEmitter {
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Mikrofon kaydını açar/kapatır
|
|
126
|
+
*/
|
|
127
|
+
setMicrophoneEnabled(enabled) {
|
|
128
|
+
this.options.includeMicrophone = enabled === true;
|
|
129
|
+
return this.options.includeMicrophone;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Sistem sesi kaydını açar/kapatır
|
|
134
|
+
*/
|
|
135
|
+
setSystemAudioEnabled(enabled) {
|
|
136
|
+
this.options.includeSystemAudio = enabled === true;
|
|
137
|
+
return this.options.includeSystemAudio;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Mikrofon durumunu döndürür
|
|
142
|
+
*/
|
|
143
|
+
isMicrophoneEnabled() {
|
|
144
|
+
return this.options.includeMicrophone === true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Sistem sesi durumunu döndürür
|
|
149
|
+
*/
|
|
150
|
+
isSystemAudioEnabled() {
|
|
151
|
+
return this.options.includeSystemAudio === true;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Audio ayarlarını toplu olarak değiştirir
|
|
156
|
+
*/
|
|
157
|
+
setAudioSettings(settings = {}) {
|
|
158
|
+
if (typeof settings.microphone === 'boolean') {
|
|
159
|
+
this.setMicrophoneEnabled(settings.microphone);
|
|
160
|
+
}
|
|
161
|
+
if (typeof settings.systemAudio === 'boolean') {
|
|
162
|
+
this.setSystemAudioEnabled(settings.systemAudio);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
microphone: this.isMicrophoneEnabled(),
|
|
167
|
+
systemAudio: this.isSystemAudioEnabled()
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
124
171
|
/**
|
|
125
172
|
* Ekran kaydını başlatır (macOS native AVFoundation kullanarak)
|
|
126
173
|
*/
|
|
@@ -266,8 +313,8 @@ class MacRecorder extends EventEmitter {
|
|
|
266
313
|
try {
|
|
267
314
|
// Native kayıt başlat
|
|
268
315
|
const recordingOptions = {
|
|
269
|
-
includeMicrophone: this.options.includeMicrophone
|
|
270
|
-
includeSystemAudio: this.options.includeSystemAudio
|
|
316
|
+
includeMicrophone: this.options.includeMicrophone === true, // Only if explicitly enabled
|
|
317
|
+
includeSystemAudio: this.options.includeSystemAudio === true, // Only if explicitly enabled
|
|
271
318
|
captureCursor: this.options.captureCursor || false,
|
|
272
319
|
displayId: this.options.displayId || null, // null = ana ekran
|
|
273
320
|
windowId: this.options.windowId || null, // null = tam ekran
|
package/package.json
CHANGED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const MacRecorder = require('./index');
|
|
4
|
+
|
|
5
|
+
async function testAudioControls() {
|
|
6
|
+
console.log('🎵 Audio Control Test');
|
|
7
|
+
console.log('====================\n');
|
|
8
|
+
|
|
9
|
+
const recorder = new MacRecorder();
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
// Test initial state
|
|
13
|
+
console.log('📋 Initial Audio State:');
|
|
14
|
+
console.log(` Microphone: ${recorder.isMicrophoneEnabled() ? '🎤 ON' : '🔇 OFF'}`);
|
|
15
|
+
console.log(` System Audio: ${recorder.isSystemAudioEnabled() ? '🔊 ON' : '🔇 OFF'}\n`);
|
|
16
|
+
|
|
17
|
+
// Test individual controls
|
|
18
|
+
console.log('🔧 Testing Individual Controls:\n');
|
|
19
|
+
|
|
20
|
+
console.log(' Enabling microphone...');
|
|
21
|
+
recorder.setMicrophoneEnabled(true);
|
|
22
|
+
console.log(` Microphone: ${recorder.isMicrophoneEnabled() ? '🎤 ON' : '🔇 OFF'}`);
|
|
23
|
+
|
|
24
|
+
console.log(' Enabling system audio...');
|
|
25
|
+
recorder.setSystemAudioEnabled(true);
|
|
26
|
+
console.log(` System Audio: ${recorder.isSystemAudioEnabled() ? '🔊 ON' : '🔇 OFF'}\n`);
|
|
27
|
+
|
|
28
|
+
console.log(' Disabling microphone...');
|
|
29
|
+
recorder.setMicrophoneEnabled(false);
|
|
30
|
+
console.log(` Microphone: ${recorder.isMicrophoneEnabled() ? '🎤 ON' : '🔇 OFF'}`);
|
|
31
|
+
|
|
32
|
+
console.log(' Disabling system audio...');
|
|
33
|
+
recorder.setSystemAudioEnabled(false);
|
|
34
|
+
console.log(` System Audio: ${recorder.isSystemAudioEnabled() ? '🔊 ON' : '🔇 OFF'}\n`);
|
|
35
|
+
|
|
36
|
+
// Test bulk settings
|
|
37
|
+
console.log('🔧 Testing Bulk Audio Settings:\n');
|
|
38
|
+
|
|
39
|
+
console.log(' Setting both to ON...');
|
|
40
|
+
let settings = recorder.setAudioSettings({
|
|
41
|
+
microphone: true,
|
|
42
|
+
systemAudio: true
|
|
43
|
+
});
|
|
44
|
+
console.log(` Result: Microphone=${settings.microphone ? 'ON' : 'OFF'}, System Audio=${settings.systemAudio ? 'ON' : 'OFF'}\n`);
|
|
45
|
+
|
|
46
|
+
console.log(' Setting microphone OFF, system audio ON...');
|
|
47
|
+
settings = recorder.setAudioSettings({
|
|
48
|
+
microphone: false,
|
|
49
|
+
systemAudio: true
|
|
50
|
+
});
|
|
51
|
+
console.log(` Result: Microphone=${settings.microphone ? 'ON' : 'OFF'}, System Audio=${settings.systemAudio ? 'ON' : 'OFF'}\n`);
|
|
52
|
+
|
|
53
|
+
// Test recording with different audio settings
|
|
54
|
+
const testOutput = `./test-output/audio-test-${Date.now()}.mov`;
|
|
55
|
+
|
|
56
|
+
console.log('🎬 Testing Recording with Audio Settings:\n');
|
|
57
|
+
|
|
58
|
+
// Test 1: No audio
|
|
59
|
+
console.log(' Test 1: No Audio Recording');
|
|
60
|
+
recorder.setAudioSettings({ microphone: false, systemAudio: false });
|
|
61
|
+
console.log(` Starting 3-second recording: ${testOutput}`);
|
|
62
|
+
console.log(` Audio settings: Mic=${recorder.isMicrophoneEnabled() ? 'ON' : 'OFF'}, System=${recorder.isSystemAudioEnabled() ? 'ON' : 'OFF'}`);
|
|
63
|
+
|
|
64
|
+
await recorder.startRecording(testOutput);
|
|
65
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
66
|
+
await recorder.stopRecording();
|
|
67
|
+
console.log(' ✅ Recording completed (no audio)\n');
|
|
68
|
+
|
|
69
|
+
// Test 2: Microphone only
|
|
70
|
+
console.log(' Test 2: Microphone Only Recording');
|
|
71
|
+
recorder.setAudioSettings({ microphone: true, systemAudio: false });
|
|
72
|
+
const testOutput2 = `./test-output/audio-test-mic-${Date.now()}.mov`;
|
|
73
|
+
console.log(` Starting 3-second recording: ${testOutput2}`);
|
|
74
|
+
console.log(` Audio settings: Mic=${recorder.isMicrophoneEnabled() ? 'ON' : 'OFF'}, System=${recorder.isSystemAudioEnabled() ? 'ON' : 'OFF'}`);
|
|
75
|
+
|
|
76
|
+
await recorder.startRecording(testOutput2);
|
|
77
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
78
|
+
await recorder.stopRecording();
|
|
79
|
+
console.log(' ✅ Recording completed (microphone only)\n');
|
|
80
|
+
|
|
81
|
+
// Test 3: System audio only
|
|
82
|
+
console.log(' Test 3: System Audio Only Recording');
|
|
83
|
+
recorder.setAudioSettings({ microphone: false, systemAudio: true });
|
|
84
|
+
const testOutput3 = `./test-output/audio-test-system-${Date.now()}.mov`;
|
|
85
|
+
console.log(` Starting 3-second recording: ${testOutput3}`);
|
|
86
|
+
console.log(` Audio settings: Mic=${recorder.isMicrophoneEnabled() ? 'ON' : 'OFF'}, System=${recorder.isSystemAudioEnabled() ? 'ON' : 'OFF'}`);
|
|
87
|
+
|
|
88
|
+
await recorder.startRecording(testOutput3);
|
|
89
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
90
|
+
await recorder.stopRecording();
|
|
91
|
+
console.log(' ✅ Recording completed (system audio only)\n');
|
|
92
|
+
|
|
93
|
+
console.log('✅ All audio control tests completed successfully!');
|
|
94
|
+
console.log('\n📁 Check test-output/ directory for video files.');
|
|
95
|
+
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error('\n❌ Test failed:', error.message);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (require.main === module) {
|
|
103
|
+
testAudioControls();
|
|
104
|
+
}
|