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!");
     }
 }
Exemple #2
0
    private void OnUserJoined(uint uid, int elapsed)
    {
        Debug.Log("New user has joined channel with id" + uid);

        // add remote stream to scene

        // create game object
        GameObject go;

        go = GameObject.CreatePrimitive(PrimitiveType.Plane);

        go.name = uid.ToString();

        // configure video surface
        VideoSurface o = go.AddComponent <VideoSurface>();

        o.SetForUser(uid);
        o.mAdjustTransform += OnTransformDelegate;
        o.SetEnable(true);
        o.transform.Rotate(-90.0f, 0.0f, 0.0f);
        float r = Random.Range(-5.0f, 5.0f);

        o.transform.position   = new Vector3(0f, r, 0f);
        o.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f);

        mRemotePeer = uid;
    }
Exemple #3
0
    protected override void SetupUI()
    {
        base.SetupUI();
        Button titleBtn = GameObject.Find("TitleButton").GetComponent <Button>();

        titleBtn.onClick.AddListener(() => { Application.OpenURL(DOCUMENTATION_URL); });

        Button startButton = GameObject.Find("StartButton").GetComponent <Button>();

        startButton.onClick.AddListener(() => { HandleStartButtonClick(startButton); });

        host1 = GameObject.Find("Host1").AddComponent <VideoSurface>();
        host2 = GameObject.Find("Host2").AddComponent <VideoSurface>();
        host1.SetEnable(false);
        host2.SetEnable(false);

        GameObject loggerObj = GameObject.Find("LoggerText");

        if (loggerObj != null)
        {
            Text text = loggerObj.GetComponent <Text>();
            if (text != null)
            {
                logger = new Logger(text);
                logger.Clear();
            }
        }
    }
Exemple #4
0
    // 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.LogError("onUserJoined: uid = " + uid);
        // 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 assigne to this new user
        go = GameObject.CreatePrimitive(PrimitiveType.Cube);
        if (!ReferenceEquals(go, null))
        {
            go.name = uid.ToString();

            // configure videoSurface
            VideoSurface o = go.AddComponent <VideoSurface>();
            o.SetForUser(uid);
            o.SetEnable(true);
            o.transform.Rotate(-90.0f, 0.0f, 0.0f);
            o.transform.position   = getNextCubePosition();
            o.transform.localScale = Vector3.one;
        }
        OnEnable();
    }
    public VideoSurface makeImageSurface(string goName)
    {
        GameObject go = new GameObject();

        if (go == null)
        {
            return(null);
        }

        go.name = goName;

        // to be renderered onto
        go.AddComponent <RawImage>();

        // make the object draggable
        //go.AddComponent<UIElementDragger>();
        GameObject canvas = GameObject.Find("Canvas");

        if (canvas != null)
        {
            go.transform.parent = canvas.transform;
        }
        // set up transform
        go.transform.Rotate(0f, 0.0f, 180.0f);
        float xPos = Random.Range(Offset - Screen.width / 2f, Screen.width / 2f - Offset);
        float yPos = Random.Range(Offset, Screen.height / 2f - Offset);

        go.transform.localPosition = new Vector3(xPos, yPos, 0f);
        go.transform.localScale    = new Vector3(3f, 3f, 1f);

        // configure videoSurface
        VideoSurface videoSurface = go.AddComponent <VideoSurface>();

        return(videoSurface);
    }
