public void showRemoteVideo(uint uid)
 {
     clearRemoteVideo();
     if (remoteVideoObject != null)
     {
         VideoSurface videoSurface = remoteVideoObject.AddComponent <VideoSurface>() as VideoSurface;
         if (videoSurface != null)
         {
             videoSurface.SetForUser(uid);
             //videoSurface.SetEnable(true);
             if (isRemoteVideo3D)
             {
                 videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.Renderer);
             }
             else
             {
                 videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
             }
             //videoSurface.SetGameFps(30);
         }
     }
     else
     {
         Debug.LogWarning("Cannot show remote video because remoteVideoObject is null!");
     }
 }
 public void showLocalVideo()
 {
     clearLocalVideo();
     if (localVideoObject != null)
     {
         VideoSurface videoSurface = localVideoObject.AddComponent <VideoSurface>() as VideoSurface;
         if (videoSurface != null)
         {
             videoSurface.SetForUser(0); //0 is for local user
             //videoSurface.SetEnable(true);
             if (isLocalVideo3D)
             {
                 videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.Renderer);
             }
             else
             {
                 videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
             }
             //videoSurface.SetGameFps(30);
         }
     }
     else
     {
         Debug.LogWarning("Cannot show local video because localVideoObject is null!");
     }
 }
    // When a remote user joined, this delegate will be called. Typically
    // create a GameObject to render video on it
    private void onUserJoined(uint uid, int elapsed)
    {
        Debug.Log("onUserJoined: uid = " + uid + " elapsed = " + elapsed);
        // this is called in main thread

        // find a game object to render video stream from 'uid'
        GameObject go = GameObject.Find(uid.ToString());

        if (!ReferenceEquals(go, null))
        {
            return; // reuse
        }

        // create a GameObject and assign to this new user
        VideoSurface videoSurface = makeImageSurface(uid.ToString());

        if (!ReferenceEquals(videoSurface, null))
        {
            // configure videoSurface
            videoSurface.SetForUser(uid);
            videoSurface.SetEnable(true);
            videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
            videoSurface.SetGameFps(30);
        }
    }
    // When a remote user joined, this delegate will be called. Typically
    // create a GameObject to render video on it
    protected virtual void OnUserJoined(uint uid, int elapsed)
    {
        Debug.Log("onUserJoined: uid = " + uid + " elapsed = " + elapsed);

        // find a game object to render video stream from 'uid'
        GameObject go = GameObject.Find(uid.ToString());

        if (!ReferenceEquals(go, null))
        {
            return; // reuse
        }

        // create a GameObject and assign to this new user
        VideoSurface videoSurface = makeImageSurface(uid.ToString());

        if (!ReferenceEquals(videoSurface, null))
        {
            // configure videoSurface
            videoSurface.SetForUser(uid);
            videoSurface.SetEnable(true);
            videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
            videoSurface.SetGameFps(30);
            videoSurface.EnableFilpTextureApply(enableFlipHorizontal: true, enableFlipVertical: false);
            UserVideoDict[uid] = videoSurface;
            Vector2 pos = AgoraUIUtils.GetRandomPosition(100);
            videoSurface.transform.localPosition = new Vector3(pos.x, pos.y, 0);
        }
    }
Exemple #5
0
    void OnUserJoinedHandler(uint uid, int elapsed)
    {
        Debug.Log("onUserJoined: uid = " + uid + " elapsed = " + elapsed);

        // find a game object to render video stream from 'uid'
        GameObject go = GameObject.Find(uid.ToString());

        if (go != null)
        {
            return;
        }

        // create a GameObject and assign to this new user
        VideoSurface videoSurface = makeImageSurface(uid.ToString());

        if (videoSurface != null)
        {
            // configure videoSurface
            videoSurface.SetForUser(uid);
            videoSurface.SetEnable(true);
            videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
            videoSurface.SetGameFps(30);
        }

        usersInChannel++;
    }
    private void OnUserJoined(uint uid, int elapsed)
    {
        print("user joined");
        remoteVideo.name = uid.ToString();
        VideoSurface videoSurface = makeImageSurface(uid.ToString());

        if (!ReferenceEquals(videoSurface, null))
        {
            videoSurface.SetForUser(uid);
            videoSurface.SetEnable(true);
            videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
            videoSurface.SetGameFps(30);
        }
    }
Exemple #7
0
    void OnUserJoined(uint uid, int elapsed)
    {
        GameObject go = GameObject.Find("RemoteView");

        if (remoteView == null)
        {
            remoteView = go.AddComponent <VideoSurface>();
        }

        remoteView.SetForUser(uid);
        remoteView.SetEnable(true);
        remoteView.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
        remoteView.SetGameFps(30);
    }
