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?

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

  1. Run the code on an android device (with hot reload)
  2. Select a video, preferably in mp4 format
  3. Press the Go To 5s button
  4. 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)

Most upvoted comments

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 SupportedOSPlatformVersion to 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.org

You 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!

Sorry, I cannot find the CanSeek property. Where can I find it?

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 CanSeek property