//对方视频断开了,下线了、掉线了、3s以上没有收到数据包
 public void Stop()
 {
     Debug.LogError("Stop:" + bundleUserid);
     YouMeTexture.GetInstance().DeleteRender(bundleUserid);
     videoImage.texture = closeTexture;
     videoButton.gameObject.SetActive(false);
 }
 //这个视频被动暂停了,可能是对方关闭了摄像头
 public void Paused()
 {
     Debug.LogError("Paused:" + bundleUserid);
     videoButton.gameObject.SetActive(false);
     YouMeTexture.GetInstance().PauseVideoRender(bundleUserid);
     videoImage.texture = pauseTexture;
 }
 //屏蔽这个人的视频流
 public void StopVideoRecive()
 {
     videoReciveStoped = true;
     YouMe.YouMeVoiceAPI.GetInstance().MaskVideoByUserId(bundleUserid, true);
     YouMeTexture.GetInstance().PauseVideoRender(bundleUserid);
     videoImage.texture = pauseTexture;
 }
Пример #4
0
    /// <summary>
    /// 进入聊天频道
    /// </summary>
    public void OnClickButtonJoin()
    {
        //只有状态为leaved时才能直接加入频道
        if (YouMe.ChannelState.CHANNEL_STATE_LEAVED == state)
        {
            # if UNITY_ANDROID
            //安卓处理的接口
            var errorCode1 = YouMe.YouMeVoiceAPI.GetInstance().SetVideoFrameRawCbEnabled(true);
            Debug.Log("Android  Status:" + errorCode1);
            #endif
            //获取userID和roomID
            GetID();

            //======================设置分辨率=========================
            YouMe.YouMeVoiceAPI.GetInstance().SetVideoLocalResolution(240, 320);
            YouMe.YouMeVoiceAPI.GetInstance().SetMixVideoSize(240, 320);
            YouMe.YouMeVoiceAPI.GetInstance().AddMixOverlayVideo(selfUserID, 0, 0, 0, 240, 320);
            YouMe.YouMeVoiceAPI.GetInstance().SetVideoNetResolution(240, 320);
            //======================调用加入频道接口=========================
            var errorCode = YouMe.YouMeVoiceAPI.GetInstance().JoinChannelSingleMode(selfUserID, roomID, YouMe.YouMeUserRole.YOUME_USER_TALKER_FREE);

            if (YouMe.YouMeErrorCode.YOUME_SUCCESS == errorCode)
            {
                //只有直接返回值为成功才会进回调
                state = YouMe.ChannelState.CHANNEL_STATE_JOINING;
            }
            //======================调用加入频道接口=========================
            userIds.Clear();
            Debug.Log("User host " + selfUserID + " join");
            userIds.Add(selfUserID, 1);

            //=========================创建视频流=============================
            selfVideoImage.transform.rotation = Quaternion.Euler(180, 0, 0);            //竖屏显示需要旋转下
            int videoRenderid = YouMeTexture.GetInstance().CreateTexture(selfUserID);
            //更新视频,默认15帧每秒
            YouMeTexture.GetInstance().SetVideoRenderUpdateCallback(videoRenderid, (videoTexture) => {
                UpdateVideoRender(videoTexture);
            });
            //=========================创建视频流=============================

            //显示自己的视频开关
            cameraControlButton.gameObject.SetActive(true);
        }
 //这个视频被动恢复正常了,可能是对方重新打开摄像头
 public void Resume()
 {
     Debug.LogError("Resume:" + bundleUserid);
     YouMeTexture.GetInstance().ResumeVideoRender(bundleUserid);
     videoButton.gameObject.SetActive(true);
 }
 //接收这个人的视频流
 public void ResumeVideoRecive()
 {
     videoReciveStoped = false;
     YouMeTexture.GetInstance().ResumeVideoRender(bundleUserid);
     YouMe.YouMeVoiceAPI.GetInstance().MaskVideoByUserId(bundleUserid, false);
 }