Esempio n. 1
0
        public string OnAppStart()
        {
            string clientVersion = "Failed";

#if __ANDROID__
            ConnectorPKG.SetApplicationUIContext(Forms.Context as Activity);
#endif
            // Initialize VidyoClient library.
            // This should be called only once throughout the lifetime of the app.
            _vidyoClientInitialized = ConnectorPKG.Initialize();

            if (_vidyoClientInitialized)
            {
                try
                {
                    _connector = new Connector(_videoView.Handle,
                                               Connector.ConnectorViewStyle.ConnectorviewstyleDefault,
                                               15,
                                               "info@VidyoClient info@VidyoConnector warning",
                                               "",
                                               0);

                    // Get the version of VidyoClient
                    clientVersion = _connector.GetVersion();

                    // If enableDebug is configured then enable debugging
                    if (_enableDebug)
                    {
                        _connector.EnableDebug(7776, "warning info@VidyoClient info@VidyoConnector");
                    }

                    // Set experimental options if any exist
                    if (_experimentalOptions != null)
                    {
                        ConnectorPKG.SetExperimentalOptions(_experimentalOptions);
                    }

                    // Set initial position
                    RefreshUI();

                    _connector.RegisterLocalCameraEventListener(this);

                    // Register for log callbacks
                    if (!_connector.RegisterLogEventListener(this, "info@VidyoClient info@VidyoConnector warning"))
                    {
                        _logger.Log("VidyoConnector RegisterLogEventListener failed");
                    }
                }
                catch (Exception e)
                {
                    _logger.Log("VidyoConnector Construction failed");
                    _logger.Log(e.Message);
                }
            }
            else
            {
                _logger.Log("ERROR: VidyoClientInitialize failed - not constructing VidyoConnector ...");
            }
            return(clientVersion);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Set application context and initialize VidyoClient library
            ConnectorPKG.SetApplicationUIContext(this);
            ConnectorPKG.Initialize();

            videoFrame = FindViewById <FrameLayout>(Resource.Id.videoFrame);
            try
            {
                // Construct VidyoConnector
                vc = new Connector(videoFrame.Handle, Connector.ConnectorViewStyle.ConnectorviewstyleDefault, 15, "warning info@VidyoConnector info@VidyoClient", "", 0);

                // Register for local and remote camera event listeners
                if (!vc.RegisterLocalCameraEventListener(this))
                {
                    Console.WriteLine("RegisterLocalCameraEventListener failed");
                }
                if (!vc.RegisterRemoteCameraEventListener(this))
                {
                    Console.WriteLine("RegisterRemoteCameraEventListener failed");
                }

                // Get our buttons from the layout resource and attach an event to each button
                Button showPreviewButton = FindViewById <Button>(Resource.Id.showPreviewButton);
                Button connectButton     = FindViewById <Button>(Resource.Id.connectButton);
                Button disconnectButton  = FindViewById <Button>(Resource.Id.disconnectButton);
                Button cycleCameraButton = FindViewById <Button>(Resource.Id.cycleCameraButton);

                // Delegates when the buttons are clicked
                showPreviewButton.Click += delegate
                {
                    vc.ShowViewAt(videoFrame.Handle, 0, 0, (uint)videoFrame.Width, (uint)videoFrame.Height);
                };
                connectButton.Click += delegate
                {
                    string token = "";                     //INSERT VALID TOKEN
                    vc.Connect("prod.vidyo.io", token, "Xamarin.Android User", "demoroom", this);
                };
                disconnectButton.Click += delegate
                {
                    vc.Disconnect();
                };
                cycleCameraButton.Click += delegate
                {
                    vc.CycleCamera();
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }