Skip to content

Commit 4c87a9d

Browse files
ne0rrmatrixpictos
andauthored
Fix for MediaElement Android Resource file not found (#1537)
* Fix for MediaElement Android Resource file not found * Add test for Embeded Media source test for Android * revert test * Update src/CommunityToolkit.Maui.MediaElement/MediaSource/MediaSource.shared.cs Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com> * Fix HLS crash when changing to invalid HLS source in Windows. * Forgot to revert a change I made. * fix Duration bug * revert all changes to windows as they are not needed for this fix * add line space back into windows as it was missing * changed the prop to info and used .NET API --------- Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
1 parent 7160815 commit 4c87a9d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/CommunityToolkit.Maui.MediaElement/MediaSource/MediaSource.shared.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace CommunityToolkit.Maui.Views;
99
[TypeConverter(typeof(MediaSourceConverter))]
1010
public abstract class MediaSource : Element
1111
{
12+
static readonly bool isAndroid = OperatingSystem.IsAndroid();
1213
readonly WeakEventManager weakEventManager = new();
1314

1415
internal event EventHandler SourceChanged
@@ -37,7 +38,7 @@ internal event EventHandler SourceChanged
3738
/// </summary>
3839
/// <param name="path">Full path to the resource file, relative to the application's resources folder.</param>
3940
/// <returns>A <see cref="ResourceMediaSource"/> instance.</returns>
40-
public static MediaSource FromResource(string? path) => new ResourceMediaSource { Path = path };
41+
public static MediaSource FromResource(string? path) => new ResourceMediaSource { Path = isAndroid ? $"Assets/{path}" : path };
4142

4243
/// <summary>
4344
/// Creates a <see cref="UriMediaSource"/> from an string that contains an absolute URI.

0 commit comments

Comments
 (0)