Apologies if this is a dumb question, but I'm rather new to C# and trying to cobble together a plugin.
My goal is to store Player_GetPosition() at an interval. When the user changes to another track, load the stored position of that track. In other words, "remember where I left off" on a per-file basis.
I've nearly got it all working, except when I change to a new track in my now-playing list, I'm getting an infinite loop because Player_SetPosition() appears to be triggering `NotificationType.TrackChanged`.
Is there a different event I need to be using? Thanks in advance.
(shortened code:)
public void LoadSavedPosition()
{
try
{
var text = File.ReadAllText(GetPositionFilename());
_mbApiInterface.Player_SetPosition(int.Parse(text));
}
catch (Exception)
{
// ignored
}
}
public void ReceiveNotification(string sourceFileUrl, NotificationType type)
{
switch (type)
{
case NotificationType.TrackChanged:
LoadSavedPosition();
break;
}
}