Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Xamarin.media windows phone 8.1 crash

Hi, i'm trying to use the Xamarin.Media plugin to access the camera on windows phone 8.1, i'm using the default code to do so (see screen shot attached), but when i click on the button to open the camera, the code crashes on this line:

" var file = await CrossMedia.Current.TakePhotoAsync(test);"

I have attached a stack trace from an exception which says that it crashes because "XAML parsing failed",

this code works on my android project, but i cant get my head around why it wont work for windows phone 8.1.

Can anyone help?

thanks in advance

Posts

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @christophergraham.1607 - just to eliminate a possible few issues

    1. Have you installed the package on both your PCL and native project.
    2. Do you have the camera permission set on your Windows Phone project.
  • Hi @adam, yeah i have the package installed cross all my projects, and i did have webcam selected with pictures library and videos library but it still didnt work, which is why i went overkill and made sure everything was ticked as can be seen in the pictures attached.

  • TranVoNBTranVoNB USMember ✭✭

    @christophergraham.1607
    The specific code for Window Phone has 2 xaml files CameraCaptureUI.xaml and CameraCaptureUiPage.xaml but it has not been include in libs from Nuget.
    There are 2 workaround :
    1. Get project from Github, reference projects to your solution.
    2. Build your own PluginMedia.dll and it's relative files (*.xbf, *.xml), set your window phone project reference to instead of original file from Nuget.

    You could see my attached file for example.

    Hope it help.

  • ThowkThowk USUniversity
    edited May 2016

    Thanks for providing the solution ;) However there is a bug when using portrait mode - camera view is rotated 90`. (tested on Lumia 920) Probably this is something I will manage to make work soon

    I've build release version of Media library Media.Plugin.WindowsPhone81 from master. I also check option "Generate Library Output" in VisualStudio, but still I must ship xaml files with dll...
    How did you prepare your library package, to make it work without xaml pages files provided?

  • ericleigh007ericleigh007 USMember

    So, hate to ask, but why has no one seemed to have updated the NUget package? Thx

  • ThowkThowk USUniversity

    Also wonder about that. What I see is like a lot of libraries are focused on iOS and Android only, it's not a big suprise when even Xamarin ignores WP in many topics.

    I'll try to post that bug info on github if it's not there yet.

  • JamesMontemagnoJamesMontemagno USForum Administrator, Xamarin Team, Developer Group Leader Xamurai

    I fixed the nuget now: Fixed officially in 2.5.1-beta33! Tested and shipped!

  • MarcojakMarcojak GBMember

    With the version 2.5.1-beta33 I can use the camera on WP anyway there is another bug:
    in portrait mode - camera view is rotated 90.

    How can I fix it?

  • MarcojakMarcojak GBMember

    @Marcojak said:
    With the version 2.5.1-beta33 I can use the camera on WP anyway there is another bug:
    in portrait mode - camera view is rotated 90.

    How can I fix it?

    I've added a pull request for the Media plugin to fix the rotation problem on Windows Phone 8.1.
    if @JamesMontemagno approves the pull request, I suppose you can find the fix in the next release.

  • ImlavanImlavan USMember

    Hello @christophergraham.1607 have you fixed the issue. If so pls give your suggestions.

Sign In or Register to comment.