/// <summary>The timer tick event handler</summary> /// <param name="sender">The object that created this event</param> /// <param name="e">The event data object</param> private static void CoreTimerOnElapsed(object sender, ElapsedEventArgs e) { if (CurrentChannelProgrammes == null) { return; } var newProgramme = CurrentChannelProgrammes.Find(x => x.Start <DateTime.UtcNow && x.Stop> DateTime.UtcNow); if (Equals(CurrentProgramme, newProgramme)) { return; } LogDebug("[TVCore] CoreTimerOnElapsed(): New programme detected!"); CurrentProgramme = newProgramme; ProgrammeChanged?.Invoke(newProgramme); }
/// <summary>Set the channel, using the zero indexed number</summary> /// <param name="channelIndex">A zero based number to switch to</param> public static void SetChannel(uint channelIndex) { var totalChannels = ChannelIndexList.Count; if (channelIndex > totalChannels) { channelIndex = (uint)totalChannels; } if (CurrentChannel != null && CurrentChannelIndex == channelIndex) { return; } LogDebug($"[TVCore] Setting channelIndex to {channelIndex}"); CurrentChannel = Channels.Find(x => x.Index == ChannelIndexList[(int)channelIndex]); CurrentChannelIndex = channelIndex; CurrentChannelProgrammes = Guide.Where(x => x.Channel == CurrentChannel.Id).ToList(); CurrentProgramme = CurrentChannelProgrammes.Find(x => x.Start <DateTime.UtcNow && x.Stop> DateTime.UtcNow); ChannelChanged?.Invoke(channelIndex); }