using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using UnityEngine; /// /// 本地视频 /// [AddComponentMenu("LocalVideo/本地视频")] public class LocalVideo : MonoBehaviour { public static LocalVideo Inst; public WebSocketT socketT = new WebSocketT(); public List clickEventLens; public List 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://172.16.1.40:8081/websocket"); } // Update is called once per frame void Update() { } public void Dispose(string message) { try { Root root = JsonConvert.DeserializeObject(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 { /// /// /// public string alarmPicture; /// /// /// public string alarmPictureType; /// /// /// public string alarmIype; /// /// /// public string deviceld; /// /// /// public int id; /// /// /// public string reference; /// /// /// public string relatedid; /// /// /// public string seg; /// /// /// public string sourceld; /// /// /// public string sourceName; /// /// /// public string timeStamp; /// /// /// public string type; } }