110 lines
2.4 KiB
C#
110 lines
2.4 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
|
|
/// <summary>
|
|
/// 本地视频
|
|
/// </summary>
|
|
[AddComponentMenu("LocalVideo/本地视频")]
|
|
public class LocalVideo : MonoBehaviour
|
|
{
|
|
public static LocalVideo Inst;
|
|
public WebSocketT socketT = new WebSocketT();
|
|
public List<ClickEventLens> clickEventLens;
|
|
public List<BaseConf> baseConfs;
|
|
|
|
private void Awake()
|
|
{
|
|
Inst = this;
|
|
baseConfs = clickEventLens.Select(x => x.baseConf).ToList();
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
//socketT.Init("ws://127.0.0.1:8081/websocket");
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void Dispose(string message)
|
|
{
|
|
try
|
|
{
|
|
Root root = JsonConvert.DeserializeObject<Root>(message);
|
|
for (int i = 0; i < baseConfs.Count; i++)
|
|
{
|
|
if (baseConfs[i].conf1.isPicture && root.sourceName == baseConfs[i].conf1.LensName)
|
|
{
|
|
baseConfs[i].conf1.base64 = root.alarmPicture;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.Log("解析本地视频错误:" + e.StackTrace);
|
|
}
|
|
}
|
|
|
|
|
|
[System.Serializable]
|
|
public class Root
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string alarmPicture;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string alarmPictureType;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string alarmIype;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string deviceld;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public int id;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string reference;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string relatedid;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string seg;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string sourceld;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string sourceName;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string timeStamp;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public string type;
|
|
}
|
|
|
|
}
|