XamarinCommunityToolkit icon indicating copy to clipboard operation
XamarinCommunityToolkit copied to clipboard

[Bug] Media Element Not Playing MP3s.

Open musictopia2 opened this issue 5 years ago • 9 comments

Description

If I have the IsVisible to false in the media element, then it will not play any songs. Also, even if IsVisible is true, if i don't specify the area to be filled and expanded, then it won't play songs. There are many cases where a person may want to play a song but not see anything else so other controls can be there and they can still play the song. In the WPF MediaElement, if Visibility is hidden, a person can still play a song. Same thing should happen even with xamarin forms.

Steps to Reproduce

  1. Set IsVisible to false.
  2. Set source to song.

Expected Behavior

Still hear the song because you put the path in there and wanted to play the song.

Actual Behavior

Nothing happens. No errors. But nothing plays either.

Basic Information

  • Version with issue:

  • Last known good version:

  • IDE:

  • Platform Target Frameworks: Any android version.

  • Nuget Packages:

  • Affected Devices:

Screenshots

Reproduction Link

Workaround

musictopia2 avatar Apr 23 '20 17:04 musictopia2

I have created a reproduction sample: Issue10428.zip

@musictopia2 In which platform do you have the problem?. If you try the sample you can hear the audio with a hidden MediaElement (tested on iOS).

jsuarezruiz avatar Apr 24 '20 08:04 jsuarezruiz

I was using android.

musictopia2 avatar Apr 28 '20 00:04 musictopia2

I tried the sample and it would not even let me put on the device. I created a blank app and it had no problem. The error was "The project Issue10428.Android needs to be deployed before it can be started. Verify the project is selected to be deployed in the Solution Configuration Manager."

musictopia2 avatar Apr 28 '20 00:04 musictopia2

The good news is I was able to copy the xaml <StackLayout> <MediaElement BackgroundColor="Black" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Source="https://sec.ch9.ms/ch9/94a2/1e1e55c2-8c33-4f2f-8cc0-413e8ae794a2/MemoryManagement.mp3" AutoPlay="True" ShowsPlaybackControls="True" IsVisible="False"/> </StackLayout> to another project and it was able to load. The bad news is even with that xaml, if IsVisible was false, no sounds played. However, if I specified IsVisible as true, then it worked fine. This means that still does not work. If you want me to post to my git, i can. However, to test, just create a new project with that xaml to show it happening.

musictopia2 avatar Apr 28 '20 00:04 musictopia2

I tried the sample and it would not even let me put on the device. I created a blank app and it had no problem. The error was "The project Issue10428.Android needs to be deployed before it can be started. Verify the project is selected to be deployed in the Solution Configuration Manager."

Just open up the solution configuration and check the "Deploy" checkbox next to the Android project.

hartez avatar Apr 28 '20 19:04 hartez

With the repro project from @jsuarezruiz - the sound will play on iOS if the MediaElement has IsVisible="False", but on Android nothing plays. So we need to make all the platforms behave in the same way.

hartez avatar Apr 28 '20 19:04 hartez

How do I get to solution configuration. I have visual studio 2019 community edition and don't even see solution configuration. The good news is since I was able to copy the xaml to another project, then i was able to deploy that to show the problem.

musictopia2 avatar Apr 29 '20 01:04 musictopia2

How do I get to solution configuration. I have visual studio 2019 community edition and don't even see solution configuration.

In the Solution Explorer, right-click the solution - Configuration Manager should be one of the context menu options.

hartez avatar May 01 '20 22:05 hartez

Hi, any update on this? I am also facing the same issue.

Awesomer9561 avatar Dec 28 '22 07:12 Awesomer9561