Exemple #6
0
    public VideoSurface makeImageSurface(string goName)
    {
        GameObject go = new GameObject();

        if (go == null)
        {
            return(null);
        }

        go.name = goName;
        go.AddComponent <RawImage>();

        GameObject canvas = GameObject.Find("pnlContainer");

        if (canvas != null)
        {
            go.transform.parent = canvas.transform;
        }

        // set up transform
        go.transform.Rotate(0f, 0.0f, 180.0f);
        go.transform.localPosition = spawnPoint.localPosition + (Vector3.up * usersInChannel * 300f);
        go.transform.localScale    = Vector3.one * 2.5f;

        // configure videoSurface
        VideoSurface videoSurface = go.AddComponent <VideoSurface>();

        return(videoSurface);
    }
 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!");
     }
 }
    private void onUserJoined(uint uid, int elapsed)
    {
        Debug.Log("onUserJoined: uid = " + uid);
        // 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 assigne to this new user
        go = GameObject.CreatePrimitive(PrimitiveType.Plane);
        if (!ReferenceEquals(go, null))
        {
            go.name = uid.ToString();

            // configure videoSurface
            VideoSurface o = go.AddComponent <VideoSurface> ();
            o.SetForUser(uid);
            o.mAdjustTransfrom += onTransformDelegate;
            o.SetEnable(true);
            o.transform.Rotate(-90.0f, 0.0f, 0.0f);
            float r = Random.Range(-5.0f, 5.0f);
            o.transform.position   = new Vector3(0f, r, 0f);
            o.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f);
        }

        mRemotePeer = uid;
    }
    private void OnUserJoined(uint uid, int elapsed)
    {
        Debug.Log("New user has joined channel with id: " + uid);
        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Plane);

        go.name = uid.ToString();
        VideoSurface o = go.AddComponent <VideoSurface>();

        o.SetForUser(uid);

        //o.mAdjustTransfrom += OnTransformDelegate;
        o.SetEnable(true);
        o.transform.Rotate(-90.0f, 0.0f, 0.0f);
        float r = Random.Range(-5.0f, 5.0f);

        o.transform.position   = new Vector3(0f, r, 0f);
        o.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f);

        mRemotePeer = uid;

        /*Debug.Log("new person join channel " + " " + uid);
         * GameObject go;
         * go = GameObject.CreatePrimitive(PrimitiveType.Plane);
         * go.name = uid.ToString();
         * VideoSurface o = go.AddComponent<VideoSurface>();
         * o.SetForUser(uid);
         * o.mAdjustTransfrom += OnTransformDelegate;
         * o.SetEnable(true);
         * o.transform.Rotate(-90.0f, 0.0f, 0.0f);
         * float r = Random.Range(-5.0f, 5.0f);
         * o.transform.position = new Vector3(0f, r, 0f);
         * o.transform.localScale = new Vector3(0.5f, 0.5f, 1.0f);
         * mRemotePeer = uid; */
    }
    void OnJoinChannelSuccessHandler(string channelName, uint uid, int elapsed)
    {
        Debug.Log("JoinChannelSuccessHandler: uid = " + uid);
        VideoSurface localVideoSurface = localVideoImage.AddComponent <VideoSurface>();

        // Get the name name of your machine's microphone to display in the bottom panel
        string audioDeviceName = "null";
        string audioDeviceID   = "null";

        AudioRecordingDeviceManager.GetInstance(AgoraJoin.mRtcEngine).CreateAAudioRecordingDeviceManager();
        AudioRecordingDeviceManager.GetInstance(AgoraJoin.mRtcEngine).GetCurrentRecordingDeviceInfo(ref audioDeviceName, ref audioDeviceID);
        audioDeviceText.text = audioDeviceName;

        // Get the name of your machine's webcam to display
        string videoDeviceName = "null";
        string videoDeviceID   = "null";

        VideoDeviceManager.GetInstance(AgoraJoin.mRtcEngine).CreateAVideoDeviceManager();
        VideoDeviceManager.GetInstance(AgoraJoin.mRtcEngine).GetVideoDevice(0, ref videoDeviceName, ref videoDeviceID);
        videoDeviceText.text = videoDeviceName;

        // Set user name to name on the top panel
        channelIDText.text = channelName;

        isLocalVideoEnabled = true;
    }
Exemple #11
0
    // 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);
        // 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
        }

        numUsers++;
        // create a GameObject and assigne to this new user
        go = GameObject.CreatePrimitive(PrimitiveType.Plane);
        if (!ReferenceEquals(go, null))
        {
            go.name = uid.ToString();

            // configure videoSurface
            VideoSurface o = go.AddComponent <VideoSurface>();
            o.SetForUser(uid);
            //o.mAdjustTransfrom += onTransformDelegate; ///
            o.SetEnable(true);
            o.transform.Rotate(-90.0f, 180.0f, 0.0f);
            //float r = Random.Range (-5.0f, 5.0f); ///
            var videoQuadPos = GameObject.Find("VideoSpawn").transform.position;
            o.transform.position   = videoQuadPos + new Vector3(0, 0, 0);     //y wie x
            o.transform.localScale = new Vector3(0.50f, (0.28125f), (0.50f)); //ohen die 5en  0.09475f  0.5f  0.094924f
        }

        // mRemotePeer = uid;
    }
    // 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);
        }
    }
    public virtual void OnSceneLoaded()
    {
        // find a game object to render video stream from 'uid'
        GameObject go = GameObject.Find(RemoteStreamTargetImage);

        if (go == null)
        {
            return;
        }

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

        videoSurface.enabled = false;


        go = GameObject.Find("ButtonExit");
        if (go != null)
        {
            Button button = go.GetComponent <Button>();
            if (button != null)
            {
                button.onClick.AddListener(OnLeaveButtonClicked);
            }
        }
        SetupToggleMic();
    }
