Closed Dark-night45 closed 9 months ago
Generally, I would recommend against developing .NET Core 3.1, and would recommend moving to .NET 6+. While I build for older versions, .NET Core 3.1 has been EOL since December 2022.
However, even with that, I'm not entirely sure why that's coming up null, I think I'd need more context. Specifically how currentSession
is being set.
Well this is a problem with @Dark-night45 's coding here. If you split await currentSession?.ControlSession.TryPauseAsync()
into
if (currentSession != null)
{
await null;
}
else
{
await currentSession.ControlSession.TryPauseAsync()
}
You can see you are awaiting on null
you should return the fuction as soon as currentSession is null
Okay, wait, I see this is code directly taken from Sample.UI
, and @Aytackydln is correct in the fact that I handled currentSession
being null incorrectly.
I have committed changes to properly handle this now.
The way the sample UI works is that it doesn't select the user's current/selected session by default. The user selects it, therefore it is initially null. It can also be null if the user-selected session is killed.
Edit: currentSession
is the user-selected session in the app, NOT the windows focused session (which is denoted by a #
in the UI)
The reason I'm using .NET Core 3.1 is that on my first attempt at the project, I ran into an error when using .NET 6.0 that resulted in WindowsMediaController not being supported. So, I switched to using .NET Core 3.1 instead.
I realized that the currentSession
variable was empty because I intended to display only one MediaSession. I didn't see the MediaManager_OnAnySessionOpened
and MediaManager_OnAnySessionClosed
functions.
Thank you for your assistance.
I closed the issue by mistake, I want to know why WindowsMediaController is not supported in .NET 6.0
@Dark-night45 May want to read up on this, the way WinRT is handled after NET 5 changed: https://github.com/DubyaDude/WindowsMediaController#net-5
@Dark-night45 I see you still have this open, do let me know if you have any issues setting it up, I'm more than happy to help more or even a quick 1 on 1 on Discord!
I appreciate your help, I will let you know if there are any problems or questions.
I just got acquainted with this package and I tried to make an app with the help of the example, but I had a problem skipping or stopping the media. I noticed that
currentSession
is null and I don't know why. I'm using .NET Core 3.1Code:
Error: