XamarinCommunityToolkit
XamarinCommunityToolkit copied to clipboard
[Bug] Media Element Not Playing MP3s.
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
- Set IsVisible to false.
- 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
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).
I was using android.
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."
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.
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.
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.
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.
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.
Hi, any update on this? I am also facing the same issue.