Problem with cameraview after calling cameraView.Shutter();

rick ruhl 61 Reputation points
2022-01-18T01:04:13.863+00:00

Something weird here happening and it worked before.
cs code
void OnRecord(object sender, EventArgs e)
{
//mediaView.Stop();

            Send.Text = "Test Send";
            if (mediaView.CurrentState == MediaElementState.Stopped ||
           mediaView.CurrentState == MediaElementState.Paused || mediaView.CurrentState == MediaElementState.Closed)
            {
                mediaView.Play();
                cameraView.CaptureMode = (Xamarin.CommunityToolkit.UI.Views.CameraCaptureMode)CameraCaptureMode.Video;
                cameraView.Shutter();

                Record.Text = "Recording";
            }
            //      else if (mediaView.CurrentState == MediaElementState.Playing)
            //      {
            //         Record.Text = "Stop";
            //         cameraView.Shutter();
            //         mediaView.Stop();
            //      }

            //     _timer = new Timer(TimeSpan.FromSeconds(1), CountDown);
            //     TotalSeconds = _totalSeconds;
            //     StartTimerCommand();
        }

XAML code

 <Grid>
<xct:CameraView
                    Grid.Column="1"
                    x:Name="cameraView"
                    CaptureMode="Video"
                    FlashMode="Off"
                    HorizontalOptions="FillAndExpand"



                    VerticalOptions="FillAndExpand" />
                            <Label
                     Grid.Column="2"
                         Text=""
                         HorizontalTextAlignment="Center"
                         HorizontalOptions="FillAndExpand"
                         VerticalOptions="End" />
                        </Grid>
                    </Grid>


                    <Grid>
                        <Button x:Name="Send" Text="Send"  HeightRequest="70"  FontAttributes="Bold"  WidthRequest="400"  HorizontalOptions="Center"   CornerRadius="6"  BackgroundColor="#083F5D" BorderColor=" #083F5D" TextColor="White"></Button>
                    </Grid>

When we press the start button, and it calls cameraView.Shutter();, the cameraview goes black.

Before we press the button we can see video on the cameraview

any thoughts?

using VS 2022
Xamarin Community toolkit 1.3.2
Forms 5.0.0.2291

Rick

Developer technologies .NET Xamarin
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.