-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat(HikVision): add ChangeWindowNum function #871
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -125,6 +125,11 @@ public partial class HikVisionWebPlugin | |||||
| /// </summary> | ||||||
| public bool IsStartRecord { get; private set; } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// 获得 当前是否为分屏状态 | ||||||
| /// </summary> | ||||||
| public bool IsMultipleWindowType { get; private set; } | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// <inheritdoc/> | ||||||
| /// </summary> | ||||||
|
|
@@ -204,7 +209,7 @@ public async Task GetChannelList() | |||||
| /// <returns></returns> | ||||||
| public async Task StartRealPlay(int streamType, int channelId) | ||||||
| { | ||||||
| if (IsLogin && !IsRealPlaying) | ||||||
| if (IsMultipleWindowType || (IsLogin && !IsRealPlaying)) | ||||||
|
||||||
| if (IsMultipleWindowType || (IsLogin && !IsRealPlaying)) | |
| if ((IsLogin && !IsRealPlaying) || (IsMultipleWindowType && IsLogin)) |
Copilot
AI
Dec 27, 2025
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.
The logic for controlling method calls using IsMultipleWindowType is problematic. When IsMultipleWindowType is true, the condition passes even if IsRealPlaying is false, potentially allowing stop operations when nothing is playing. The condition should be: IsRealPlaying || (IsMultipleWindowType && IsRealPlaying) to ensure proper state checking.
| if (IsMultipleWindowType || IsRealPlaying) | |
| if (IsRealPlaying) |
Copilot
AI
Dec 27, 2025
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.
The logic for controlling method calls using IsMultipleWindowType is problematic. When IsMultipleWindowType is true, the condition passes even if IsLogin is false or IsRealPlaying is false, potentially allowing sound operations on an unauthenticated or non-playing session. The condition should be: (IsLogin && IsRealPlaying) || (IsMultipleWindowType && IsLogin && IsRealPlaying) to ensure proper state checking.
| if (IsMultipleWindowType || (IsLogin && IsRealPlaying)) | |
| if (IsLogin && IsRealPlaying) |
Copilot
AI
Dec 27, 2025
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.
The logic for controlling method calls using IsMultipleWindowType is problematic. When IsMultipleWindowType is true, the condition passes even if IsLogin is false or IsRealPlaying is false, potentially allowing sound operations on an unauthenticated or non-playing session. The condition should be: (IsLogin && IsRealPlaying) || (IsMultipleWindowType && IsLogin && IsRealPlaying) to ensure proper state checking.
Copilot
AI
Dec 27, 2025
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.
The logic for controlling method calls using IsMultipleWindowType is problematic. When IsMultipleWindowType is true, the condition passes even if IsLogin is false or IsRealPlaying is false, potentially allowing volume operations on an unauthenticated or non-playing session. The condition should be: (IsLogin && IsRealPlaying) || (IsMultipleWindowType && IsLogin && IsRealPlaying) to ensure proper state checking.
Copilot
AI
Dec 27, 2025
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.
The logic for controlling method calls using IsMultipleWindowType is problematic. When IsMultipleWindowType is true, the condition passes even if IsLogin is false or IsRealPlaying is false, potentially allowing capture operations on an unauthenticated or non-playing session. The condition should be: (IsLogin && IsRealPlaying) || (IsMultipleWindowType && IsLogin && IsRealPlaying) to ensure proper state checking.
Copilot
AI
Dec 27, 2025
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.
The logic for controlling method calls using IsMultipleWindowType is problematic. When IsMultipleWindowType is true, the condition passes even if IsLogin is false or IsRealPlaying is false, potentially allowing capture operations on an unauthenticated or non-playing session. The condition should be: (IsLogin && IsRealPlaying) || (IsMultipleWindowType && IsLogin && IsRealPlaying) to ensure proper state checking.
Copilot
AI
Dec 27, 2025
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.
The logic for controlling method calls using IsMultipleWindowType is problematic. When IsMultipleWindowType is true, the condition passes even if IsLogin is false or IsRealPlaying is false, potentially allowing record operations on an unauthenticated or non-playing session. The condition should be: (IsLogin && IsRealPlaying) || (IsMultipleWindowType && IsLogin && IsRealPlaying) to ensure proper state checking.
Copilot
AI
Dec 27, 2025
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.
The logic for controlling method calls using IsMultipleWindowType is problematic. When IsMultipleWindowType is true, the condition passes even if IsLogin is false or IsRealPlaying is false, potentially allowing stop record operations on an unauthenticated or non-playing session. The condition should be: (IsLogin && IsRealPlaying) || (IsMultipleWindowType && IsLogin && IsRealPlaying) to ensure proper state checking.
Copilot
AI
Dec 27, 2025
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.
The documentation comment is unclear about the behavior when iWndType exceeds 4. The comment states "数字超过4返回16分割" (numbers exceeding 4 return 16 splits), but it's not clear if the function returns false or if it defaults to a 4x4 layout. Consider clarifying the exact behavior and return value in this edge case.
| /// <param name="iWndType">画面分割类型 1- 1*1,2- 2*2,3- 3*3,4- 4*4 (最大显示数值为4*4分割,数字超过4返回16分割)</param> | |
| /// <param name="iWndType">画面分割类型。支持的值:1 = 1×1,2 = 2×2,3 = 3×3,4 = 4×4。传入其它值将原样传递给底层插件,由其决定实际分割效果和返回值。</param> |
Copilot
AI
Dec 27, 2025
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.
Missing input validation for the iWndType parameter. The function should validate that iWndType is one of the expected values ("1", "2", "3", "4", "12", "21") before calling the API. Invalid values could lead to unexpected behavior or errors from the WebVideoCtrl API.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,13 +13,11 @@ export async function init(id) { | |||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| const result = await initWindow(id); | ||||||
| const vision = Data.get(id); | ||||||
| const result = await initWindow(id, iWndIndex => vision.iWndIndex = iWndIndex); | ||||||
| if (result.inited === false) { | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| const vision = Data.get(id); | ||||||
| vision.iWndIndex = result.iWndIndex; | ||||||
| vision.inited = true; | ||||||
|
|
||||||
| const observer = new IntersectionObserver(() => { | ||||||
|
|
@@ -103,14 +101,14 @@ const removePlugin = () => { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| const initWindow = id => { | ||||||
| const result = { inited: null, iWndIndex: -1 }; | ||||||
| const initWindow = (id, cb) => { | ||||||
| const result = { inited: null }; | ||||||
| WebVideoCtrl.I_InitPlugin({ | ||||||
| szBasePath: './_content/BootstrapBlazor.HikVision', | ||||||
| bWndFull: true, | ||||||
| iWndowType: 1, | ||||||
| cbSelWnd: function (xmlDoc) { | ||||||
| result.iWndIndex = parseInt(getTagNameFirstValue(xmlDoc, "SelectWnd")); | ||||||
| cb(parseInt(getTagNameFirstValue(xmlDoc, "SelectWnd"))); | ||||||
| }, | ||||||
| cbDoubleClickWnd: function (iWndIndex, bFullScreen) { | ||||||
|
|
||||||
|
|
@@ -553,6 +551,29 @@ export async function stopRecord(id) { | |||||
| }); | ||||||
| } | ||||||
|
|
||||||
| export async function changeWndNum(id, iWndType) { | ||||||
|
||||||
| export async function changeWndNum(id, iWndType) { | |
| export async function ChangeWndNum(id, iWndType) { |
Copilot
AI
Dec 27, 2025
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.
The parameter 'vision' is retrieved but never used in the function. Consider removing this unused variable declaration to improve code clarity.
| const vision = Data.get(id); |
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.
issue (complexity): Consider extracting the repeated
IsMultipleWindowType-related conditions into dedicated helper properties and using those at call sites to centralize the rules and simplify each method.You can reduce the added complexity by centralizing the new
IsMultipleWindowTypelogic into helper properties so the rules live in one place instead of being duplicated across many methods.For example:
Then use these in the call sites:
Apply
CanControlPlaybacksimilarly toCloseSound,SetVolume,CapturePictureAndDownload,CapturePicture,StartRecord, andStopRecord.This keeps all the multi-window vs. login/playback rules in one place, makes future behavior changes safer (only update the properties), and simplifies the public methods without changing any functionality.