xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] MediaElement doesn't like being inside a StackLayout (particularly on Android) #9573

Open davidbritch opened 4 years ago

davidbritch commented 4 years ago

Description

With the following code I'd expect to display a MediaElement above a Button:

<ContentPage>
    <StackLayout>
        <MediaElement Source="https://sec.ch9.ms/ch9/5d93/a1eab4bf-3288-4faf-81c4-294402a85d93/XamarinShow_mid.mp4"
                      ShowsPlaybackControls="True" />
        <Button Text="Button that does nothing" />
    </StackLayout>
</ContentPage> 

What I get is this:

See screenshots below.

On iOS, if you put the Button followed by the MediaElement it behaves as expected. But on Android you still don't get the MediaElement.

Steps to Reproduce

  1. Run the attached sample.
  2. Browse to the last page (test page).

Expected Behavior

MediaElement with a Button underneath it.

Actual Behavior

On iOS, a MediaElement that fills the screen. No sign of the Button. On Android, a Button and no sign of the MediaElement.

Basic Information

Screenshots

iOS:

Simulator Screen Shot - iPhone 11 - 2020-02-13 at 16 59 14

Android:

Screenshot_1581613170

Reproduction Link

WorkingWithMediaElement.zip

davidbritch commented 4 years ago

After more investigation this issue is about layouts in general, not just specifically the StackLayout. For example, the same result (MediaElement not shown) is achieved in a two row Grid, where the row containing the MediaElement is set to Auto size. However, the MediaElement does appear in a Grid row whose size is set to *.

So it appears that the MediaElement doesn't force layout to be re-evaluated once the size of the control is known, after the Source has been loaded.

ymebrugts commented 4 years ago

This seems to be present in the latest preview version as well. Any ETA on this?

ymebrugts commented 4 years ago

This should get the "MediaElement" label. It doesn't show up as a bug in that project.

Waaheeda commented 3 years ago

still facing same issue just on Android, any workaround for this?

=== Visual Studio Professional 2019 for Mac ===

Version 8.10.10 (build 8) Installation UUID: c780bbaa-1fa3-4fb2-80a4-6e2f27b089ef GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000140

=== Mono Framework MDK ===

Runtime: Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit) Package version: 612000140

=== Roslyn (Language Service) ===

3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb

=== NuGet ===

Version: 5.9.0.7134

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.401/Sdks SDK Versions: 5.0.401 5.0.201 3.1.413 3.1.407 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 5.0.10 5.0.4 3.1.19 3.1.13

=== .NET Core 3.1 SDK ===

SDK: 3.1.413

=== Xamarin.Profiler ===

Version: 1.6.15.68 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 13.1 (19466) Build 13A1030d

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 15.0.0.6 (Visual Studio Professional) Hash: 2771277e0 Branch: xcode13-ios Build date: 2021-09-23 10:36:08-0400

=== Xamarin Designer ===

Version: 16.10.0.119 Hash: 36a2d986f Branch: remotes/origin/d16-10 Build date: 2021-06-02 19:41:34 UTC

=== Xamarin.Android ===

Version: 11.3.0.4 (Visual Studio Professional) Commit: xamarin-android/d16-10/ae14caf Android SDK: /Users/vahidahavaldar/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 4.4 (API level 19) 8.0 (API level 26)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 30.0.4 SDK Build Tools Version: 30.0.2

Build Information: Mono: b4a3858 Java.Interop: xamarin/java.interop/d16-10@f39db25 ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.35.4@85460d3 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-10@c5732a0

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/vahidahavaldar/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.10.0.13 Hash: 1b81df5 Branch: remotes/origin/d16-10 Build date: 2021-09-21 02:30:50 UTC

=== Android Device Manager ===

Version: 16.10.0.15 Hash: 89dcc0b Branch: remotes/origin/d16-10 Build date: 2021-09-21 02:31:08 UTC

=== Build Information ===

Release ID: 810100008 Git revision: a3ff4b6e658e1f94623e1f3ed34ca94ed4fe78d8 Build date: 2021-09-23 19:50:51-04 Build branch: release-8.10

=== Operating System ===

Mac OS X 10.16.0 Darwin 20.6.0 Darwin Kernel Version 20.6.0 Mon Aug 30 06:12:21 PDT 2021 root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64