feat: 前端添加切换摄像头功能
This commit is contained in:
parent
d1c9710afe
commit
e872f24936
|
@ -13,6 +13,45 @@ public class VideoStreamController : ControllerBase
|
|||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
private readonly server.Services.HttpVideoStreamService _videoStreamService;
|
||||
|
||||
/// <summary>
|
||||
/// 视频流信息结构体
|
||||
/// </summary>
|
||||
public class StreamInfoResult
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public int FrameRate { get; set; }
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public int FrameWidth { get; set; }
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public int FrameHeight { get; set; }
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string Format { get; set; } = "MJPEG";
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string HtmlUrl { get; set; } = "";
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string MjpegUrl { get; set; } = "";
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string SnapshotUrl { get; set; } = "";
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
public string UsbCameraUrl { get; set; } = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 摄像头配置请求模型
|
||||
/// </summary>
|
||||
|
@ -96,23 +135,25 @@ public class VideoStreamController : ControllerBase
|
|||
/// <returns>流信息</returns>
|
||||
[HttpGet("StreamInfo")]
|
||||
[EnableCors("Users")]
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(StreamInfoResult), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(Exception), StatusCodes.Status500InternalServerError)]
|
||||
public IResult GetStreamInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.Info("获取 HTTP 视频流信息");
|
||||
return TypedResults.Ok(new
|
||||
var result = new StreamInfoResult
|
||||
{
|
||||
frameRate = _videoStreamService.FrameRate,
|
||||
frameWidth = _videoStreamService.FrameWidth,
|
||||
frameHeight = _videoStreamService.FrameHeight,
|
||||
format = "MJPEG",
|
||||
htmlUrl = $"http://localhost:{_videoStreamService.ServerPort}/video-feed.html",
|
||||
mjpegUrl = $"http://localhost:{_videoStreamService.ServerPort}/video-stream",
|
||||
snapshotUrl = $"http://localhost:{_videoStreamService.ServerPort}/snapshot",
|
||||
});
|
||||
FrameRate = _videoStreamService.FrameRate,
|
||||
FrameWidth = _videoStreamService.FrameWidth,
|
||||
FrameHeight = _videoStreamService.FrameHeight,
|
||||
Format = "MJPEG",
|
||||
HtmlUrl = $"http://localhost:{_videoStreamService.ServerPort}/video-feed.html",
|
||||
MjpegUrl = $"http://localhost:{_videoStreamService.ServerPort}/video-stream",
|
||||
SnapshotUrl = $"http://localhost:{_videoStreamService.ServerPort}/snapshot",
|
||||
UsbCameraUrl = $"http://localhost:{_videoStreamService.ServerPort}/usb-camera"
|
||||
};
|
||||
return TypedResults.Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -68,7 +68,7 @@ export class VideoStreamClient {
|
|||
* 获取 HTTP 视频流信息
|
||||
* @return 流信息
|
||||
*/
|
||||
getStreamInfo(): Promise<any> {
|
||||
getStreamInfo(): Promise<StreamInfoResult> {
|
||||
let url_ = this.baseUrl + "/api/VideoStream/StreamInfo";
|
||||
url_ = url_.replace(/[?&]$/, "");
|
||||
|
||||
|
@ -84,15 +84,14 @@ export class VideoStreamClient {
|
|||
});
|
||||
}
|
||||
|
||||
protected processGetStreamInfo(response: Response): Promise<any> {
|
||||
protected processGetStreamInfo(response: Response): Promise<StreamInfoResult> {
|
||||
const status = response.status;
|
||||
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
||||
if (status === 200) {
|
||||
return response.text().then((_responseText) => {
|
||||
let result200: any = null;
|
||||
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
||||
result200 = resultData200 !== undefined ? resultData200 : <any>null;
|
||||
|
||||
result200 = StreamInfoResult.fromJS(resultData200);
|
||||
return result200;
|
||||
});
|
||||
} else if (status === 500) {
|
||||
|
@ -107,7 +106,7 @@ export class VideoStreamClient {
|
|||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||
});
|
||||
}
|
||||
return Promise.resolve<any>(null as any);
|
||||
return Promise.resolve<StreamInfoResult>(null as any);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4673,6 +4672,88 @@ export interface IException {
|
|||
stackTrace?: string | undefined;
|
||||
}
|
||||
|
||||
/** 视频流信息结构体 */
|
||||
export class StreamInfoResult implements IStreamInfoResult {
|
||||
/** TODO: */
|
||||
frameRate!: number;
|
||||
/** TODO: */
|
||||
frameWidth!: number;
|
||||
/** TODO: */
|
||||
frameHeight!: number;
|
||||
/** TODO: */
|
||||
format!: string;
|
||||
/** TODO: */
|
||||
htmlUrl!: string;
|
||||
/** TODO: */
|
||||
mjpegUrl!: string;
|
||||
/** TODO: */
|
||||
snapshotUrl!: string;
|
||||
/** TODO: */
|
||||
usbCameraUrl!: string;
|
||||
|
||||
constructor(data?: IStreamInfoResult) {
|
||||
if (data) {
|
||||
for (var property in data) {
|
||||
if (data.hasOwnProperty(property))
|
||||
(<any>this)[property] = (<any>data)[property];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(_data?: any) {
|
||||
if (_data) {
|
||||
this.frameRate = _data["frameRate"];
|
||||
this.frameWidth = _data["frameWidth"];
|
||||
this.frameHeight = _data["frameHeight"];
|
||||
this.format = _data["format"];
|
||||
this.htmlUrl = _data["htmlUrl"];
|
||||
this.mjpegUrl = _data["mjpegUrl"];
|
||||
this.snapshotUrl = _data["snapshotUrl"];
|
||||
this.usbCameraUrl = _data["usbCameraUrl"];
|
||||
}
|
||||
}
|
||||
|
||||
static fromJS(data: any): StreamInfoResult {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
let result = new StreamInfoResult();
|
||||
result.init(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
toJSON(data?: any) {
|
||||
data = typeof data === 'object' ? data : {};
|
||||
data["frameRate"] = this.frameRate;
|
||||
data["frameWidth"] = this.frameWidth;
|
||||
data["frameHeight"] = this.frameHeight;
|
||||
data["format"] = this.format;
|
||||
data["htmlUrl"] = this.htmlUrl;
|
||||
data["mjpegUrl"] = this.mjpegUrl;
|
||||
data["snapshotUrl"] = this.snapshotUrl;
|
||||
data["usbCameraUrl"] = this.usbCameraUrl;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/** 视频流信息结构体 */
|
||||
export interface IStreamInfoResult {
|
||||
/** TODO: */
|
||||
frameRate: number;
|
||||
/** TODO: */
|
||||
frameWidth: number;
|
||||
/** TODO: */
|
||||
frameHeight: number;
|
||||
/** TODO: */
|
||||
format: string;
|
||||
/** TODO: */
|
||||
htmlUrl: string;
|
||||
/** TODO: */
|
||||
mjpegUrl: string;
|
||||
/** TODO: */
|
||||
snapshotUrl: string;
|
||||
/** TODO: */
|
||||
usbCameraUrl: string;
|
||||
}
|
||||
|
||||
/** 摄像头配置请求模型 */
|
||||
export class CameraConfigRequest implements ICameraConfigRequest {
|
||||
/** 摄像头地址 */
|
||||
|
|
|
@ -8,17 +8,14 @@
|
|||
控制面板
|
||||
</h2>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||
<div class="grid grid-cols-1 gap-4"
|
||||
:class="{ 'md:grid-cols-3': streamType === 'usbCamera', 'md:grid-cols-4': streamType === 'videoStream' }">
|
||||
<!-- 服务状态 -->
|
||||
<div class="stats shadow">
|
||||
<div class="stat bg-base-100">
|
||||
<div class="stat-figure text-primary">
|
||||
<div
|
||||
class="badge"
|
||||
:class="
|
||||
statusInfo.isRunning ? 'badge-success' : 'badge-error'
|
||||
"
|
||||
>
|
||||
<div class="badge" :class="statusInfo.isRunning ? 'badge-success' : 'badge-error'
|
||||
">
|
||||
{{ statusInfo.isRunning ? "运行中" : "已停止" }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -43,30 +40,23 @@
|
|||
</div>
|
||||
|
||||
<!-- 分辨率控制 -->
|
||||
<div class="stats shadow">
|
||||
<div v-show="streamType === 'videoStream'" class="stats shadow">
|
||||
<div class="stat bg-base-100">
|
||||
<div class="stat-figure text-info">
|
||||
<Settings class="w-8 h-8" />
|
||||
</div>
|
||||
<div class="stat-title">分辨率设置</div>
|
||||
<div class="stat-value text-sm">
|
||||
<select
|
||||
class="select select-sm select-bordered max-w-xs"
|
||||
v-model="selectedResolution"
|
||||
@change="changeResolution"
|
||||
:disabled="changingResolution"
|
||||
>
|
||||
<select class="select select-sm select-bordered max-w-xs" v-model="selectedResolution"
|
||||
@change="changeResolution" :disabled="changingResolution">
|
||||
<option v-for="res in supportedResolutions" :key="`${res.width}x${res.height}`" :value="res">
|
||||
{{ res.width }}×{{ res.height }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="stat-desc">
|
||||
<button
|
||||
class="btn btn-xs btn-outline btn-info mt-1"
|
||||
@click="refreshResolutions"
|
||||
:disabled="loadingResolutions"
|
||||
>
|
||||
<button class="btn btn-xs btn-outline btn-info mt-1" @click="refreshResolutions"
|
||||
:disabled="loadingResolutions">
|
||||
<RefreshCw v-if="loadingResolutions" class="animate-spin h-3 w-3" />
|
||||
{{ loadingResolutions ? "刷新中..." : "刷新" }}
|
||||
</button>
|
||||
|
@ -86,30 +76,18 @@
|
|||
</div>
|
||||
<div class="stat-desc">
|
||||
<div class="dropdown dropdown-hover dropdown-top">
|
||||
<div
|
||||
tabindex="0"
|
||||
role="button"
|
||||
class="text-xs underline cursor-help"
|
||||
>
|
||||
<div tabindex="0" role="button" class="text-xs underline cursor-help">
|
||||
查看客户端
|
||||
</div>
|
||||
<ul
|
||||
tabindex="0"
|
||||
class="dropdown-content z-20 menu p-2 shadow bg-base-200 rounded-box w-64 max-h-48 overflow-y-auto"
|
||||
>
|
||||
<li
|
||||
v-for="(client, index) in statusInfo.clientEndpoints"
|
||||
:key="index"
|
||||
class="text-xs"
|
||||
>
|
||||
<ul tabindex="0"
|
||||
class="dropdown-content z-20 menu p-2 shadow bg-base-200 rounded-box w-64 max-h-48 overflow-y-auto">
|
||||
<li v-for="(client, index) in statusInfo.clientEndpoints" :key="index" class="text-xs">
|
||||
<a class="break-all">{{ client }}</a>
|
||||
</li>
|
||||
<li
|
||||
v-if="
|
||||
<li v-if="
|
||||
!statusInfo.clientEndpoints ||
|
||||
statusInfo.clientEndpoints.length === 0
|
||||
"
|
||||
>
|
||||
">
|
||||
<a class="text-xs opacity-50">无活跃连接</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -121,29 +99,21 @@
|
|||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="card-actions justify-end mt-4">
|
||||
<button
|
||||
class="btn btn-outline btn-primary"
|
||||
@click="configCamera"
|
||||
:dsiabled="configing"
|
||||
>
|
||||
<button class="btn btn-outline btn-warning mr-2" @click="toggleStreamType" :disabled="isSwitchingStreamType">
|
||||
<SwitchCamera class="h-4 w-4 mr-2" />
|
||||
{{ streamType === 'usbCamera' ? '切换到视频流' : '切换到USB摄像头' }}
|
||||
</button>
|
||||
<button v-show="streamType === 'videoStream'" class="btn btn-outline btn-primary" @click="configCamera" :disabled="configing">
|
||||
<RefreshCw v-if="configing" class="animate-spin h-4 w-4 mr-2" />
|
||||
<CogIcon v-else class="h-4 w-4 mr-2" />
|
||||
{{ configing ? "配置中..." : "配置摄像头" }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-outline btn-primary"
|
||||
@click="refreshStatus"
|
||||
:disabled="loading"
|
||||
>
|
||||
<button class="btn btn-outline btn-primary" @click="refreshStatus" :disabled="loading">
|
||||
<RefreshCw v-if="loading" class="animate-spin h-4 w-4 mr-2" />
|
||||
<RefreshCw v-else class="h-4 w-4 mr-2" />
|
||||
{{ loading ? "刷新中..." : "刷新状态" }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
@click="testConnection"
|
||||
:disabled="testing"
|
||||
>
|
||||
<button v-show="streamType === 'videoStream'" class="btn btn-primary" @click="testConnection" :disabled="testing">
|
||||
<RefreshCw v-if="testing" class="animate-spin h-4 w-4 mr-2" />
|
||||
<TestTube v-else class="h-4 w-4 mr-2" />
|
||||
{{ testing ? "测试中..." : "测试连接" }}
|
||||
|
@ -160,42 +130,24 @@
|
|||
视频预览
|
||||
</h2>
|
||||
|
||||
<div
|
||||
class="relative bg-black rounded-lg overflow-hidden cursor-pointer"
|
||||
:class="[
|
||||
<div class="relative bg-black rounded-lg overflow-hidden cursor-pointer" :class="[
|
||||
focusAnimationClass,
|
||||
{ 'cursor-not-allowed': !isPlaying || hasVideoError }
|
||||
]"
|
||||
style="aspect-ratio: 4/3"
|
||||
@click="handleVideoClick"
|
||||
>
|
||||
]" style="aspect-ratio: 4/3" @click="handleVideoClick">
|
||||
<!-- 视频播放器 - 使用img标签直接显示MJPEG流 -->
|
||||
<div
|
||||
v-show="isPlaying"
|
||||
class="w-full h-full flex items-center justify-center"
|
||||
>
|
||||
<img
|
||||
:src="currentVideoSource"
|
||||
alt="视频流"
|
||||
class="max-w-full max-h-full object-contain"
|
||||
@error="handleVideoError"
|
||||
@load="handleVideoLoad"
|
||||
/>
|
||||
<div v-show="isPlaying" class="w-full h-full flex items-center justify-center">
|
||||
<img :src="currentVideoSource" alt="视频流" class="max-w-full max-h-full object-contain"
|
||||
@error="handleVideoError" @load="handleVideoLoad" />
|
||||
</div>
|
||||
|
||||
<!-- 对焦提示 -->
|
||||
<div
|
||||
v-if="isPlaying && !hasVideoError"
|
||||
class="absolute top-4 right-4 text-white text-sm bg-black bg-opacity-50 px-2 py-1 rounded"
|
||||
>
|
||||
<div v-if="isPlaying && !hasVideoError"
|
||||
class="absolute top-4 right-4 text-white text-sm bg-black bg-opacity-50 px-2 py-1 rounded">
|
||||
{{ isFocusing ? '对焦中...' : '点击画面对焦' }}
|
||||
</div>
|
||||
|
||||
<!-- 错误信息显示 -->
|
||||
<div
|
||||
v-if="hasVideoError"
|
||||
class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-70"
|
||||
>
|
||||
<div v-if="hasVideoError" class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-70">
|
||||
<div class="card bg-error text-white shadow-lg w-full max-w-lg">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title flex items-center gap-2">
|
||||
|
@ -209,10 +161,7 @@
|
|||
<li>端口 {{ statusInfo.serverPort }} 是否可访问</li>
|
||||
</ul>
|
||||
<div class="card-actions justify-end mt-2">
|
||||
<button
|
||||
class="btn btn-sm btn-outline btn-primary"
|
||||
@click="tryReconnect"
|
||||
>
|
||||
<button class="btn btn-sm btn-outline btn-primary" @click="tryReconnect">
|
||||
重试连接
|
||||
</button>
|
||||
</div>
|
||||
|
@ -221,10 +170,8 @@
|
|||
</div>
|
||||
|
||||
<!-- 占位符 -->
|
||||
<div
|
||||
v-show="!isPlaying && !hasVideoError"
|
||||
class="absolute inset-0 flex items-center justify-center text-white"
|
||||
>
|
||||
<div v-show="!isPlaying && !hasVideoError"
|
||||
class="absolute inset-0 flex items-center justify-center text-white">
|
||||
<div class="text-center">
|
||||
<Video class="w-16 h-16 mx-auto mb-4 opacity-50" />
|
||||
<p class="text-lg opacity-75">{{ videoStatus }}</p>
|
||||
|
@ -245,18 +192,11 @@
|
|||
</div>
|
||||
<div class="space-x-2">
|
||||
<div class="dropdown dropdown-hover dropdown-top dropdown-end">
|
||||
<div
|
||||
tabindex="0"
|
||||
role="button"
|
||||
class="btn btn-sm btn-outline btn-accent"
|
||||
>
|
||||
<div tabindex="0" role="button" class="btn btn-sm btn-outline btn-accent">
|
||||
<MoreHorizontal class="w-4 h-4 mr-1" />
|
||||
更多功能
|
||||
</div>
|
||||
<ul
|
||||
tabindex="0"
|
||||
class="dropdown-content z-[1] menu p-2 shadow bg-base-200 rounded-box w-52"
|
||||
>
|
||||
<ul tabindex="0" class="dropdown-content z-[1] menu p-2 shadow bg-base-200 rounded-box w-52">
|
||||
<li>
|
||||
<a @click="openInNewTab(streamInfo.htmlUrl)">
|
||||
<ExternalLink class="w-4 h-4" />
|
||||
|
@ -277,19 +217,11 @@
|
|||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-success btn-sm"
|
||||
@click="startStream"
|
||||
:disabled="isPlaying"
|
||||
>
|
||||
<button class="btn btn-success btn-sm" @click="startStream" :disabled="isPlaying">
|
||||
<Play class="w-4 h-4 mr-1" />
|
||||
播放视频流
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-error btn-sm"
|
||||
@click="stopStream"
|
||||
:disabled="!isPlaying"
|
||||
>
|
||||
<button class="btn btn-error btn-sm" @click="stopStream" :disabled="!isPlaying">
|
||||
<Square class="w-4 h-4 mr-1" />
|
||||
停止视频流
|
||||
</button>
|
||||
|
@ -307,20 +239,11 @@
|
|||
</h2>
|
||||
|
||||
<div class="bg-base-300 rounded-lg p-4 h-48 overflow-y-auto">
|
||||
<div
|
||||
v-for="(log, index) in logs"
|
||||
:key="index"
|
||||
class="text-sm font-mono mb-1"
|
||||
>
|
||||
<span class="text-base-content/50"
|
||||
>[{{ formatTime(log.time) }}]</span
|
||||
>
|
||||
<div v-for="(log, index) in logs" :key="index" class="text-sm font-mono mb-1">
|
||||
<span class="text-base-content/50">[{{ formatTime(log.time) }}]</span>
|
||||
<span :class="getLogClass(log.level)">{{ log.message }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="logs.length === 0"
|
||||
class="text-base-content/50 text-center py-8"
|
||||
>
|
||||
<div v-if="logs.length === 0" class="text-base-content/50 text-center py-8">
|
||||
暂无日志记录
|
||||
</div>
|
||||
</div>
|
||||
|
@ -352,8 +275,9 @@ import {
|
|||
FileText,
|
||||
AlertTriangle,
|
||||
MoreHorizontal,
|
||||
SwitchCamera,
|
||||
} from "lucide-vue-next";
|
||||
import { VideoStreamClient, CameraConfigRequest, ResolutionConfigRequest } from "@/APIClient";
|
||||
import { VideoStreamClient, CameraConfigRequest, ResolutionConfigRequest, StreamInfoResult } from "@/APIClient";
|
||||
import { useEquipments } from "@/stores/equipments";
|
||||
|
||||
const eqps = useEquipments();
|
||||
|
@ -366,6 +290,10 @@ const isPlaying = ref(false);
|
|||
const hasVideoError = ref(false);
|
||||
const videoStatus = ref('点击"播放视频流"按钮开始查看实时视频');
|
||||
|
||||
// 视频流类型切换相关
|
||||
const streamType = ref<'usbCamera' | 'videoStream'>('videoStream');
|
||||
const isSwitchingStreamType = ref(false);
|
||||
|
||||
// 对焦相关状态
|
||||
const isFocusing = ref(false);
|
||||
const focusAnimationClass = ref('');
|
||||
|
@ -390,7 +318,7 @@ const statusInfo = ref({
|
|||
clientEndpoints: [] as string[],
|
||||
});
|
||||
|
||||
const streamInfo = ref({
|
||||
const streamInfo = ref<StreamInfoResult>(new StreamInfoResult({
|
||||
frameRate: 30,
|
||||
frameWidth: 640,
|
||||
frameHeight: 480,
|
||||
|
@ -398,7 +326,8 @@ const streamInfo = ref({
|
|||
htmlUrl: "",
|
||||
mjpegUrl: "",
|
||||
snapshotUrl: "",
|
||||
});
|
||||
usbCameraUrl: "",
|
||||
}));
|
||||
|
||||
const currentVideoSource = ref("");
|
||||
const logs = ref<Array<{ time: Date; level: string; message: string }>>([]);
|
||||
|
@ -462,6 +391,27 @@ const openInNewTab = (url: string) => {
|
|||
addLog("info", `已在新标签打开视频页面: ${url}`);
|
||||
};
|
||||
|
||||
// 切换视频流类型
|
||||
const toggleStreamType = async () => {
|
||||
if (isSwitchingStreamType.value) return;
|
||||
isSwitchingStreamType.value = true;
|
||||
try {
|
||||
// 这里假设后端有API: setStreamType(type: string)
|
||||
addLog('info', `正在切换视频流类型到${streamType.value === 'usbCamera' ? '视频流' : 'USB摄像头'}...`);
|
||||
refreshStatus();
|
||||
|
||||
// 设置视频源
|
||||
streamType.value = streamType.value === 'usbCamera' ? 'videoStream' : 'usbCamera';
|
||||
addLog('success', `已切换到${streamType.value === 'usbCamera' ? 'USB摄像头' : '视频流'}`);
|
||||
stopStream();
|
||||
} catch (error) {
|
||||
addLog('error', `切换视频流类型失败: ${error}`);
|
||||
console.error('切换视频流类型失败:', error);
|
||||
} finally {
|
||||
isSwitchingStreamType.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 获取并下载快照
|
||||
const takeSnapshot = async () => {
|
||||
try {
|
||||
|
@ -654,7 +604,7 @@ const startStream = async () => {
|
|||
await refreshStatus();
|
||||
|
||||
// 设置视频源
|
||||
currentVideoSource.value = streamInfo.value.mjpegUrl;
|
||||
currentVideoSource.value = streamType.value === 'usbCamera' ? streamInfo.value.usbCameraUrl : streamInfo.value.mjpegUrl;
|
||||
|
||||
// 设置播放状态
|
||||
isPlaying.value = true;
|
||||
|
@ -810,21 +760,27 @@ img {
|
|||
0% {
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
100% {
|
||||
border-color: #fbbf24; /* 黄色 */
|
||||
border-color: #fbbf24;
|
||||
/* 黄色 */
|
||||
box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes focus-success-animation {
|
||||
0% {
|
||||
border-color: #fbbf24; /* 黄色 */
|
||||
border-color: #fbbf24;
|
||||
/* 黄色 */
|
||||
box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
|
||||
}
|
||||
|
||||
50% {
|
||||
border-color: #10b981; /* 绿色 */
|
||||
border-color: #10b981;
|
||||
/* 绿色 */
|
||||
box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
|
||||
}
|
||||
|
||||
100% {
|
||||
border-color: transparent;
|
||||
box-shadow: none;
|
||||
|
@ -833,13 +789,17 @@ img {
|
|||
|
||||
@keyframes focus-error-animation {
|
||||
0% {
|
||||
border-color: #fbbf24; /* 黄色 */
|
||||
border-color: #fbbf24;
|
||||
/* 黄色 */
|
||||
box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
|
||||
}
|
||||
|
||||
50% {
|
||||
border-color: #ef4444; /* 红色 */
|
||||
border-color: #ef4444;
|
||||
/* 红色 */
|
||||
box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
|
||||
}
|
||||
|
||||
100% {
|
||||
border-color: transparent;
|
||||
box-shadow: none;
|
||||
|
|
Loading…
Reference in New Issue