-
Notifications
You must be signed in to change notification settings - Fork 442
Camera Video Recording #2710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Camera Video Recording #2710
Conversation
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.
@VladislavAntonyuk I believe you're using the old Camera2 APi, you should use the CameraX API instead, it will be simpler and it's newer
here for reference https://developer.android.com/media/camera/camerax/video-capture
I see we reference a NuGet for camera 2, that is why I used this implementation. According to Google camera 2 is not obsolete, but allows you to have a full control of the camera. CameraX just a convenient way to work with camera api. I will update to CameraX. |
Ensures proper handling of the video recording stream by setting appropriate file access and share options. Also, explicitly flushes the stream and nullifies the file after copying to prevent potential issues with file access or deletion. Addresses an issue where the `VideoRecordEvent` was not correctly identified as the final event.
Updates the `PlatformStartVideoRecording` method signature on Tizen to accept a stream, allowing for greater flexibility in handling video data.
Updated CameraViewPage.xaml to include buttons for starting/stopping video recording and setting night mode. Changed "GetStream" button text to "Save Video Recording" and repositioned "Capture Image" button. Simplified video file creation in CameraManager.android.cs by removing unnecessary ContentValues. Modified PlatformStopVideoRecording to change flow after stopping video recording. Enhanced CreateStopVideoRecordingCommand to use async lambda for better asynchronous operation handling.
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.
Pull Request Overview
This PR implements video recording functionality for the .NET MAUI Community Toolkit's CameraView, adding comprehensive support across Android, iOS/macOS, and Windows platforms. The implementation includes new public APIs for starting and stopping video recording, along with extension capabilities for Android camera features.
Key changes include:
- Addition of
StartVideoRecording
andStopVideoRecording
methods to the CameraView API - Platform-specific implementations for video recording across all supported platforms
- New command properties for XAML binding support
- Sample application updates to demonstrate video recording functionality
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
CameraView.shared.cs | Adds new bindable properties and commands for video recording functionality |
CameraViewDefaults.shared.cs | Implements default command factories for video recording operations |
ICameraView.shared.cs | Defines the public interface for video recording methods |
CameraManager.*.cs | Platform-specific implementations of video recording for Android, iOS/macOS, Windows, Tizen, and .NET |
Sample project files | Updates sample app to demonstrate video recording with UI controls and save functionality |
src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs
Outdated
Show resolved
Hide resolved
samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs
Show resolved
Hide resolved
…ommunityToolkit/Maui into feature/camera-video-recording
src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs
Show resolved
Hide resolved
This is looking very well done! I am shocked at how nice some of the code looks. I have for over a year now wanted a solution to async - await for android in dotnet. From looking at this code I can see an easy example I can reference in the future for how to do that! Ty for that alone! I am going to test on my Mac mini and my iPad later this morning but just looking at the code it looks good to go after you look at my comments. I think all that is left for now is finishing testing and starting the documentation. This is a great addition to the toolkit. |
Start video recording on iOS and iOS simulator is crashing on button click with message about not finding camera.
|
Managed to get a stacktrace for MacOS. For some reason the debugger was not working for either iOS simulator or device. MacOS:
Hopefully that might help figure out what is going on. I don't have a camera attached to my mac mini. Which is probably an issue but should the sample app crash when you open the camera page? It just CTD when I navigate to camera page. |
The camera is not available on iOS simulators; you can only test it on real devices |
Refactor video recording logic and improve null checks - Updated `StartUseCase` in `CameraManager.android.cs` to use a builder pattern for `videoRecorder`, allowing for null checks on `Quality.Highest`. - Changed executor retrieval in `PlatformStartVideoRecording` to enhance readability and error handling. - Improved null safety in `EnableModes` by checking for nullability of `extensionsManager`. - Updated `SupportedOSPlatform` in `CameraManager.windows.cs` to require a higher minimum Windows version. - Refactored `PlatformStartVideoRecording` to use `var` for `profile` and modernized null-checking style for `frameSource` and `frameFormat`.
Description of Change
Linked Issues
PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRAdditional information
https://vladislavantonyuk.github.io/articles/Turn-any-phone-into-an-IP-Camera-in-30-Minutes-using-.NET-MAUI/