feat(HikVision): add CapturePicture function#7407
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a CapturePicture feature to the HikVision sample, wiring a new UI button to an async capture-and-download method and adjusting sound state handling on real-play lifecycle events. Sequence diagram for HikVision capture picture featuresequenceDiagram
actor User
participant HikVisionsComponent
participant HikVisionService
participant BrowserDownload
User->>HikVisionsComponent: Click capture picture button
HikVisionsComponent->>HikVisionsComponent: OnCapture()
HikVisionsComponent->>HikVisionService: CapturePictureAndDownload()
HikVisionService-->>BrowserDownload: Stream captured image data
BrowserDownload-->>User: Prompt image download/save
Updated class diagram for HikVisions component and HikVision serviceclassDiagram
class HikVisionsComponent {
- bool _startRealPlayStatus
- bool _stopRealPlayStatus
- bool _openSoundStatus
- bool _closeSoundStatus
- int _streamType
- int _channelId
- HikVisionService _hikVision
- bool _inited
+ Task OnStartRealPlay()
+ Task OnOpenSound()
+ Task OnCloseSound()
+ Task OnCapture()
+ Task OnInitedAsync(bool initialized)
+ Task OnStartRealPlayedAsync()
+ Task OnStopRealPlayedAsync()
}
class HikVisionService {
+ bool IsRealPlaying
+ Task StartRealPlay(int streamType, int channelId)
+ Task StopRealPlay()
+ Task OpenSound()
+ Task CloseSound()
+ Task CapturePictureAndDownload()
}
HikVisionsComponent --> HikVisionService : uses
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider guarding
OnCaptureso it’s a no-op (or shows feedback) when the HikVision component is not initialized or not in a real-play state, rather than relying solely on the_stopRealPlayStatusflag for the button disable logic. - The state transitions for
_openSoundStatusand_closeSoundStatusinOnStartRealPlayedAsyncandOnStopRealPlayedAsynclook asymmetric; double-check that both flags reflect the intended enabled/disabled state of the sound buttons immediately after start and stop (e.g.,_closeSoundStatusis set totruein both callbacks). - If
CapturePictureAndDownloadcan take noticeable time or fail, you might want to add basic busy/error handling aroundOnCapture(e.g., temporary button disable and try/catch) to avoid repeated rapid clicks or unhandled exceptions surfacing to the UI.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider guarding `OnCapture` so it’s a no-op (or shows feedback) when the HikVision component is not initialized or not in a real-play state, rather than relying solely on the `_stopRealPlayStatus` flag for the button disable logic.
- The state transitions for `_openSoundStatus` and `_closeSoundStatus` in `OnStartRealPlayedAsync` and `OnStopRealPlayedAsync` look asymmetric; double-check that both flags reflect the intended enabled/disabled state of the sound buttons immediately after start and stop (e.g., `_closeSoundStatus` is set to `true` in both callbacks).
- If `CapturePictureAndDownload` can take noticeable time or fail, you might want to add basic busy/error handling around `OnCapture` (e.g., temporary button disable and try/catch) to avoid repeated rapid clicks or unhandled exceptions surfacing to the UI.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7407 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 748 748
Lines 32793 32793
Branches 4551 4551
=========================================
Hits 32793 32793
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a capture picture functionality to the HikVision web plugin component, allowing users to capture and download images from the video stream. The implementation includes a new capture button in the UI and refactors the sound status initialization logic to be handled in the event callbacks rather than in the button click handlers.
- Added CapturePictureAndDownload functionality with a new capture button
- Refactored sound status initialization from OnStartRealPlay to OnStartRealPlayedAsync callback
- Updated BootstrapBlazor.HikVision package from version 10.0.5 to 10.0.6
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| HikVisions.razor.cs | Added OnCapture method and moved sound status initialization from OnStartRealPlay to the OnStartRealPlayedAsync/OnStopRealPlayedAsync callbacks for proper state management |
| HikVisions.razor | Added capture button that is disabled when the real-time stream is not playing |
| BootstrapBlazor.Server.csproj | Updated HikVision package dependency to version 10.0.6 which includes the new CapturePictureAndDownload API |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private async Task OnCapture() | ||
| { | ||
| await _hikVision.CapturePictureAndDownload(); | ||
| } |
There was a problem hiding this comment.
The OnCapture method lacks user feedback for success or failure. Unlike OnOpenSound and OnCloseSound methods which provide toast notifications to inform users of the operation result, this method silently executes without any feedback. Consider adding success/error toast messages similar to the sound control methods to improve user experience.
Link issues
fixes #7406
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add a HikVision sample action to capture and download a snapshot during real-time playback and update related UI state handling.
New Features:
Enhancements: