Maui: [BUG] Exception thrown - SeekTo function (Media Element)
Is there an existing issue for this?
- I have searched the existing issues
Did you read the “Reporting a bug” section on Contributing file?
- I have read the “Reporting a bug” section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
The following exception is thrown whenever I go to use the seekTo function: Java.Lang.AbstractMethodError Message=abstract method “void androidx.media3.common.Player$Listener.onPositionDiscontinuity(androidx.media3.common.Player$PositionInfo, androidx.media3.common.Player$PositionInfo, int)” on receiver java.lang.Class<crc64ceb75e76f4b66147.MediaManager>
Expected Behavior
Should jump to the set time (in seconds) that the SeekTo function is parsed
Steps To Reproduce
- Run the code on an android device (with hot reload)
- Select a video, preferably in mp4 format
- Press the Go To 5s button
- The exception will be thrown
Link to public reproduction project repository
https://github.com/Mason-831/Error.git
Environment
- .NET MAUI CommunityToolkit: 12.1.0
- .NET MAUI ComminityToolkit.Maui.MediaElement: 6.1.1
- .NET MAUI: NET 9.0
Transistive Packages:
-Xamarin.AndroidX.Media3.Common: 1.5.0
-Xamarin.AndroidX.Media3.ExoPlayer: 1.5.0
Anything else?
If there is a simple work around to the bug, I am open to any suggestions.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 20 (12 by maintainers)
Well and truly. Thanks again
Is the issue resolved?
wow. thank you so much. I spent like 9 or 10 hours trying to figure it out or find a workaround. I can’t believe the fix was that simple.
I think I found the issue. After double checking the requirements to run media element I found that you failed to set the
SupportedOSPlatformVersionto the Min API level of 26. After updating your sample with this:<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">26.0</SupportedOSPlatformVersion>and adding<MauiVersion>9.0.81</MauiVersion>inside csproj file it now works as intended. I was able to replicate the bug and the above changes will prevent the crash on existing nuget from nuget.orgYou also need to await seekTo.
Can u provide video sample for me to test with?
@bijington I am going to shamelessly plug that link a lot I think!
This should explain how to do it
https://github.com/CommunityToolkit/Maui/wiki/Preview-Packages#pull-requests-
Oh sorry this was more a comment for the toolkit team when debugging to check some of the internals of the toolkit
Is there a way to check whether the underlying stream supports seeking? There is the
CanSeekproperty