Trying with MediaElement in Xamarin.
It is not working in android 10 when taking video from 'raw' folder.
We are not facing this issue in Android 9.
We are not facing this issue if we are giving a URL as a source.
demo project is added in the following link--> https://github.com/devcrux/Xamarin.Forms-Shapes
Steps followed.
1.Added ' Device.SetFlags(new[] { "Shapes_Experimental", "MediaElement_Experimental" });' in App class.
2.Added mp4 file in row folder
3.Build action is given as 'Android Resource'
4.MediaElement is added like
<MediaElement
x:Name="mediaElementBar"
Source="https://qdserversas1.eastus.cloudapp.azure.com:571/video/hospital.mp4"
ShowsPlaybackControls="False"
IsLooping="True" Aspect="AspectFill" AutoPlay="True"
SeekCompleted="mediaElementBar_SeekCompleted"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>
.
Please help me to fix this issue.
Thanx in advance :)
Related
I have a Xamarin.Forms shared project. On Android all images work fine. I wanted to add them to my iOS project, but they don't show. I've added them to Assets.xcassets:
{
"filename": "logo_launcher.png",
"scale": "1x",
"idiom": "universal"
}
And I use the following XAML:
<Image Source="logo_launcher.png" x:Name="logo" />
I've added all images except for the vector ones. I'm testing it on a iPhone 8 - 11.4 simulator.
Although it is deprecated, I tried to add the images to the "Resource" folder. But I couldn't even select the .png files. So that didn't work either.
I'm lost at what to do. Is there some option I need to enable, or something to include in the XAML to make it work?
Just select all images in resources folder in ios and right click-->build action-->bundle resource. It will work.
Check/Reproduce some steps below:
Check the build action on your image resource, in shared PCL it should be Embedded Resource, in Android the build action should be AndroidResourceand BundleResource in iOS
Try to set Copy to output directory to Always copy
Delete bin/obj folders, switch build configuration from debug to release, rebuild project and then back to debug
Try to delete the image from iOS, rebuild, re-add again, and then repeat the steps above
Also, you can try to set the ImageSource as you can see below:
<Image x:Name="logo">
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource">
<On Platform="Android" Value="logo_launcher.png"/>
<On Platform="iOS" Value="logo_launcher"/>
</OnPlatform>
</Image.Source>
</Image>
I hope this can help you.
Maybe I found a possible solution using Assets.xcassets, check the steps below:
Main.xaml
<Image x:Name="iconBrain">
<Image.Source>
<OnPlatform x:TypeArguments="ImageSource">
<OnPlatform.iOS><FileImageSource File="IconBrain"/></OnPlatform.iOS>
<OnPlatform.Android><FileImageSource File="ic_brain"/></OnPlatform.Android>
</OnPlatform>
</Image.Source>
</Image>
Android: Add the images on the respective Drawable folders under Resourses directory.
iOS: Create a new Image Set under Assets.xcassets and add the Images.
Done. No extra properties, configs, or xamarin tricks.
Check out my GitHub for the full solution, also I tried to reproduce the same environment w/ Xamarin.Forms, Shared Project and iPhone 8 - 11.4 simulator.
Another point, you can't add the images under mipmap directories, because the mipmap folders are for placing your app/launcher icons (which are shown on the homescreen) in only. Any other drawable assets you use should be placed in the relevant drawable folders as before.
It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density. - Google blogpost
Finally, thank you for the information about the deprecated approach by Apple.
Prior to iOS 9, images were typically placed in the Resources folder with Build Action: BundleResource. However, this method of working with images in an iOS app has been deprecated by Apple. For more information, see Image Sizes and Filenames. - Images in Xamarin.Forms
I hope this can help you.
I'm learning Xamarin.Forms PCL. I want to load image on page, i tried to load image with uri, that's OK. But i add image into project, it's don't work.
<StackLayout Margin="0,20,0,0">
<Image x:Name="img" Source="mario.jpg"/>
<Button x:Name="btnRotate" Clicked="btnRotate_Clicked" Text="Rotate" />
</StackLayout>
Any help is appreciated. Thanks!
You can not include dashes or spaces in image names for Android compatibility
Rename your image from piotr-chrobot-276746.jpg to something else, like piotrchrobot.jpg
https://developer.xamarin.com/guides/android/application_fundamentals/resources_in_android/part_1_-_android_resource_basics/
Don't forget to set the Build action to AndroidResource.
Mvvmcross version 4.4.0
xamarin forms need Xamanarin.android.support.v4/v7.x version 23.0.0
Download Cachè plugin need Xamarin.android.support.compat version 24.2.1
My app is using xamarin forms so i cant remove it, but i also need to use MvxListView to show an image from url with local:MvxBind="ImageUrl myimage"
so i need download cache plugin, but i cant install it.
Is there any other IMvxImageHelper to use instead of MvvmCross-DownloadCache plugin ? or any other solution ?
*IMPORTANT NOTE-> No code in the Android View.
We use the Xamarin.Forms Plugin FFImageLoading - Fast & Furious Image Loading. It works like a charm and the image loading is much faster than without this plugin. So just take a look at it.
You can find detailed documentation on this github wiki.
Here's a short Xaml example how to use it:
<ffimageloading:CachedImage HorizontalOptions="Center" VerticalOptions="Center"
WidthRequest="300" HeightRequest="300"
DownsampleToViewSize="true"
Source = "http://loremflickr.com/600/600/nature?filename=simple.jpg">
</ffimageloading:CachedImage>
I am trying to add some Images as Image Sets in a Xamarin.Forms project. I followed this guide . But the icon is not displayed. Is it possible actually to use Image Sets in a Xamarin Forms Solution for the iOS project?
<Image VerticalOptions="Center"
HorizontalOptions="End"
Source="check_outline_500_active.png"
WidthRequest="40">
</Image>
Yes you can.
create the Asset catalog
add Image Set and name it "check_outline_500_active" (without .png)
add the images
done
my xaml
<Image VerticalOptions="Center"
HorizontalOptions="Center"
Source="check_outline_500_active.png">
</Image>
Result
Note
You might have to delete mtbs (on the mac) and bin/obj (on your project) or the build cache can fool you :)
Try to add images in resources folder under xamarin ios project and rename file like :
check_outline_500_active.png,
check_outline_500_active#2x.png,
check_outline_500_active#3x.png
but in code use : check_outline_500_active.png
I am new to Windows 8 development. i am following the tutorial provided by the Windows 8 team and i have run across some problem.
Can someone please tell me where i should insert the following code block explained in the tutorial. (In step 2)
Windows.Storage.ApplicationDataContainer roamingSettings =
Windows.Storage.ApplicationData.Current.RoamingSettings;
roamingSettings.Values["userName"] = nameInput.Text;
I was looking at MainPage.xaml.cs but it doesn't have any definition of a TextField. So where should i add this code block.
The definition is found in MainPage.xaml rather than MainPage.xaml.cs:
<TextBox x:Name="nameInput" Width="300" HorizontalAlignment="Left"
TextChanged="NameInput_TextChanged"/>
The MainPage.xaml.cs is a partial class of the xaml, so any controls declared in the xaml are available from the .cs file.
See the completed example here.