Exemplo n.º 1
0
        protected async Task FetchDeviceListAsync()
        {
            var Devices = await BlazorMediaAPI.EnumerateMediaDevices();

            foreach (MediaDeviceInfo mdi in Devices)
            {
                if (mdi.Kind == MediaDeviceKind.AudioInput)
                {
                    Microphones.Add(mdi);
                }
                if (mdi.Kind == MediaDeviceKind.VideoInput)
                {
                    Cameras.Add(mdi);
                }
            }

            if (Microphones.Count > 0)
            {
                SelectedMicrophone = Microphones[0].DeviceId;
            }
            if (Cameras.Count > 0)
            {
                SelectedCamera = Cameras[0].DeviceId;
            }
        }
Exemplo n.º 2
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                // Should call this before listening to device changes.
                await BlazorMediaAPI.StartDeviceChangeListenerAsync();
                await FetchDeviceListAsync();

                BlazorMediaAPI.DeviceChanged += BlazorMedia_DeviceChanged;
                await InvokeAsync(StateHasChanged);
            }
            await base.OnAfterRenderAsync(firstRender);
        }
Exemplo n.º 3
0
 protected override async Task OnInitializedAsync()
 {
     BlazorMediaAPI = new BlazorMediaAPI(JSRuntime);
     await base.OnInitializedAsync();
 }