xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.59k stars 474 forks source link

[Bug] MediaElement for UWP is broken in Xamarin Community Toolkit 1.1 #1171

Open coquilanka opened 3 years ago

coquilanka commented 3 years ago

Description

[Bug] MediaElement for UWP is broken in Xamarin Community Toolkit 1.1

Steps to Reproduce

  1. Try the below MainPage.xaml file that contains a MediaElement Tag (set the UWP project as startup, and start debugging). You will only get the "red background" set in "BackgroundColor" in XAML below, but not the player interface, and playback does not work

<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:xct="http://xamarin.com/schemas/2020/toolkit" x:Class="ClipM.MainPage"> <xct:MediaElement Source="https://sec.ch9.ms/ch9/5d93/a1eab4bf-3288-4faf-81c4-294402a85d93/XamarinShow_mid.mp4" ShowsPlaybackControls="True" BackgroundColor="Red"/>

(Xamarin Forms version 5.0.0.2012) (Xamarin Community Toolkit version 1.1.0)

Expected Behavior

Playback of Video to start

Actual Behavior

You will only get the "red background" shown in the image, but not the player interface, and playback does not work (note that the background color of MediaElement is set to red in the above XAML )

Basic Information

Workaround

Downgrade to 1.0.3

Reproduction imagery

image

jfversluis commented 3 years ago

I've tried it with the sample app and that seems to work fine.

Could you maybe add a little reproduction project to show the issue? That would really help tracking this down. Thanks!

coquilanka commented 3 years ago

I've tried it with the sample app and that seems to work fine.

Could you maybe add a little reproduction project to show the issue? That would really help tracking this down. Thanks!

Thanks a lot for your help Versluis. After patient investigation, I think I found the origin of the problem. It does not seem to be directly related to the MediaElement

The problem seems to be in the combination of the Xamarin Community Toolkit version being used and the "Targeting Min Version" setting in the properties of the UWP project in the Xamarin Solution ' If I use Xamarin Community Toolkit 1.0.3 with "Min Targeting Version" setting on Windows 10 Version 1809 Build 17763 or above, the UWP project with the Xamarin Community Toolkit MediaElement renders correctly on screen

If I use Xamarin Community Toolkit 1.1.0 with "Min Targeting Version" setting on Windows 10 Version 2004 Build 19041, the UWP project with the Xamarin Community Toolkit MediaElement renders correctly on screen.

Any other combination fails as per the image previously enclosed in this thread.

(my Windows 10 operating system is currently Build 19041)

May I please ask if this is a bug or on the contrary it is expected behavior? I took the opportunity to read about "Targeting Versions" and it sounds that even if my "Min Target Version" was set to 17763 (I think), the problem should not have occurred with XCT 1.1.0.

Your insight, if possible for you, would be very highly appreciated. Thanks!

JKennedy24 commented 3 years ago

I can also replicate this issue with V1.1.0 of community toolkit.

Downgrading to V1.0.3 fixed the issue

In terms of my target version and min versions are as follows:

Target Version: Windows 10 Version 2004 (10.0 build 19041) Min Version: Windows 10 Version 1809 (10.0 build 17763)

pictos commented 3 years ago

@JKennedy24 just for science, could you upgrade your min. version to build 19041 and see if that works?

coquilanka commented 3 years ago

@JKennedy24 just for science, could you upgrade your min. version to build 19041 and see if that works?

@pictos: as per my original message, yes XCT 1.1.0 works OK if you set the min version to build 19041. In my tests, as per my original report:

"If I use Xamarin Community Toolkit 1.0.3 with "Min Targeting Version" setting on Windows 10 Version 1809 Build 17763 or above, the UWP project with the Xamarin Community Toolkit MediaElement renders correctly on screen If I use Xamarin Community Toolkit 1.1.0 with "Min Targeting Version" setting on Windows 10 Version 2004 Build 19041, the UWP project with the Xamarin Community Toolkit MediaElement renders correctly on screen. Any other combination fails as per the image previously enclosed in this thread."

Thanks!

pictos commented 3 years ago

@coquilanka thanks, didn't see all comments, sorry for that hehe

jfversluis commented 3 years ago

@coquilanka and all, would you be able to test this NuGet maybe: https://dev.azure.com/xamarin/public/_build/results?buildId=39270&view=artifacts&pathAsName=false&type=publishedArtifacts

If you don't know how to test one from an artifact, this should help: https://blog.verslu.is/xamarin/xamarin-forms-xamarin/test-xamarin-forms-bugfixes/

Wondering if that fixes it for all scenarios

Sergtek commented 3 years ago

@coquilanka and all, would you be able to test this NuGet maybe: https://dev.azure.com/xamarin/public/_build/results?buildId=39270&view=artifacts&pathAsName=false&type=publishedArtifacts

If you don't know how to test one from an artifact, this should help: https://blog.verslu.is/xamarin/xamarin-forms-xamarin/test-xamarin-forms-bugfixes/

Wondering if that fixes it for all scenarios

I just tested the nuget and the MediaElement is still not working in UWP. With the following configuration: Target version: 1903 Min version: 1809

Sergtek commented 3 years ago

I just created a test project where the problem can be reproduced: https://github.com/nacompllo/MediaElementIssue

jfversluis commented 3 years ago

I just created a test project where the problem can be reproduced: https://github.com/nacompllo/MediaElementIssue

Was going to try this but the shared project seems to be missing from this repo @nacompllo :)

Sergtek commented 3 years ago

I just created a test project where the problem can be reproduced: https://github.com/nacompllo/MediaElementIssue

Was going to try this but the shared project seems to be missing from this repo @nacompllo :)

I just cloned it and the shared project looks good. I understand why you say that you only see the specific projects of the platforms?

jfversluis commented 3 years ago

I just created a test project where the problem can be reproduced: https://github.com/nacompllo/MediaElementIssue

Was going to try this but the shared project seems to be missing from this repo @nacompllo :)

I just cloned it and the shared project looks good. I understand why you say that you only see the specific projects of the platforms?

Oh wow that's weird. I didn't check the repo, it is indeed there, my bad. Must've been something weird on my side. I will try again 😅

RuddyOne commented 2 years ago

Same issue here. Any update on this?

chowarth commented 2 years ago

Also seeing the same problem with our UWP project:

solomonfried commented 2 years ago

Using Xamarin.Forms 5.0.0.2337 Xamarin Community Toolkit 2.0.0

The Media player using a URL (did not test with files) only works with Windows min version = Window 10 1903