Exemple #8
0
    void CreateNewUserVideoFrame(uint newUserUid)
    {
        if (photonView.isMine)
        {
            userCount++;

            GameObject newUserVideo = Instantiate(videoSurfacePrefab, transform.GetChild(1));

            newUserVideo.GetComponent <RectTransform>().anchoredPosition += Vector2.right * 120 * userCount;

            VideoSurface videoControls = newUserVideo.GetComponent <VideoSurface>();
            videoControls.SetForUser(newUserUid);
            videoControls.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
            videoControls.SetEnable(true);
        }
    }
        void OnUserJoinedHandler(uint uid, int elapsed)
        {
            logger.UpdateLog(string.Format("OnUserJoined uid: ${0} elapsed: ${1}", uid, elapsed));
            GameObject go = Instantiate(userPrefab);

            RemoteUserObject[uid] = go;
            go.transform.SetParent(rootSpace);
            go.transform.localScale    = Vector3.one;
            go.transform.localPosition = new Vector3(userCount * 2, 0, 0);

            VideoSurface v = go.AddComponent <VideoSurface>();

            v.SetForUser(uid);
            v.SetEnable(true);
            v.SetVideoSurfaceType(AgoraVideoSurfaceType.Renderer);
            userCount++;
        }
    void VideoImageClicked(string name)
    {
        if (bigPicTemp != null)
        {
            if (bigPicTemp.name == name)
            {
                removeObserver(uint.Parse(name));
                AddObserver(uint.Parse(name));
            }
            RemoveBig();
        }
        else
        {
            GameObject go = null;
            for (int i = 0; i < allObserver.Count; i++)
            {
                if (allObserver[i].name == name)
                {
                    go = allObserver[i];
                    break;
                }
                Debug.Log(name);
            }
            if (go != null)
            {
                VideoSurface video1 = go.GetComponent <VideoSurface>();
                DestroyImmediate(video1);
            }

            bigPicTemp                  = Instantiate(bigPic);
            bigPicTemp.name             = name;
            bigPicTemp.transform.parent = bkaVideoParent;
            bigPicTemp.GetComponent <RectTransform>().SetAsFirstSibling();
            bigPicTemp.transform.localScale = new Vector3(1, -1, 1);
            bigPicTemp.SetActive(true);
            VideoSurface videoSurface = bigPicTemp.AddComponent <VideoSurface>();
            videoSurface.resize = true;
            videoSurface.expert = isExpert;
            // configure videoSurface
            videoSurface.SetForUser(uint.Parse(name));
            videoSurface.SetEnable(true);
            videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
            videoSurface.SetGameFps(25);
        }
    }
Exemple #11
0
    private void makeVideoView(uint uid)
    {
        GameObject go = GameObject.Find(uid.ToString());

        if (!ReferenceEquals(go, null))
        {
            return; // reuse
        }

        // create a GameObject and assign to this new user
        VideoSurface videoSurface = makeImageSurface(uid.ToString());

        if (!ReferenceEquals(videoSurface, null))
        {
            // configure videoSurface
            videoSurface.SetForUser(uid);
            videoSurface.SetEnable(true);
            videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
            videoSurface.SetGameFps(30);
        }
    }
Exemple #12
0
    private void makeVideoView(string channelId, uint uid)
    {
        string     objName = channelId + "_" + uid.ToString();
        GameObject go      = GameObject.Find(objName);

        if (!ReferenceEquals(go, null))
        {
            return; // reuse
        }

        // create a GameObject and assign to this new user
        VideoSurface videoSurface = makeImageSurface(objName);

        if (!ReferenceEquals(videoSurface, null))
        {
            // configure videoSurface
            videoSurface.SetForMultiChannelUser(channelId, uid);
            videoSurface.SetEnable(true);
            videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
            videoSurface.SetGameFps(30);
        }
    }
    public void AddObserver(uint uid)
    {
        GameObject go = Instantiate(prefab);

        go.name                 = uid.ToString();
        go.transform.parent     = transform;
        go.transform.localScale = new Vector3(1, -1, 1);// Vector3.one;
        go.GetComponent <Button>().onClick.AddListener(delegate
        {
            VideoImageClicked(go.name);
        });
        // set up transform
        VideoSurface videoSurface = go.AddComponent <VideoSurface>();

        // configure videoSurface
        videoSurface.SetForUser(uid);
        videoSurface.SetEnable(true);
        videoSurface.SetVideoSurfaceType(AgoraVideoSurfaceType.RawImage);
        videoSurface.SetGameFps(25);
        allObserver.Add(go);
        //更新大小
        UpdateSelfSize(allObserver.Count);
    }