Open Mikilll94 opened 4 years ago
I've been testing your repro sample. To have the MediaElement working, some details are missing.
The first point is the experimental flag. MediaElement is in preview and you need the use the following flag:
Device.SetFlags(new string[] { "MediaElement_Experimental" });
Then, if you want to auto play the video, you can use the Autoplay
property. If you want to start playback by pressing the Play button, you need to handle the Click event and use the MediaElement Play method.
void Button_Clicked(object sender, System.EventArgs e)
{
MediaPlayer.Play();
}
Please, test when you can the attached sample (is your sample modified): Issue9785.zip
@jsuarezruiz
You are right that I forgot to add Device.SetFlags(new string[] { "MediaElement_Experimental" });
in Android project. After adding this I have noticed that the media player is still not displaying. Then I have changed this:
<MediaElement Source="https://sec.ch9.ms/ch9/5d93/a1eab4bf-3288-4faf-81c4-294402a85d93/XamarinShow_mid.mp4"
ShowsPlaybackControls="True" VerticalOptions="StartAndExpand"/>
to this
<MediaElement Source="https://sec.ch9.ms/ch9/5d93/a1eab4bf-3288-4faf-81c4-294402a85d93/XamarinShow_mid.mp4"
ShowsPlaybackControls="True" VerticalOptions="FillAndExpand"/>
So when you have VerticalOptions="StartAndExpand"
it is not working but if change to VerticalOptions="FillAndExpand"
it is working.
I had the same issue now have implemented: VerticalOptions="FillAndExpand"
I only see an issue with no playback when the video source is a local resource on android.
I only see an issue with no playback when the video source is a local resource on android.
I have the same issue, but for some reason It works after hot reloading the page
As a temporary workaround I manually play the video and resize it to refresh the view
Device.StartTimer(TimeSpan.FromSeconds(1), () =>
{
videoPlayer.Play();
videoPlayer.ScaleTo(0.99f);
videoPlayer.ScaleTo(1.00f);
return false;
});
We also can confirm this issue on Android 10 (API Level 29) with the video loaded from local resources.
This is still happening with the Toolkit version. There is a couple of workarounds already mentioned.
FillAndExpand
Still good to take a look what is going on and hopefully fix it :)
I was about to give up on using "mediaElement". Luckily I saw this thread so I was able to add the "FillAndExpand" attribute. Now it works fine. I didn't need to add storage access to the manifest, nor did I need to set the experimental flag.
Same Issue in 2022 as this not been fixed yet? Even with this am getting nothing display though am using https://github.com/Tyrrrz/YoutubeExplode to covert to stream might be causing a dealy possilby will youtube stream support come in eventually
<xct:MediaElement x:Name="mediaElement"
Grid.Row="0"
HeightRequest="500"
AutoPlay="True"
ShowsPlaybackControls="True"
VerticalOptions="FillAndExpand"
/>
I only see an issue with no playback when the video source is a local resource on android.
The same issue I am facing here, no issue with the URL video but facing issue with the video that is added in resource. Issue with android version also,We dont have any issue with android 9 but isssue with version 10
The same issue I am facing here, no issue with the URL video but facing issue with the video that is added in the resource. Issue with Android version also, We don't have any issue with android 9 but issue with version 10
I have same issue.
Asked question here https://docs.microsoft.com/en-us/answers/questions/939040/mediaelement-is-not-working-for-xamarin-android.html
Any ideas why it's not show up?
Had the same problem when media element was contained in a grid. This is what I found:
The grid had 2 rows. Media element is in the second row. Upper row had a label and a button.
Adding this up to the discussion above leads me to believe that it is highly probable that the media element does not request for space(WidthRequest?\HightRequest) from it's parent after assessing the size of the video.
Description
Steps to Reproduce
Run this project MediaElementTest.zip
As you can see MediaElement (video) is not showing up.
Expected Behavior
MediaElement (video) should be visible.
Actual Behavior
MediaElement (video) is not visible. I was testing on Android.
Basic Information