Exemple #14
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++;
    }
    // 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 #16
0
    // accessing GameObject in Scnene1
    // set video transform delegate for statically created GameObject
    public void onSceneHelloVideoLoaded()
    {
        Debug.Log("onSceneHelloVideoLoaded_________________________________");
        GameObject   go = RecallController.GetInstanse.GetLocal;
        VideoSurface o  = go.AddComponent <VideoSurface> ();

        o.SetEnable(true);
    }
Exemple #17
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     _videoSurface = new VideoSurface();
     VideoView.Add(_videoSurface);
     CrossMediaManager.Current.VideoPlayer.RenderSurface = _videoSurface;
     CrossMediaManager.Current.PlayingChanged           += (sender, e) => ProgressView.Progress = (float)e.Progress;
 }
Exemple #18
0
    // accessing GameObject in Scnene1
    // set video transform delegate for statically created GameObject
    public void onSceneHelloVideoLoaded()
    {
        //Debug.Log("onSceneHelloVideoLoaded");
        GameObject   go = DisplayCamManager.GetInstance.GetLocal;
        VideoSurface o  = go.AddComponent <VideoSurface> ();

        o.SetEnable(true);
        switchCamera();
    }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            _videoSurface = new VideoSurface();
            VideoView.Add(_videoSurface);
            CrossMediaManager.Current.VideoPlayer.RenderSurface = _videoSurface;
            CrossMediaManager.Current.PlayingChanged           += (sender, e) => ProgressView.Progress = (float)e.Progress;

            // Perform any additional setup after loading the view, typically from a nib.
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
			_videoSurface = new VideoSurface();
			VideoView.Add(_videoSurface);
			CrossMediaManager.Current.VideoPlayer.RenderSurface = _videoSurface;
			CrossMediaManager.Current.PlayingChanged += (sender, e) => ProgressView.Progress = (float)e.Progress;

            // Perform any additional setup after loading the view, typically from a nib.
        }
Exemple #21
0
    private void onFirstLocalVideoFrame(uint uid, int width, int height, int elapsed)
    {
        GameObject   go = getGameObjectWithUserID(MyUserID);
        VideoSurface vs = go.GetComponent <VideoSurface>();

        vs.UserID = MyUserID;
        vs.IsMe   = true;
        //getLocalTextureSize (true, ref vs.TextureWidth, ref vs.TextureHeight);
        vs.TextureWidth  = width;
        vs.TextureHeight = height;
    }
    private void OnUserJoined(uint uid, int elapsed)
    {
        // Debug.Log("New User has joined the channel");
        videoSurface.SetActive(true);
        videoSurface.name = uid.ToString();
        VideoSurface o = videoSurface.GetComponent <VideoSurface>();

        o.SetForUser(uid);
        o.SetEnable(true);
        mRemotePeer = uid;
    }
Exemple #23
0
    // accessing GameObject in Scnene1
    // set video transform delegate for statically created GameObject
    public void onSceneHelloVideoLoaded()
    {
        GameObject go = GameObject.Find("VideoSpawn");

        if (ReferenceEquals(go, null))
        {
            Debug.Log("BBBB: failed to find VideoQuad");
            return;
        }
        VideoSurface o = go.GetComponent <VideoSurface>();
        //  o.mAdjustTransfrom += onTransformDelegate;
    }
    // accessing GameObject in Scnene1
    // set video transform delegate for statically created GameObject
    public void onScene1Loaded()
    {
        GameObject go = GameObject.Find("Cylinder");

        if (ReferenceEquals(go, null))
        {
            logD("BBBB: failed to find Cylinder");
            return;
        }
        VideoSurface o = go.GetComponent <VideoSurface> ();

        o.mAdjustTransfrom += onTransformDelegate;
    }
