XamarinCommunityToolkit icon indicating copy to clipboard operation
XamarinCommunityToolkit copied to clipboard

[Bug] MediaElement - strange behavior when changing orientation

Open Mikilll94 opened this issue 4 years ago • 7 comments

Description

When changing orientation to landscape the MediaElement is behaving strangely. It is not filling the entire space on the screen.

Here it is shown this strange behavior on the GIF:

media_element_orientation

Steps to Reproduce

  1. Run this project MediaElementTest.zip

  2. Switch your phone/emulator to landscape orientation

  3. As you can see, the video is not filling the entire available space.

Expected Behavior

The video player in landscape orientation should fill the entire space.

Actual Behavior

The video takes about a quarter of the whole screen in landscape mode.

Basic Information

  • Version with issue: 4.5.0.356
  • IDE: 16.4.5
  • Platform Target Frameworks:
    • Android: 10.0

Mikilll94 avatar Mar 02 '20 22:03 Mikilll94

Hi guys, is there any movement on this? Or a better work around than the below? Further information:

  1. only android (50% of our clients devices here in Australia are Android - it's a big problem).

  2. if you start an app in landscape it will size to that and keep that size when rotate to portrait. Not just portrait to landscape as in the video.

  3. not fixed with HorizontalOptions="FillAndExpand" and VerticalOptions="FillAndExpand"

  4. not fixed by executing a ThisPage.ForceLayout().

  5. it DOES work if you reset the source and re-play (obviously as this is a complete rerack of effectively a new video). But this causes the video to start from the beginning so to fix this on an orientation change we have to capture the current play position and when restart playing play from that position.

  6. Full screen mode like the iOS experience is does not work either. This is very difficult to work around ... we have tabs, a navigation bar and differing display formats between tablet and phone, all of which are sorted with full screen mode on iOS but on Android it is simply not triggered. We are working on a work around ... an ETA on the your fix would be appreciated.

Thanks

rodhemphill avatar May 15 '20 00:05 rodhemphill

@samhouts Hi Sam, it looks like we are hitting every bug on MediaElements (see also https://github.com/xamarin/Xamarin.Forms/issues/9525). The app we are building needs to get out to the guys rebuilding our electricity network killed by our bushfires here. I know it's not your problem but I can see these issues have been outstanding for three months now - is anyone working on these? If not, do you have any recommendation of packages we should implement as an alternative?

Much appreciated.

rodhemphill avatar May 18 '20 07:05 rodhemphill

@rodhemphill have you tried MediaManager package it does have a decent VideoPlayer.

sarthak1995-26 avatar Dec 02 '20 16:12 sarthak1995-26

There is also issue with MediaElament size changing due to device orientation changes. When MediaElament orientation changed to landscape, the 'landscape' taken videos (180°, or 0°) size remains the same. Means not to expand/or stretch as the user expects.

mcblacksea avatar Jun 14 '22 21:06 mcblacksea

@Mikilll94 use Octane.Xam.VideoPlayer Nuget: "https://www.nuget.org/packages/Octane.Xam.VideoPlayer" Octane.Xamarin.Forms.VideoPlayer.VideoPlayer player = new Octane.Xamarin.Forms.VideoPlayer.VideoPlayer() { Source = url, DisplayControls = true, AutoPlay = true, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, FillMode = Octane.Xamarin.Forms.VideoPlayer.Constants.FillMode.ResizeAspect }; Use same fill mode it will work perfectly in all orientations.

thimanshu1993 avatar Dec 06 '22 10:12 thimanshu1993

I'm experiencing similar issues. I have implemented a pseudo-fullscreen mode for landscape in a commercial app that I'm working on and it works well with the Octane player, the MediaElement, however, doesn't adjust its size automatically when going into landscape mode. I need to tap the video controls to trigger a layout cycle that actually updates the View's size and position.

ewerspej avatar Mar 30 '23 15:03 ewerspej

I've created a repository showcasing some of the MediaElement bugs, including this one: https://github.com/ewerspej/MediaCustomTransport

ewerspej avatar Mar 31 '23 17:03 ewerspej