public new static LiveTvMediaItem Deserialize(XmlReader reader) { LiveTvMediaItem result = new LiveTvMediaItem(Guid.Empty); ((IXmlSerializable)result).ReadXml(reader); return(result); }
/// <summary> /// Checks if both <see cref="LiveTvMediaItem"/> are of same type, which includes mimeType and streaming url. This check is used to detected /// card changes on server and switching between radio and tv channels. /// </summary> /// <param name="oldItem"></param> /// <param name="newItem"></param> /// <returns></returns> protected bool IsSameLiveTvItem(LiveTvMediaItem oldItem, LiveTvMediaItem newItem) { string oldPath = oldItem.Aspects[ProviderResourceAspect.ASPECT_ID].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH).ToString(); string newPath = newItem.Aspects[ProviderResourceAspect.ASPECT_ID].GetAttributeValue(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH).ToString(); if (oldPath != newPath) return false; IChannel oldChannel = oldItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel; IChannel newChannel = newItem.AdditionalProperties[LiveTvMediaItem.CHANNEL] as IChannel; if (oldChannel != null && newChannel != null && oldChannel.MediaType != newChannel.MediaType) return false; string oldMimeType; string oldTitle; string newMimeType; string newTitle; return oldItem.GetPlayData(out oldMimeType, out oldTitle) && newItem.GetPlayData(out newMimeType, out newTitle) && oldMimeType == newMimeType; }
/// <summary> /// Checks if both <see cref="LiveTvMediaItem"/> are representing the same player slot. /// </summary> /// <param name="oldItem"></param> /// <param name="newItem"></param> /// <returns><c>true</c> if same</returns> protected bool IsSameSlot(LiveTvMediaItem oldItem, LiveTvMediaItem newItem) { return ((int)oldItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX] == (int)newItem.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX]); }
/// <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; }
public new static LiveTvMediaItem Deserialize(XmlReader reader) { LiveTvMediaItem result = new LiveTvMediaItem(Guid.Empty); ((IXmlSerializable) result).ReadXml(reader); return result; }
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); }