Exemple #25
0
    private void onUserOffline(uint uid, USER_OFFLINE_REASON reason)
    {
        Debug.Log("onUserOffline");
        GameObject go;

        go = GameObject.Find("other");
        VideoSurface o = go.GetComponent <VideoSurface>();

        if (!ReferenceEquals(o, null))
        {
            Destroy(o);
        }
    }
    public void OnChatSceneLoaded()
    {
        GameObject go = GameObject.Find("Sphere");

        if (ReferenceEquals(go, null))
        {
            Debug.Log("cant fiund sphere");
            return;
        }

        VideoSurface o = go.GetComponent <VideoSurface>();
        //o.mAdjustTransfrom += OnTransformDelegate;
    }
Exemple #27
0
    private void onJoinChannelSuccess(string channelName, uint uid, int elapsed)
    {
        Debug.Log("JoinChannelSuccessHandler: uid = " + uid);
        GameObject textVersionGameObject = GameObject.Find("VersionText");

        textVersionGameObject.GetComponent <Text> ().text = "Version : " + getSdkVersion();



        GameObject go1, go2, go3, go4;

        GameObject go = GameObject.Find(uid.ToString());

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


        go1 = GameObject.Find("Cylinder");
        go2 = GameObject.Find("Cylinder2");
        go3 = GameObject.Find("Cylinder3");
        go4 = GameObject.Find("Cylinder4");

        go2.GetComponent <Renderer>().enabled = false;
        go3.GetComponent <Renderer>().enabled = false;
        go4.GetComponent <Renderer>().enabled = false;


        GameObject go1_cp = new GameObject();

        go1_cp = Instantiate(go1);

        go1_cp.GetComponent <Renderer>().enabled = true;

        go1.name = "C_" + uid.ToString();

        go1_cp.name = uid.ToString();
        anf         = uid;
        go          = go1_cp;

        if (!ReferenceEquals(go, null))
        {
            go.name = uid.ToString();

            // configure videoSurface
            VideoSurface o = go.GetComponent <VideoSurface> ();
            o.SetForUser(uid);
            o.SetEnable(true);
        }
    }
    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 #29
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 #30
0
    private void onUserOffline(uint uid, USER_OFFLINE_REASON reason)
    {
        GameObject go = getGameObjectWithUserID(uid);

        if (!ReferenceEquals(go, null))
        {
            UsersDictionary [go] = 0;

            VideoSurface vs = go.GetComponent <VideoSurface> ();
            vs.UserID = 0;
            vs.RemoveTexture();
            vs.enabled = false;
        }
    }
Exemple #31
0
    // Create new image plane to display users in party.
    private void CreateUserVideoSurface(uint uid, bool isLocalUser)
    {
        // Avoid duplicating Local player VideoSurface image plane.
        for (int i = 0; i < playerVideoList.Count; i++)
        {
            if (playerVideoList[i].name == uid.ToString())
            {
                return;
            }
        }

        // Get the next position for newly created VideoSurface to place inside UI Container.
        float   spawnY        = playerVideoList.Count * spaceBetweenUserVideos;
        Vector3 spawnPosition = new Vector3(0, -spawnY, 0);

        // Create Gameobject that will serve as our VideoSurface.
        GameObject newUserVideo = Instantiate(userVideoPrefab, spawnPosition, spawnPoint.rotation);

        if (newUserVideo == null)
        {
            Debug.LogError("CreateUserVideoSurface() - newUserVideoIsNull");
            return;
        }
        newUserVideo.name = uid.ToString();
        newUserVideo.transform.SetParent(spawnPoint, false);
        newUserVideo.transform.rotation = Quaternion.Euler(Vector3.right * -180);

        playerVideoList.Add(newUserVideo);

        // Update our VideoSurface to reflect new users
        VideoSurface newVideoSurface = newUserVideo.GetComponent <VideoSurface>();

        if (newVideoSurface == null)
        {
            Debug.LogError("CreateUserVideoSurface() - VideoSurface component is null on newly joined user");
            return;
        }

        if (isLocalUser == false)
        {
            newVideoSurface.SetForUser(uid);
        }
        newVideoSurface.SetGameFps(30);

        // Update our "Content" container that holds all the newUserVideo image planes
        content.sizeDelta = new Vector2(0, playerVideoList.Count * spaceBetweenUserVideos + 140);

        UpdatePlayerVideoPostions();
        UpdateLeavePartyButtonState();
    }