Hello,
I implemented the Demo Code for a short test and removed the Autostart Parameter.
When launching the page, i get the Access Request for the Cameras and can choose a Camera.
But now when i click the start button, the deviceId will not found.
CameraId is not set at any time to a value, it stays an empty string.
Using the StartAsync method without a Value, will result in a access request without device selection.

<CameraStreamer @ref="CameraStreamerReference"
Width="1920"
Height="1080"
OnRendered="OnRenderedHandler"
OnFrame="OnFrameHandler"
Style="width: 960px; height: 540px;"
CameraID="@CameraId"
/>
<div>
Camera: @CameraId
<button @onclick=Start>
Start
</button>
<button @onclick=Stop>
Stop
</button>
</div>
@code {
private CameraStreamer CameraStreamerReference;
private string CameraId = "";
private async void OnRenderedHandler()
{
// Check camera-access or ask user, if it's not allowed currently
if (await CameraStreamerReference.GetCameraAccessAsync())
{
Console.WriteLine($"CameraID {CameraStreamerReference.CameraID}");
// Reloading re-initializes the stream and starts the
// stream automatically if the Autostart parameter is set
await CameraStreamerReference.ReloadAsync();
// If Autostart is not set, you have to manually start the stream again
//await CameraStreamerReference.StartAsync(cameraId);
}
}
private void OnFrameHandler(string data)
{
// Remove the suffix added by javascript
//data = data[(data.IndexOf(',') + 1)..];
// Convert the base64 string to a System.Drawing.Bitmap
//var bmp = new(new MemoryStream(Convert.FromBase64String(data)));
// Do something with the bitmap
}
private async void Start()
{
await CameraStreamerReference.StartAsync(CameraId);
}
private async void Stop()
{
await CameraStreamerReference.StopAsync();
}
}
Uncaught (in promise)
MediaStreamError { name: "OverconstrainedError", message: "Constraints could be not satisfied.", constraint: "deviceId", stack: "" }
constraint: "deviceId"
message: "Constraints could be not satisfied."
name: "OverconstrainedError"
stack: ""
<prototype>: MediaStreamErrorPrototype { name: Getter, message: Getter, constraint: Getter, … }
constraint:
message:
name:
stack: ""
Symbol(Symbol.toStringTag): "MediaStreamError"
<get constraint()>: function constraint()
length: 0
name: "get constraint"
<prototype>: function ()
apply: function apply()
arguments:
bind: function bind()
call: function call()
caller:
constructor: function Function()
length: 0
name: ""
toString: function toString()
Symbol(Symbol.hasInstance): function Symbol.hasInstance()
Symbol(wasm type): 4
<get arguments()>: function arguments()
<set arguments()>: function arguments()
<get caller()>: function caller()
<set caller()>: function caller()
<prototype>: Object { Symbol("wasm type"): 0, … }
<get message()>: function message()
length: 0
name: "get message"
<prototype>: function ()
<get name()>: function name()
length: 0
name: "get name"
<prototype>: function ()
<prototype>: Error.prototype { stack: "", … }
Hello,
I implemented the Demo Code for a short test and removed the Autostart Parameter.
When launching the page, i get the Access Request for the Cameras and can choose a Camera.
But now when i click the start button, the deviceId will not found.
CameraId is not set at any time to a value, it stays an empty string.
Using the StartAsync method without a Value, will result in a access request without device selection.