Ejemplo n.º 1
0
        private async Task ConnenctDevice(DiscoverResult result)
        {
            await VideoPlayer.StopVideo();

            _connectionDisposables.Clear();
            ConnectedDevice.Dispose();
            ConnectedDevice = new DeviceModel();
            if (result == null)
            {
                return;
            }

            var oldViewMode = _viewMode.Value;
            var nextDevice  = new DeviceModel(result);

            nextDevice.ModeChanged.Subscribe(async(_) => await OnDeviceModeChanged()).AddTo(_connectionDisposables);
            nextDevice.PreviewModeChanged.Subscribe(async(_) => await OnDeviceModeChanged()).AddTo(_connectionDisposables);
            nextDevice.VideoSwitcherStatusChanged.Subscribe(OnVideoSwitcherStatusChanged).AddTo(_connectionDisposables);
            await nextDevice.Connect();

            if (nextDevice.IsConnected == false)
            {
                _connectionDisposables.Clear();
                nextDevice.Dispose();
                return;
            }

            switch (oldViewMode)
            {
            case ViewMode.Input:
                await nextDevice.PreviewInputTile();

                break;

            case ViewMode.Output:
                await nextDevice.PreviewProgramOut();

                break;

            default:
                break;
            }

            ConnectedDevice = nextDevice;
            VideoPlayer.SetEnable();
        }