@capgo/capacitor-screen-recorder 8.2.38 → 8.3.0
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/README.md +29 -4
- package/android/src/main/java/ee/forgr/plugin/screenrecorder/CapgoScrCastWithAudio.kt +11 -1
- package/android/src/main/java/ee/forgr/plugin/screenrecorder/ScreenRecorderPlugin.java +6 -1
- package/android/src/main/java/ee/forgr/plugin/screenrecorder/VideoFormatResolver.kt +21 -0
- package/dist/docs.json +81 -6
- package/dist/esm/definitions.d.ts +36 -3
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +1 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/ScreenRecorderPlugin/ScreenRecorderPlugin.swift +4 -3
- package/ios/Sources/ScreenRecorderPlugin/Wyler.swift +38 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,6 +104,8 @@ No configuration required for this plugin.
|
|
|
104
104
|
* [`start(...)`](#start)
|
|
105
105
|
* [`stop()`](#stop)
|
|
106
106
|
* [`getPluginVersion()`](#getpluginversion)
|
|
107
|
+
* [Interfaces](#interfaces)
|
|
108
|
+
* [Type Aliases](#type-aliases)
|
|
107
109
|
|
|
108
110
|
</docgen-index>
|
|
109
111
|
|
|
@@ -116,7 +118,7 @@ Allows you to capture video recordings of the screen with optional audio.
|
|
|
116
118
|
### start(...)
|
|
117
119
|
|
|
118
120
|
```typescript
|
|
119
|
-
start(options?:
|
|
121
|
+
start(options?: StartRecordingOptions | undefined) => Promise<void>
|
|
120
122
|
```
|
|
121
123
|
|
|
122
124
|
Start recording the device screen.
|
|
@@ -126,9 +128,9 @@ prompted to grant screen recording permissions if not already granted.
|
|
|
126
128
|
On iOS, the system recording UI will be displayed. On Android, the recording
|
|
127
129
|
starts immediately after permission is granted.
|
|
128
130
|
|
|
129
|
-
| Param | Type
|
|
130
|
-
| ------------- |
|
|
131
|
-
| **`options`** | <code>
|
|
131
|
+
| Param | Type | Description |
|
|
132
|
+
| ------------- | ----------------------------------------------------------------------- | --------------------------------- |
|
|
133
|
+
| **`options`** | <code><a href="#startrecordingoptions">StartRecordingOptions</a></code> | - Recording configuration options |
|
|
132
134
|
|
|
133
135
|
**Since:** 1.0.0
|
|
134
136
|
|
|
@@ -166,4 +168,27 @@ Get the native Capacitor plugin version.
|
|
|
166
168
|
|
|
167
169
|
--------------------
|
|
168
170
|
|
|
171
|
+
|
|
172
|
+
### Interfaces
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
#### StartRecordingOptions
|
|
176
|
+
|
|
177
|
+
Options for {@link ScreenRecorderPlugin.start}.
|
|
178
|
+
|
|
179
|
+
| Prop | Type | Description | Default | Since |
|
|
180
|
+
| ----------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
|
|
181
|
+
| **`recordAudio`** | <code>boolean</code> | Whether to record audio along with the screen video. | <code>false</code> | 1.0.0 |
|
|
182
|
+
| **`format`** | <code><a href="#screenrecordervideoformat">ScreenRecorderVideoFormat</a> \| 'video/mp4' \| 'video/quicktime'</code> | Video container format for the saved recording. Accepts `mp4`, `mov`, or MIME types `video/mp4` and `video/quicktime`. iOS supports both `mp4` and `mov`. Android records MPEG-4 (`.mp4`) regardless of this value. | <code>'mp4'</code> | 8.3.0 |
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
### Type Aliases
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
#### ScreenRecorderVideoFormat
|
|
189
|
+
|
|
190
|
+
Supported video container formats for screen recordings.
|
|
191
|
+
|
|
192
|
+
<code>'mp4' | 'mov'</code>
|
|
193
|
+
|
|
169
194
|
</docgen-api>
|
|
@@ -33,6 +33,8 @@ class CapgoScrCastWithAudio private constructor(private val activity: ComponentA
|
|
|
33
33
|
var options: Options = Options()
|
|
34
34
|
private set
|
|
35
35
|
|
|
36
|
+
private var fileExtension: String = "mp4"
|
|
37
|
+
|
|
36
38
|
private var recordingSession: Intent? = null
|
|
37
39
|
private var serviceBinder: CapgoRecorderService? = null
|
|
38
40
|
private var outputFile: File? = null
|
|
@@ -94,6 +96,14 @@ class CapgoScrCastWithAudio private constructor(private val activity: ComponentA
|
|
|
94
96
|
this.options = handleDynamicVideoSize(options)
|
|
95
97
|
}
|
|
96
98
|
|
|
99
|
+
fun updateVideoFormat(format: String?) {
|
|
100
|
+
val resolved = VideoFormatResolver.resolve(format)
|
|
101
|
+
fileExtension = resolved.extension
|
|
102
|
+
options = handleDynamicVideoSize(
|
|
103
|
+
options.copy(storage = options.storage.copy(outputFormat = resolved.outputFormat)),
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
97
107
|
fun record() {
|
|
98
108
|
Dexter.withContext(activity)
|
|
99
109
|
.withPermissions(
|
|
@@ -111,7 +121,7 @@ class CapgoScrCastWithAudio private constructor(private val activity: ComponentA
|
|
|
111
121
|
|
|
112
122
|
private fun resolveOutputFile(): File? {
|
|
113
123
|
val dir = options.storage.mediaStorageLocation ?: return null
|
|
114
|
-
return File("${dir.path}${File.separator}${options.storage.fileNameFormatter()}
|
|
124
|
+
return File("${dir.path}${File.separator}${options.storage.fileNameFormatter()}.$fileExtension")
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
private fun startService(result: ActivityResult, file: File) {
|
|
@@ -11,7 +11,7 @@ import dev.bmcreations.scrcast.config.Options;
|
|
|
11
11
|
@CapacitorPlugin(name = "ScreenRecorder")
|
|
12
12
|
public class ScreenRecorderPlugin extends Plugin {
|
|
13
13
|
|
|
14
|
-
private final String pluginVersion = "8.
|
|
14
|
+
private final String pluginVersion = "8.3.0";
|
|
15
15
|
|
|
16
16
|
private ScrCast recorder;
|
|
17
17
|
private CapgoScrCastWithAudio audioRecorder;
|
|
@@ -30,8 +30,13 @@ public class ScreenRecorderPlugin extends Plugin {
|
|
|
30
30
|
public void start(PluginCall call) {
|
|
31
31
|
try {
|
|
32
32
|
final boolean recordAudio = call.getBoolean("recordAudio", false);
|
|
33
|
+
final String format = call.getString("format");
|
|
33
34
|
recordingWithAudio = recordAudio;
|
|
34
35
|
|
|
36
|
+
final Options configuredOptions = VideoFormatResolver.INSTANCE.applyTo(recorder.getOptions(), format);
|
|
37
|
+
recorder.updateOptions(configuredOptions);
|
|
38
|
+
audioRecorder.updateVideoFormat(format);
|
|
39
|
+
|
|
35
40
|
if (recordAudio) {
|
|
36
41
|
audioRecorder.record();
|
|
37
42
|
} else {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package ee.forgr.plugin.screenrecorder
|
|
2
|
+
|
|
3
|
+
import android.media.MediaRecorder
|
|
4
|
+
import dev.bmcreations.scrcast.config.Options
|
|
5
|
+
|
|
6
|
+
object VideoFormatResolver {
|
|
7
|
+
data class Resolved(
|
|
8
|
+
val extension: String = "mp4",
|
|
9
|
+
val outputFormat: Int = MediaRecorder.OutputFormat.MPEG_4,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
fun resolve(@Suppress("UNUSED_PARAMETER") format: String?): Resolved {
|
|
13
|
+
// Android MediaRecorder only supports MPEG-4 output.
|
|
14
|
+
return Resolved()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
fun applyTo(options: Options, format: String?): Options {
|
|
18
|
+
val resolved = resolve(format)
|
|
19
|
+
return options.copy(storage = options.storage.copy(outputFormat = resolved.outputFormat))
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/docs.json
CHANGED
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"methods": [
|
|
13
13
|
{
|
|
14
14
|
"name": "start",
|
|
15
|
-
"signature": "(options?:
|
|
15
|
+
"signature": "(options?: StartRecordingOptions | undefined) => Promise<void>",
|
|
16
16
|
"parameters": [
|
|
17
17
|
{
|
|
18
18
|
"name": "options",
|
|
19
19
|
"docs": "- Recording configuration options",
|
|
20
|
-
"type": "
|
|
20
|
+
"type": "StartRecordingOptions | undefined"
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
"returns": "Promise<void>",
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"name": "param",
|
|
31
31
|
"text": "options.recordAudio - Whether to record audio along with the screen video. Defaults to false."
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"name": "param",
|
|
35
|
+
"text": "options.format - Video container format for the saved recording. Defaults to `mp4`."
|
|
36
|
+
},
|
|
33
37
|
{
|
|
34
38
|
"name": "returns",
|
|
35
39
|
"text": "Promise that resolves when recording starts"
|
|
@@ -44,11 +48,13 @@
|
|
|
44
48
|
},
|
|
45
49
|
{
|
|
46
50
|
"name": "example",
|
|
47
|
-
"text": "```typescript\n// Start recording without audio\nawait ScreenRecorder.start();\n\n// Start recording with audio\nawait ScreenRecorder.start({ recordAudio: true });\n```"
|
|
51
|
+
"text": "```typescript\n// Start recording without audio\nawait ScreenRecorder.start();\n\n// Start recording with audio\nawait ScreenRecorder.start({ recordAudio: true });\n\n// Start recording as MOV on iOS\nawait ScreenRecorder.start({ format: 'mov' });\n```"
|
|
48
52
|
}
|
|
49
53
|
],
|
|
50
54
|
"docs": "Start recording the device screen.\n\nInitiates screen recording with optional audio capture. The user will be\nprompted to grant screen recording permissions if not already granted.\nOn iOS, the system recording UI will be displayed. On Android, the recording\nstarts immediately after permission is granted.",
|
|
51
|
-
"complexTypes": [
|
|
55
|
+
"complexTypes": [
|
|
56
|
+
"StartRecordingOptions"
|
|
57
|
+
],
|
|
52
58
|
"slug": "start"
|
|
53
59
|
},
|
|
54
60
|
{
|
|
@@ -108,8 +114,77 @@
|
|
|
108
114
|
],
|
|
109
115
|
"properties": []
|
|
110
116
|
},
|
|
111
|
-
"interfaces": [
|
|
117
|
+
"interfaces": [
|
|
118
|
+
{
|
|
119
|
+
"name": "StartRecordingOptions",
|
|
120
|
+
"slug": "startrecordingoptions",
|
|
121
|
+
"docs": "Options for {@link ScreenRecorderPlugin.start}.",
|
|
122
|
+
"tags": [
|
|
123
|
+
{
|
|
124
|
+
"text": "8.3.0",
|
|
125
|
+
"name": "since"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"methods": [],
|
|
129
|
+
"properties": [
|
|
130
|
+
{
|
|
131
|
+
"name": "recordAudio",
|
|
132
|
+
"tags": [
|
|
133
|
+
{
|
|
134
|
+
"text": "false",
|
|
135
|
+
"name": "default"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"text": "1.0.0",
|
|
139
|
+
"name": "since"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"docs": "Whether to record audio along with the screen video.",
|
|
143
|
+
"complexTypes": [],
|
|
144
|
+
"type": "boolean | undefined"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "format",
|
|
148
|
+
"tags": [
|
|
149
|
+
{
|
|
150
|
+
"text": "'mp4'",
|
|
151
|
+
"name": "default"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"text": "8.3.0",
|
|
155
|
+
"name": "since"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"text": "'mov'",
|
|
159
|
+
"name": "example"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"docs": "Video container format for the saved recording.\n\nAccepts `mp4`, `mov`, or MIME types `video/mp4` and `video/quicktime`.\niOS supports both `mp4` and `mov`. Android records MPEG-4 (`.mp4`) regardless of this value.",
|
|
163
|
+
"complexTypes": [
|
|
164
|
+
"ScreenRecorderVideoFormat"
|
|
165
|
+
],
|
|
166
|
+
"type": "ScreenRecorderVideoFormat | 'video/mp4' | 'video/quicktime' | undefined"
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
],
|
|
112
171
|
"enums": [],
|
|
113
|
-
"typeAliases": [
|
|
172
|
+
"typeAliases": [
|
|
173
|
+
{
|
|
174
|
+
"name": "ScreenRecorderVideoFormat",
|
|
175
|
+
"slug": "screenrecordervideoformat",
|
|
176
|
+
"docs": "Supported video container formats for screen recordings.",
|
|
177
|
+
"types": [
|
|
178
|
+
{
|
|
179
|
+
"text": "'mp4'",
|
|
180
|
+
"complexTypes": []
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"text": "'mov'",
|
|
184
|
+
"complexTypes": []
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
],
|
|
114
189
|
"pluginConfigs": []
|
|
115
190
|
}
|
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported video container formats for screen recordings.
|
|
3
|
+
*
|
|
4
|
+
* @since 8.3.0
|
|
5
|
+
*/
|
|
6
|
+
export type ScreenRecorderVideoFormat = 'mp4' | 'mov';
|
|
7
|
+
/**
|
|
8
|
+
* Options for {@link ScreenRecorderPlugin.start}.
|
|
9
|
+
*
|
|
10
|
+
* @since 8.3.0
|
|
11
|
+
*/
|
|
12
|
+
export interface StartRecordingOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Whether to record audio along with the screen video.
|
|
15
|
+
*
|
|
16
|
+
* @default false
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
recordAudio?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Video container format for the saved recording.
|
|
22
|
+
*
|
|
23
|
+
* Accepts `mp4`, `mov`, or MIME types `video/mp4` and `video/quicktime`.
|
|
24
|
+
* iOS supports both `mp4` and `mov`. Android records MPEG-4 (`.mp4`) regardless of this value.
|
|
25
|
+
*
|
|
26
|
+
* @default 'mp4'
|
|
27
|
+
* @since 8.3.0
|
|
28
|
+
* @example 'mov'
|
|
29
|
+
*/
|
|
30
|
+
format?: ScreenRecorderVideoFormat | 'video/mp4' | 'video/quicktime';
|
|
31
|
+
}
|
|
1
32
|
/**
|
|
2
33
|
* Capacitor Screen Recorder Plugin for recording the device screen.
|
|
3
34
|
* Allows you to capture video recordings of the screen with optional audio.
|
|
@@ -15,6 +46,7 @@ export interface ScreenRecorderPlugin {
|
|
|
15
46
|
*
|
|
16
47
|
* @param options - Recording configuration options
|
|
17
48
|
* @param options.recordAudio - Whether to record audio along with the screen video. Defaults to false.
|
|
49
|
+
* @param options.format - Video container format for the saved recording. Defaults to `mp4`.
|
|
18
50
|
* @returns Promise that resolves when recording starts
|
|
19
51
|
* @throws Error if recording fails to start or permissions are denied
|
|
20
52
|
* @since 1.0.0
|
|
@@ -25,11 +57,12 @@ export interface ScreenRecorderPlugin {
|
|
|
25
57
|
*
|
|
26
58
|
* // Start recording with audio
|
|
27
59
|
* await ScreenRecorder.start({ recordAudio: true });
|
|
60
|
+
*
|
|
61
|
+
* // Start recording as MOV on iOS
|
|
62
|
+
* await ScreenRecorder.start({ format: 'mov' });
|
|
28
63
|
* ```
|
|
29
64
|
*/
|
|
30
|
-
start(options?:
|
|
31
|
-
recordAudio?: boolean;
|
|
32
|
-
}): Promise<void>;
|
|
65
|
+
start(options?: StartRecordingOptions): Promise<void>;
|
|
33
66
|
/**
|
|
34
67
|
* Stop the current screen recording.
|
|
35
68
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Capacitor Screen Recorder Plugin for recording the device screen.\n * Allows you to capture video recordings of the screen with optional audio.\n *\n * @since 1.0.0\n */\nexport interface ScreenRecorderPlugin {\n /**\n * Start recording the device screen.\n *\n * Initiates screen recording with optional audio capture. The user will be\n * prompted to grant screen recording permissions if not already granted.\n * On iOS, the system recording UI will be displayed. On Android, the recording\n * starts immediately after permission is granted.\n *\n * @param options - Recording configuration options\n * @param options.recordAudio - Whether to record audio along with the screen video. Defaults to false.\n * @returns Promise that resolves when recording starts\n * @throws Error if recording fails to start or permissions are denied\n * @since 1.0.0\n * @example\n * ```typescript\n * // Start recording without audio\n * await ScreenRecorder.start();\n *\n * // Start recording with audio\n * await ScreenRecorder.start({ recordAudio: true });\n * ```\n */\n start(options?:
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Supported video container formats for screen recordings.\n *\n * @since 8.3.0\n */\nexport type ScreenRecorderVideoFormat = 'mp4' | 'mov';\n\n/**\n * Options for {@link ScreenRecorderPlugin.start}.\n *\n * @since 8.3.0\n */\nexport interface StartRecordingOptions {\n /**\n * Whether to record audio along with the screen video.\n *\n * @default false\n * @since 1.0.0\n */\n recordAudio?: boolean;\n\n /**\n * Video container format for the saved recording.\n *\n * Accepts `mp4`, `mov`, or MIME types `video/mp4` and `video/quicktime`.\n * iOS supports both `mp4` and `mov`. Android records MPEG-4 (`.mp4`) regardless of this value.\n *\n * @default 'mp4'\n * @since 8.3.0\n * @example 'mov'\n */\n format?: ScreenRecorderVideoFormat | 'video/mp4' | 'video/quicktime';\n}\n\n/**\n * Capacitor Screen Recorder Plugin for recording the device screen.\n * Allows you to capture video recordings of the screen with optional audio.\n *\n * @since 1.0.0\n */\nexport interface ScreenRecorderPlugin {\n /**\n * Start recording the device screen.\n *\n * Initiates screen recording with optional audio capture. The user will be\n * prompted to grant screen recording permissions if not already granted.\n * On iOS, the system recording UI will be displayed. On Android, the recording\n * starts immediately after permission is granted.\n *\n * @param options - Recording configuration options\n * @param options.recordAudio - Whether to record audio along with the screen video. Defaults to false.\n * @param options.format - Video container format for the saved recording. Defaults to `mp4`.\n * @returns Promise that resolves when recording starts\n * @throws Error if recording fails to start or permissions are denied\n * @since 1.0.0\n * @example\n * ```typescript\n * // Start recording without audio\n * await ScreenRecorder.start();\n *\n * // Start recording with audio\n * await ScreenRecorder.start({ recordAudio: true });\n *\n * // Start recording as MOV on iOS\n * await ScreenRecorder.start({ format: 'mov' });\n * ```\n */\n start(options?: StartRecordingOptions): Promise<void>;\n\n /**\n * Stop the current screen recording.\n *\n * Stops the active screen recording and saves the video to the device's\n * camera roll or gallery. On iOS, the system will show a preview of the\n * recording. On Android, the video is saved directly to the gallery.\n *\n * @returns Promise that resolves when recording stops and the video is saved\n * @throws Error if stopping the recording fails or no recording is active\n * @since 1.0.0\n * @example\n * ```typescript\n * await ScreenRecorder.stop();\n * console.log('Recording saved to gallery');\n * ```\n */\n stop(): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * @returns Promise that resolves with the plugin version\n * @throws Error if getting the version fails\n * @since 1.0.0\n * @example\n * ```typescript\n * const { version } = await ScreenRecorder.getPluginVersion();\n * console.log('Plugin version:', version);\n * ```\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { ScreenRecorderPlugin } from './definitions';
|
|
2
|
+
import type { ScreenRecorderPlugin, StartRecordingOptions } from './definitions';
|
|
3
3
|
export declare class ScreenRecorderWeb extends WebPlugin implements ScreenRecorderPlugin {
|
|
4
|
-
start(): Promise<void>;
|
|
4
|
+
start(_options?: StartRecordingOptions): Promise<void>;
|
|
5
5
|
stop(): Promise<void>;
|
|
6
6
|
getPluginVersion(): Promise<{
|
|
7
7
|
version: string;
|
package/dist/esm/web.js
CHANGED
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,KAAK,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,KAAK,CAAC,KAAK,CAAC,QAAgC;QAC1C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { ScreenRecorderPlugin, StartRecordingOptions } from './definitions';\n\nexport class ScreenRecorderWeb extends WebPlugin implements ScreenRecorderPlugin {\n async start(_options?: StartRecordingOptions): Promise<void> {\n throw new Error('Method not implemented.');\n }\n async stop(): Promise<void> {\n throw new Error('Method not implemented.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst ScreenRecorder = registerPlugin('ScreenRecorder', {\n web: () => import('./web').then((m) => new m.ScreenRecorderWeb()),\n});\nexport * from './definitions';\nexport { ScreenRecorder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ScreenRecorderWeb extends WebPlugin {\n async start() {\n throw new Error('Method not implemented.');\n }\n async stop() {\n throw new Error('Method not implemented.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACrE,CAAC;;ACFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD,IAAI,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst ScreenRecorder = registerPlugin('ScreenRecorder', {\n web: () => import('./web').then((m) => new m.ScreenRecorderWeb()),\n});\nexport * from './definitions';\nexport { ScreenRecorder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ScreenRecorderWeb extends WebPlugin {\n async start(_options) {\n throw new Error('Method not implemented.');\n }\n async stop() {\n throw new Error('Method not implemented.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;AACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACrE,CAAC;;ACFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;AACjD,IAAI,MAAM,KAAK,CAAC,QAAQ,EAAE;AAC1B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;AAClD,IAAI;AACJ,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;AAClD,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst ScreenRecorder = registerPlugin('ScreenRecorder', {\n web: () => import('./web').then((m) => new m.ScreenRecorderWeb()),\n});\nexport * from './definitions';\nexport { ScreenRecorder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ScreenRecorderWeb extends WebPlugin {\n async start() {\n throw new Error('Method not implemented.');\n }\n async stop() {\n throw new Error('Method not implemented.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrE,CAAC;;ICFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst ScreenRecorder = registerPlugin('ScreenRecorder', {\n web: () => import('./web').then((m) => new m.ScreenRecorderWeb()),\n});\nexport * from './definitions';\nexport { ScreenRecorder };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ScreenRecorderWeb extends WebPlugin {\n async start(_options) {\n throw new Error('Method not implemented.');\n }\n async stop() {\n throw new Error('Method not implemented.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,cAAc,GAAGA,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACrE,CAAC;;ICFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,MAAM,KAAK,CAAC,QAAQ,EAAE;IAC1B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;IAClD,IAAI;IACJ,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC;IAClD,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -7,7 +7,7 @@ import Capacitor
|
|
|
7
7
|
*/
|
|
8
8
|
@objc(ScreenRecorderPlugin)
|
|
9
9
|
public class ScreenRecorderPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
|
-
private let pluginVersion: String = "8.
|
|
10
|
+
private let pluginVersion: String = "8.3.0"
|
|
11
11
|
public let identifier = "ScreenRecorderPlugin"
|
|
12
12
|
public let jsName = "ScreenRecorder"
|
|
13
13
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -19,7 +19,8 @@ public class ScreenRecorderPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
19
19
|
|
|
20
20
|
@objc func start(_ call: CAPPluginCall) {
|
|
21
21
|
let recordAudio = call.getBool("recordAudio") ?? false
|
|
22
|
-
|
|
22
|
+
let videoFormat = VideoContainerFormat.from(call.getString("format"))
|
|
23
|
+
implementation.startRecording(saveToCameraRoll: true, recordAudio: recordAudio, videoFormat: videoFormat, handler: { error in
|
|
23
24
|
if let error = error {
|
|
24
25
|
debugPrint("Error when start recording \(error)")
|
|
25
26
|
call.reject("Cannot start recording")
|
|
@@ -28,6 +29,7 @@ public class ScreenRecorderPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
28
29
|
}
|
|
29
30
|
})
|
|
30
31
|
}
|
|
32
|
+
|
|
31
33
|
@objc func stop(_ call: CAPPluginCall) {
|
|
32
34
|
implementation.stoprecording(handler: { error in
|
|
33
35
|
if let error = error {
|
|
@@ -42,5 +44,4 @@ public class ScreenRecorderPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
42
44
|
@objc func getPluginVersion(_ call: CAPPluginCall) {
|
|
43
45
|
call.resolve(["version": self.pluginVersion])
|
|
44
46
|
}
|
|
45
|
-
|
|
46
47
|
}
|
|
@@ -17,6 +17,38 @@ public enum ScreenRecorderError: Error {
|
|
|
17
17
|
case photoLibraryAccessNotGranted
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
public enum VideoContainerFormat {
|
|
21
|
+
case mp4
|
|
22
|
+
case mov
|
|
23
|
+
|
|
24
|
+
var fileType: AVFileType {
|
|
25
|
+
switch self {
|
|
26
|
+
case .mp4:
|
|
27
|
+
return .mp4
|
|
28
|
+
case .mov:
|
|
29
|
+
return .mov
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var fileExtension: String {
|
|
34
|
+
switch self {
|
|
35
|
+
case .mp4:
|
|
36
|
+
return "mp4"
|
|
37
|
+
case .mov:
|
|
38
|
+
return "mov"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static func from(_ value: String?) -> VideoContainerFormat {
|
|
43
|
+
switch value?.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() {
|
|
44
|
+
case "mov", "video/quicktime", "quicktime":
|
|
45
|
+
return .mov
|
|
46
|
+
default:
|
|
47
|
+
return .mp4
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
20
52
|
public final class ScreenRecorder {
|
|
21
53
|
private var videoOutputURL: URL?
|
|
22
54
|
private var videoWriter: AVAssetWriter?
|
|
@@ -25,15 +57,18 @@ public final class ScreenRecorder {
|
|
|
25
57
|
private var appAudioWriterInput: AVAssetWriterInput?
|
|
26
58
|
private var saveToCameraRoll = false
|
|
27
59
|
private var recordAudio = false
|
|
60
|
+
private var videoFormat: VideoContainerFormat = .mp4
|
|
28
61
|
let recorder = RPScreenRecorder.shared()
|
|
29
62
|
|
|
30
63
|
public func startRecording(to outputURL: URL? = nil,
|
|
31
64
|
size: CGSize? = nil,
|
|
32
65
|
saveToCameraRoll: Bool = false,
|
|
33
66
|
recordAudio: Bool = false,
|
|
67
|
+
videoFormat: VideoContainerFormat = .mp4,
|
|
34
68
|
handler: @escaping (Error?) -> Void) {
|
|
35
69
|
self.saveToCameraRoll = saveToCameraRoll
|
|
36
70
|
self.recordAudio = recordAudio
|
|
71
|
+
self.videoFormat = videoFormat
|
|
37
72
|
resetWriterState()
|
|
38
73
|
|
|
39
74
|
recorder.isMicrophoneEnabled = recordAudio
|
|
@@ -75,7 +110,8 @@ public final class ScreenRecorder {
|
|
|
75
110
|
newVideoOutputURL = passedVideoOutput
|
|
76
111
|
} else {
|
|
77
112
|
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString
|
|
78
|
-
|
|
113
|
+
let fileName = "WylerNewVideo.\(videoFormat.fileExtension)"
|
|
114
|
+
newVideoOutputURL = URL(fileURLWithPath: documentsPath.appendingPathComponent(fileName))
|
|
79
115
|
self.videoOutputURL = newVideoOutputURL
|
|
80
116
|
}
|
|
81
117
|
|
|
@@ -84,7 +120,7 @@ public final class ScreenRecorder {
|
|
|
84
120
|
} catch {}
|
|
85
121
|
|
|
86
122
|
do {
|
|
87
|
-
try videoWriter = AVAssetWriter(outputURL: newVideoOutputURL, fileType:
|
|
123
|
+
try videoWriter = AVAssetWriter(outputURL: newVideoOutputURL, fileType: videoFormat.fileType)
|
|
88
124
|
} catch let writerError as NSError {
|
|
89
125
|
videoWriter = nil
|
|
90
126
|
throw writerError
|