/// <summary> /// Creates a new <see cref="TimeshiftContext"/> and fills the <see cref="LiveTvMediaItem.TimeshiftContexes"/> with it. /// A new context is created for each channel change or for changed programs on same channel. /// </summary> /// <param name="timeshiftMediaItem">MediaItem</param> /// <param name="channel">Current channel.</param> private void AddOrUpdateTimeshiftContext(LiveTvMediaItem timeshiftMediaItem, IChannel channel) { TimeshiftContext tsContext = new TimeshiftContext { Channel = channel }; // Remove the newly tuned channel from history if present timeshiftMediaItem.TimeshiftContexes.Where(tc => tc.Channel.ChannelId == channel.ChannelId).ToList(). ForEach(context => timeshiftMediaItem.TimeshiftContexes.Remove(context)); // Then add the new context to the end timeshiftMediaItem.TimeshiftContexes.Add(tsContext); timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] = channel; }
private void AddTimeshiftContext(LiveTvMediaItem timeshiftMediaItem, IChannel channel) { IProgram program = GetCurrentProgram(channel); TimeshiftContext tsContext = new TimeshiftContext { Channel = channel, Program = program, TuneInTime = DateTime.Now }; int tc = timeshiftMediaItem.TimeshiftContexes.Count; if (tc > 0) { ITimeshiftContext lastContext = timeshiftMediaItem.TimeshiftContexes[tc - 1]; lastContext.TimeshiftDuration = DateTime.Now - lastContext.TuneInTime; } timeshiftMediaItem.TimeshiftContexes.Add(tsContext); }
/// <summary> /// Creates a new <see cref="TimeshiftContext"/> and fills the <see cref="LiveTvMediaItem.TimeshiftContexes"/> with it. /// A new context is created for each channel change or for changed programs on same channel. /// </summary> /// <param name="timeshiftMediaItem">MediaItem</param> /// <param name="channel">Current channel.</param> private bool AddOrUpdateTimeshiftContext(LiveTvMediaItem timeshiftMediaItem, IChannel channel) { TimeshiftContext tsContext = new TimeshiftContext { Channel = channel }; // Remove the newly tuned channel from history if present timeshiftMediaItem.TimeshiftContexes.Where(tc=>tc.Channel.ChannelId == channel.ChannelId).ToList(). ForEach(context => timeshiftMediaItem.TimeshiftContexes.Remove(context)); // Then add the new context to the end timeshiftMediaItem.TimeshiftContexes.Add(tsContext); timeshiftMediaItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] = channel; return true; }