This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera_web] Recording Video #4210
Merged
Merged
Changes from 11 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
0c6fac4
Add Support for Video Recording in Camera Web
ABausG 65b2718
Add Documentation
ABausG 4bd1173
Adding Tests
ABausG ce42759
Adding Error Handling
ABausG fdbe131
Formatting
ABausG 4b1ae4c
Add missing call to get RecordedEvent Stream
ABausG 2e6dfec
Rename onVideoRecordedEventStream
ABausG f252ffc
Unify logic from startVideoRecording and stopVideoRecording
ABausG d8114ab
throw PlatformExceptions
ABausG 39adc96
Use srcObject
ABausG 4db7748
Add Camera Tests
ABausG 287bd4a
Fix Test and Stopping Video Recording
ABausG 8f0f2fd
Clarify maxVideoDuration Test Issue
ABausG 0e1d690
Merge branch 'upstream/master' into camera_web_recording
bselwe d38978f
feat: await closing videoRecorderController in Camera
bselwe ce5c1ca
docs: update video recording comments
bselwe a517757
feat: throw a CameraWebException if the video recording fails
bselwe 2d1022f
test: add onEnded and onVideoRecordedEvent dispose tests
bselwe 01a6999
test: update Camera video recording tests
bselwe 4df6796
test: add missing CameraPlatform video recording tests
bselwe 1d3906d
Merge branch 'upstream/master' into camera_web_recording
bselwe 3c74e9e
feat: combine ondataavailable video blobs into a single video blob
bselwe f5863e9
test: update video recording tests for multiple video blobs
bselwe 4552b01
docs: add video recording documentation
bselwe cd7f80d
feat: add Camera onVideoRecordingError stream
bselwe 01b3210
test: add Camera onVideoRecordingError stream tests
bselwe c03fea6
feat: emit a CameraErrorEvent on video recording error
bselwe 194db74
test: emit a CameraErrorEvent on video recording error tests
bselwe 24ab126
Merge branch 'upstream/master' into camera_web_recording
bselwe 787ee6b
feat: make prepareForVideoRecording a no-op
bselwe bc9c72a
Merge branch 'master' into camera_web_recording
ditman 114cc46
Update CHANGELOG and pubspec
ditman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ import 'dart:ui'; | |||||||||||||||||
import 'package:camera_web/src/camera.dart'; | ||||||||||||||||||
import 'package:camera_web/src/camera_settings.dart'; | ||||||||||||||||||
import 'package:camera_web/src/types/types.dart'; | ||||||||||||||||||
import 'package:flutter/services.dart'; | ||||||||||||||||||
import 'package:flutter_test/flutter_test.dart'; | ||||||||||||||||||
import 'package:integration_test/integration_test.dart'; | ||||||||||||||||||
import 'package:mocktail/mocktail.dart'; | ||||||||||||||||||
|
@@ -297,5 +298,170 @@ void main() { | |||||||||||||||||
expect(camera.videoElement.srcObject, isNull); | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
group('startVideoRecording', () { | ||||||||||||||||||
testWidgets('starts a video recording', (tester) async { | ||||||||||||||||||
final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
|
||||||||||||||||||
await camera.startVideoRecording(); | ||||||||||||||||||
|
||||||||||||||||||
expect('recording', camera.mediaRecorder!.state); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
testWidgets( | ||||||||||||||||||
'starts a video recording with a given maxDuration ' | ||||||||||||||||||
'emits a VideoRecordedEvent', (tester) async { | ||||||||||||||||||
// TODO(abausg) There seems to be an issue with removing the listener and stopping the recorder | ||||||||||||||||||
/*final maxDuration = Duration(milliseconds: 30); | ||||||||||||||||||
|
||||||||||||||||||
final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
|
||||||||||||||||||
final eventExpectation = expectLater(camera.onVideoRecordedEvent.map((event) => event.maxVideoDuration), emits(maxDuration)); | ||||||||||||||||||
await camera.startVideoRecording(maxVideoDuration: maxDuration); | ||||||||||||||||||
|
||||||||||||||||||
await eventExpectation; | ||||||||||||||||||
expect('inactive', camera.mediaRecorder!.state);*/ | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
testWidgets( | ||||||||||||||||||
'throws PlatformException ' | ||||||||||||||||||
'when maxVideoDuration is 0 milliseconds or less', (tester) async { | ||||||||||||||||||
final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
expect( | ||||||||||||||||||
() => camera.startVideoRecording(maxVideoDuration: Duration.zero), | ||||||||||||||||||
throwsA(predicate<PlatformException>( | ||||||||||||||||||
(ex) => ex.code == CameraErrorCode.notSupported.toString()))); | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit
Suggested change
|
||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
group('pauseVideoRecording', () { | ||||||||||||||||||
testWidgets('pauses a video recording', (tester) async { | ||||||||||||||||||
final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
await camera.startVideoRecording(); | ||||||||||||||||||
|
||||||||||||||||||
await camera.pauseVideoRecording(); | ||||||||||||||||||
|
||||||||||||||||||
expect('paused', camera.mediaRecorder!.state); | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
testWidgets( | ||||||||||||||||||
'throws a PlatformException ' | ||||||||||||||||||
'if no recording was started', (tester) async { | ||||||||||||||||||
final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
|
||||||||||||||||||
expect( | ||||||||||||||||||
camera.pauseVideoRecording, | ||||||||||||||||||
throwsA(predicate<PlatformException>((ex) => | ||||||||||||||||||
ex.code == | ||||||||||||||||||
CameraErrorCode.mediaRecordingNotStarted.toString()))); | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
group('resumeVideoRecording', () { | ||||||||||||||||||
testWidgets('resumes a video recording', (tester) async { | ||||||||||||||||||
final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
|
||||||||||||||||||
await camera.startVideoRecording(); | ||||||||||||||||||
|
||||||||||||||||||
await camera.pauseVideoRecording(); | ||||||||||||||||||
|
||||||||||||||||||
await camera.resumeVideoRecording(); | ||||||||||||||||||
|
||||||||||||||||||
expect('recording', camera.mediaRecorder!.state); | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
testWidgets( | ||||||||||||||||||
'throws a PlatformException ' | ||||||||||||||||||
'if no recording was started', (tester) async { | ||||||||||||||||||
final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
|
||||||||||||||||||
expect( | ||||||||||||||||||
camera.resumeVideoRecording, | ||||||||||||||||||
throwsA(predicate<PlatformException>((ex) => | ||||||||||||||||||
ex.code == | ||||||||||||||||||
CameraErrorCode.mediaRecordingNotStarted.toString()))); | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
group('stopVideoRecording', () { | ||||||||||||||||||
testWidgets('stops a video recording and returns a File', (tester) async { | ||||||||||||||||||
// TODO(abausg) There seems to be an issue with removing the listener and stopping the recorder | ||||||||||||||||||
ABausG marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
/*final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
|
||||||||||||||||||
await camera.startVideoRecording(); | ||||||||||||||||||
|
||||||||||||||||||
final videoFile = await camera.stopVideoRecording(); | ||||||||||||||||||
|
||||||||||||||||||
expect(videoFile, isNotNull); | ||||||||||||||||||
|
||||||||||||||||||
expect(camera.mediaRecorder, isNull);*/ | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
testWidgets( | ||||||||||||||||||
'throws a PlatformException ' | ||||||||||||||||||
'if no recording was started', (tester) async { | ||||||||||||||||||
final camera = Camera( | ||||||||||||||||||
textureId: 1, | ||||||||||||||||||
cameraSettings: cameraSettings, | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
await camera.initialize(); | ||||||||||||||||||
await camera.play(); | ||||||||||||||||||
|
||||||||||||||||||
expect( | ||||||||||||||||||
camera.stopVideoRecording, | ||||||||||||||||||
throwsA(predicate<PlatformException>((ex) => | ||||||||||||||||||
ex.code == | ||||||||||||||||||
CameraErrorCode.mediaRecordingNotStarted.toString()))); | ||||||||||||||||||
}); | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit
Suggested change
|
||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.