123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BigVideoManager : MonoBehaviour
- {
- public MeshRenderer videoMr;
- public MeshRenderer audioMr;
- public Material gray;
- public Material color;
- public TextMesh titleName;
- public CustomPeer cp;
- public MeshRenderer mr;
- public GameObject isVideoGM;
- public GameObject isAudioGM;
- public void init()
- {
- cp.isBig = true;
- cp.bigView = this.gameObject;
- CustomRTC.Instance.list.initList(CustomRTC.Instance.cpl);
- cp.onChangeTexture += onChangeTexture;
- cp.onChangeInfo += onChangeInfo;
- mr.material.mainTexture = cp.tex;
- if (cp.cIdV != null && cp.cIdV != ""&& cp.isVideo)
- isVideoGM.SetActive(false);
- else
- {
- mr.material.mainTexture = CustomRTC.Instance.t2;
- isVideoGM.SetActive(true);
- }
- if (cp.cIdA != null && cp.cIdA != "" && cp.isAudio)
- isAudioGM.SetActive(false);
- else
- isAudioGM.SetActive(true);
- titleName.text = "用户名:" + cp.name;
- if (cp.cIdV == "")
- {
- videoMr.material = gray;
- }
- else
- {
- videoMr.material = color;
- }
- if (cp.cIdA == "")
- {
- audioMr.material = gray;
- }
- else
- {
- audioMr.material = color;
- }
- }
- public void onChangeCloseInfo()
- {
- Debug.Log("onChangeInfo。。。。");
- if (cp.cIdV == "")
- {
- if (cp.isVideo)
- {
- isVideoGM.SetActive(false);
- }
- else
- {
- isVideoGM.SetActive(true);
- }
- mr.material.mainTexture = CustomRTC.Instance.t2;
- videoMr.material = gray;
- }
- else if(cp.cIdA=="")
- {
- audioMr.material = gray;
- if (cp.isAudio)
- {
- isAudioGM.SetActive(false);
- }
- else
- {
- isAudioGM.SetActive(true);
- }
- }
- }
- private void onChangeTexture()
- {
- if (cp.isVideo)
- {
- mr.material.mainTexture = cp.tex;
- }
- }
- private void onChangeInfo(string type, string id)
- {
- Debug.Log("onChangeInfo。。。。");
- if (type == "video")
- {
- if (cp.isVideo)
- {
- isVideoGM.SetActive(false);
- }
- else
- {
- isVideoGM.SetActive(true);
- }
- videoMr.material = color;
- }
- else
- {
- audioMr.material = color;
- if (cp.isAudio)
- {
- isAudioGM.SetActive(false);
- }
- else
- {
- isAudioGM.SetActive(true);
- }
- }
- }
- private void OnDestroy()
- {
- cp.onChangeTexture -= onChangeTexture;
- cp.onChangeInfo -= onChangeInfo;
- }
- public void close()
- {
- cp.isBig = false;
- CustomRTC.Instance.list.initList(CustomRTC.Instance.cpl);
- Destroy(this.gameObject);
- }
- public void closeRemove()
- {
- cp.isBig = false;
- // CustomRTC.Instance.list.initList(CustomRTC.Instance.cpl);
- Destroy(this.gameObject);
- }
- public void chooseVideo()
- {
- if (isVideoGM.activeSelf)
- {
- openVideo();
- }
- else
- {
- closeVideo();
- }
- }
- public void chooseAudio()
- {
- if (isAudioGM.activeSelf)
- {
- openAudio();
- }
- else
- {
- closeAudio();
- }
- }
- public void openVideo()
- {
- if (cp.cIdV != "")
- {
- cp.isVideo = true;
- SCRtcFactory.Instance.mSCRtcHandle.openRev(cp.cIdV);
- mr.material.mainTexture = cp.tex;
- // if (cidV != "")
- // SCRtcFactory.Instance.mSCRtcHandle.openRev(cidV);
- // Debug.Log("openVideo2" + cidV);
- isVideoGM.SetActive(false);
- if (CustomRTC.Instance.bigNameID == "")
- {
- CustomRTC.Instance.showNextTexture();
- }
- }
- }
- public void closeVideo()
- {
- if (cp.cIdV != "")
- {
- cp.isVideo = false;
- SCRtcFactory.Instance.mSCRtcHandle.closeRev(cp.cIdV);
- Texture2D oVideo = cp.tex;
- mr.material.mainTexture = CustomRTC.Instance.t2;
- isVideoGM.SetActive(true);
- if (CustomRTC.Instance.bigNameID == cp.peerId)
- {
- CustomRTC.Instance.showNextTexture();
- }
- }
- }
- public void openAudio()
- {
- if (cp.cIdA != "")
- {
- cp.isAudio = true;
- SCRtcFactory.Instance.mSCRtcHandle.openRev(cp.cIdA);
- isAudioGM.SetActive(false);
- }
- }
- public void closeAudio()
- {
- if (cp.cIdA != "")
- {
- cp.isAudio = false;
- SCRtcFactory.Instance.mSCRtcHandle.closeRev(cp.cIdA);
- isAudioGM.SetActive(true);
- }
- }
- }
|