Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaPlayer.MediaStateChanged += HandleStateChange; should raise events when a song loops #2182

Open
vchelaru opened this issue Jan 11, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@vchelaru
Copy link

MediaStatePlayer.MediaStateChanged event should raise whenever a song loops. For example, the following code could be used:

MediaPlayer.MediaStateChanged += HandleStateChange;
...
private void HandleStateChange(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine($"State change at {DateTime.Now} to {MediaPlayer.State}");
}

When running on a MonoGame DesktopGL project, this happens when it loops:

State change at 1/11/2025 9:39:22 AM to Stopped
State change at 1/11/2025 9:39:22 AM to Playing

On Blazor GL projects the events are not raised.

This is important because this can be used to detect when a song loops.

What version of KNI does the bug occur on:

  • KNI 3.14

What operating system are you using:

  • Windows11

What KNI platform are you using:

  • BlazorGL
@nkast nkast added the bug Something isn't working label Jan 12, 2025
@nkast
Copy link

nkast commented Jan 12, 2025

When HTMLMediaElement is set to loop = true, I didn't get any events when the loop restarts.
We could fake the loop, and restart the song manually when the song is finished, but that will introduce a gap between the loops.
or we could perhaps use the timeupdate event and currentTime property to detect a restart.

There is also the SongFinishedPlaying event, which I have to check if it's working in looped songs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants