Skip to content
New issue

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

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

Already on GitHub? # to your account

Reading mediaPlayerCreate.MediaPlayer.PlaybackSession.Position gives error when playback is paused #2408

Open
Diolk opened this issue Oct 10, 2023 · 0 comments
Assignees
Labels
Pri2 Topic is in the second 25% of page views for the repo. uwp/prod Topic product is UWP-related. winrt-reference/tech Topic technology is WinRT-related.

Comments

@Diolk
Copy link

Diolk commented Oct 10, 2023

Go a very strang bug with the MediaPlayer control. Application in C#/UWP.
Had code that worked perfectly for 2 years in production. Ran on Win10.
Upgraded tot Win11. Got an error in the code as described below:

I have a KeyUp event handler that check for hitting the spacebar. The spacebar acts as a toggle. Hitting it will toggle between play and pause of the MediaPlayer control. Control is display with manual controls (play/forward etc.) on it.
File is loaded in the control. Manual controls work fine.
Hitting space bar gives an error that the control displays on screen: cannot decode stream.
That in itself cannot be correct, because with manual control I can play the mp3 file.

I simplified the code to reproduce the bug. In the event handler I have this snipped.
if (mediaPlayerCreate.MediaPlayer.PlaybackSession.PlaybackState != MediaPlaybackState.Playing)
{
TimeSpan currentMediaPlayerPosition = mediaPlayerCreate.MediaPlayer.PlaybackSession.Position;
mediaPlayerCreate.MediaPlayer.Play();
}

this code will give the error.
Removing the line:
TimeSpan currentMediaPlayerPosition = mediaPlayerCreate.MediaPlayer.PlaybackSession.Position;
yields working code. (the Position is read a few ms later in the code, apparently it isn't a problem any more then)

In my opinion when the mediaplayer is paused it should be possible to read the position of the player, clearly doesn't work.

Target version: Windows 11 (10.0; Build 22000)
Min version: Windows 10, version 1809 (10.0; Build 17763)


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@issues-automation issues-automation bot added Pri2 Topic is in the second 25% of page views for the repo. uwp/prod Topic product is UWP-related. winrt-reference/tech Topic technology is WinRT-related. labels Oct 10, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Pri2 Topic is in the second 25% of page views for the repo. uwp/prod Topic product is UWP-related. winrt-reference/tech Topic technology is WinRT-related.
Projects
None yet
Development

No branches or pull requests

2 participants