question

rickruhl-4179 avatar image
0 Votes"
rickruhl-4179 asked WenyanZhang-MSFT commented

issue with permission for camera different with similar URLS

In Xamarin IOS with permissions set correctly, the first link brings up the camera, the second one asks for permissions and bringgs up a blank sqaure for the camera.

If needed we can provide PHP and javascript code from the backend.


       Navigation.PushAsync(new myreviewwebpage("https://collage.mydealerpreviews.com/testing/vwalk/index.php" , EmpData, "surveyIconSmall", false, "2", false, false, false, false, false, false, true));
    
    
 Navigation.PushAsync(new myreviewwebpage("https://collage.mydealerpreviews.com/testing/vwalk/dubbing.php", EmpData, "surveyIconSmall", false, "2", false, false, false, false, false, false, true))

;

dotnet-xamarin
· 18
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I test these two address, the second page always shows the alert to ask for permissions. Usually, permission only needs to be requested once, you could check if your second page gets the permission in PHP or javascript(this method getUserMedia()).

127780-image.png



0 Votes 0 ·
image.png (723.4 KiB)

Im trying to post the relevant javascript code but I get this error message every time I try.

You don't have permission to access "http://docs.microsoft.com/answers/answers/533228/post.html" on this server.
Reference #18.358d1bb8.1630413785.3eaf9e14

I can post this as you can see without error.

0 Votes 0 ·

127810-code.jpg




Code in image format.

0 Votes 0 ·
code.jpg (44.6 KiB)
Show more comments

I'm so sorry I can't reproduce this issue, I'm afraid there are somthing wrong with the package. You could check your project with the following steps or upload your basic, minimal, reproducible project to github and attach the link here, then I will download and test it.

  1. add Xamarin.CommunityToolkit package
    131538-image.png
    131527-image.png

  2. use MediaElement in XAML

      <?xml version="1.0" encoding="utf-8" ?>
     <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
        
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                  xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
                  x:Class="MediaDemo.MainPage">
         <StackLayout>
             <xct:MediaElement Source="https://sec.ch9.ms/ch9/5d93/a1eab4bf-3288-4faf-81c4-294402a85d93/XamarinShow_mid.mp4"
                               ShowsPlaybackControls="True"></xct:MediaElement>
        
         </StackLayout>
     </ContentPage>
    

  3. (optional) add NSAppTransportSecurity in info.plist of iOS(this allow http request)

      <string> NSAppTransportSecurity</string>
     <dict>
     <key>NSAllowsArbitraryLoads</key>
     <true/>
     </dict>
    

131592-image.png

0 Votes 0 ·
image.png (643.4 KiB)
image.png (48.6 KiB)
image.png (10.4 KiB)

The page will display the video.
131604-image.png


0 Votes 0 ·
image.png (594.5 KiB)

Ok got it to compile and show the video.... how i need the cameraview to show..

 ?xml version="1.0" encoding="utf-8" ?>
 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
              x:Class="dealerpreviews.cuttingroom">
     <ContentPage.Content>
         <ScrollView>
    
         ....

         <StackLayout Grid.Row="1" >
                     <Grid ColumnDefinitions="300,Auto" Grid.Row="1" >
                         <xct:CameraView
                 x:Name="cameraView"
                 CaptureMode="Video"
                 FlashMode="On"
                 HorizontalOptions="FillAndExpand"
                  MediaCaptured="CameraView_MediaCaptured"
                 OnAvailable="CameraView_OnAvailable"
                 VerticalOptions="FillAndExpand" />
                     </Grid>
             </StackLayout>
             </Grid>
         </ScrollView>
    
     </ContentPage.Content>
 </ContentPage>

The video show and plays but no camera comes up in the preview mode, and yes it has camera permissions in the info.plist

Rick



0 Votes 0 ·

You could have a try to use Xamarin Community Toolkit CameraView, the simulator of iOS will not pop up the camera, you chould connect your own iphone with mac and test this feature in your own device.


0 Votes 0 ·
Show more comments

0 Answers