@capgo/camera-preview 6.3.6 → 6.3.7
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 +50 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,6 +108,56 @@ You will need to add two permissions to `Info.plist`. Follow the [Capacitor docs
|
|
|
108
108
|
|
|
109
109
|
Add `import '@capgo/camera-preview'` to you entry script in ionic on `app.module.ts`, so capacitor can register the web platform from the plugin
|
|
110
110
|
|
|
111
|
+
### Exemple with Capacitor uploader:
|
|
112
|
+
|
|
113
|
+
Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { CameraPreview } from '@capgo/camera-preview'
|
|
117
|
+
import { Uploader } from '@capgo/capacitor-uploader';
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
async function record() {
|
|
121
|
+
await CameraPreview.startRecordVideo({ storeToFile: true })
|
|
122
|
+
await new Promise(resolve => setTimeout(resolve, 5000))
|
|
123
|
+
const fileUrl = await CameraPreview.stopRecordVideo()
|
|
124
|
+
console.log(fileUrl.videoFilePath)
|
|
125
|
+
await uploadVideo(fileUrl.videoFilePath)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function uploadVideo(filePath: string) {
|
|
129
|
+
Uploader.addListener('events', (event) => {
|
|
130
|
+
switch (event.name) {
|
|
131
|
+
case 'uploading':
|
|
132
|
+
console.log(`Upload progress: ${event.payload.percent}%`);
|
|
133
|
+
break;
|
|
134
|
+
case 'completed':
|
|
135
|
+
console.log('Upload completed successfully');
|
|
136
|
+
console.log('Server response status code:', event.payload.statusCode);
|
|
137
|
+
break;
|
|
138
|
+
case 'failed':
|
|
139
|
+
console.error('Upload failed:', event.payload.error);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
try {
|
|
144
|
+
const result = await Uploader.startUpload({
|
|
145
|
+
filePath,
|
|
146
|
+
serverUrl: 'S#_PRESIGNED_URL',
|
|
147
|
+
method: 'PUT',
|
|
148
|
+
headers: {
|
|
149
|
+
'Content-Type': 'video/mp4',
|
|
150
|
+
},
|
|
151
|
+
mimeType: 'video/mp4',
|
|
152
|
+
});
|
|
153
|
+
console.log('Video uploaded successfully:', result.id);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.error('Error uploading video:', error);
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
111
161
|
### API
|
|
112
162
|
|
|
113
163
|
<docgen-index>
|