Skip to content

Commit 62ab88d

Browse files
committed
refactor: 重构代码
1 parent cb4f77e commit 62ab88d

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/BootstrapBlazor/Components/Camera/Camera.razor.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,18 @@ export function download(id, fileName) {
136136
createEl.remove();
137137
}
138138

139-
export function resize(id, width, height) {
139+
export async function resize(id, width, height) {
140140
const camera = Data.get(id)
141141
if (camera === null || camera.video === void 0) {
142142
return
143143
}
144144

145145
const constrains = {
146-
video: {
147-
deviceId: camera.video.deviceId,
148-
width: { ideal: width },
149-
height: { ideal: height }
150-
}
146+
facingMode: "environment",
147+
width: { ideal: width },
148+
height: { ideal: height }
151149
}
152-
153-
stopDevice(camera)
154-
play(camera, constrains)
150+
await camera.video.track.applyConstraints(constrains);
155151
}
156152

157153
export function dispose(id) {

0 commit comments

Comments
 (0)