bakes82 167 Posted November 17, 2020 Author Posted November 17, 2020 9 minutes ago, chef said: You could use config. What about a dictionary<Stopwatch, string>? Where string is the session.Id Set the entry when the session is paused, and that instance of stopwatch will remove its entry and kill the session when it hits it's max value. An unpause event will remove the entry based on the session.Id value. I wonder if that is possible... Having a key in a dictionary be an object which can remove itself?? Where are you hooking in to these events lol? Remember Im no pro to this API, it makes me want to stab my eyes out almost daily, why I do stuff 1 day, wait a week, try again another day wait a week Why couldnt I just query these events from the api? I work in marketing we collect TONS of data so like having button clicks and stuff logged is very normal for me. Shouldnt I also know when the session started, I just feel like there are basic data points I would expect but arent there. You would think in the PlayState it would have a paused duration when paused, or muted, or a list of events, something is triggering that boolean to be set. In the sched task I didnt want to have to store things back to the config to "remember" between each run. 1
chef 3810 Posted November 17, 2020 Posted November 17, 2020 17 minutes ago, bakes82 said: The issue isnt that, the issue is if you call with a TimeoutMs set on the MessageCommand you dont see the message at all. That would explain a whole lot actually. I couldn't figure out why sometimes I'd see a message on my fire TV stick, and others times I wouldn't. This is absolutely making sense.
bakes82 167 Posted November 17, 2020 Author Posted November 17, 2020 1 minute ago, chef said: That would explain a whole lot actually. I couldn't figure out why sometimes I'd see a message on my fire TV stick, and others times I wouldn't. This is absolutely making sense. Yeah I saw your code, ran it and was like this is crap it doesnt work 1
chef 3810 Posted November 17, 2020 Posted November 17, 2020 (edited) 17 minutes ago, bakes82 said: Where are you hooking in to these events lol? Remember Im no pro to this API, it makes me want to stab my eyes out almost daily, why I do stuff 1 day, wait a week, try again another day wait a week Why couldnt I just query these events from the api? I work in marketing we collect TONS of data so like having button clicks and stuff logged is very normal for me. Shouldnt I also know when the session started, I just feel like there are basic data points I would expect but arent there. You would think in the PlayState it would have a paused duration when paused, or muted, or a list of events, something is triggering that boolean to be set. In the sched task I didnt want to have to store things back to the config to "remember" between each run. I don't think you'd have to store anything in the config. You could still have a static list of paused sessions that are paused, and that just would only live for the lifetime of the server. For instance, in my Phillips hue plugin, in-order to keep track of paused sessions, I add the session ID (when paused) to a list of string, then check that list each time the PlaybackProgressEvent fires. If the session has "IsPaused" boolean flagged, and it isn't in the list, add it. If there is a session.Id in the list which doesn't have a "IsPaused" boolean in the session, it has been unpaused. At this point remove it from the list, and fire an unpaused event. Perhaps you can use something similar. Edited November 17, 2020 by chef
chef 3810 Posted November 17, 2020 Posted November 17, 2020 (edited) Here is a PlaybackProgressEventArgs from the Phillips Hue plugin: private List<string> PausedSessionsIds = new List<string>(); private void PlaybackProgress(object sender, PlaybackProgressEventArgs e) { var config = Plugin.Instance.Configuration; //No paused Session and no flagged sessions paused, move on if (!SessionManager.Sessions.Any(s => s.PlayState.IsPaused) && !PausedSessionsIds.Any()) return; switch (e.Session.PlayState.IsPaused) { case true: // We've already flagged this session, move on if (PausedSessionsIds.Exists(s => s.Equals(e.Session.Id))) return; PausedSessionsIds.Add(e.Session.Id); //run the Paused subroutine PlaybackPaused(); //<--Do something with this paused session data in that subroutine. break; case false: if (PausedSessionsIds.Exists(s => s.Equals(e.Session.Id))) { PlaybackUnPaused(); //<--Do something with this unpaused session data in that subroutine. } break; } } Edited November 17, 2020 by chef
bakes82 167 Posted November 17, 2020 Author Posted November 17, 2020 1 minute ago, chef said: I don't think you'd have to store anything in the config. You could still have a static list of paused sessions that are paused, and that just would only live for the lifetime of the server. For instance, in my Phillips hue plugin, in-order to keep track of paused sessions, I add the session ID (when paused) to a list of string, then check that list each time the PlaybackProgressEvent fires. If SessionManager.Sessions has a session with "IsPaused" boolean flagged, and it isn't in the list, add it. If there is a session.Id in the list which doesn't have a "IsPaused" boolean in the session, it has been unpaused. At this point remove it from the list, and fire an unpaused event. Perhaps you can use something similar. Ohhh yeah I guess. I tend to deal with stateless stuff. So I always forget somethings have a state of more than this one execution lol. I just need to add a serverEntryPoint then it looks like and have the progress and stop methods based on where the list you have referenced is at. I should be able to copy paste this tomorrow 1
chef 3810 Posted November 17, 2020 Posted November 17, 2020 Just now, bakes82 said: Ohhh yeah I guess. I tend to deal with stateless stuff. So I always forget somethings have a state of more than this one execution lol. I just need to add a serverEntryPoint then it looks like and have the progress and stop methods based on where the list you have referenced is at. I should be able to copy paste this tomorrow LOL! ROTFL!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now