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); }
public MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel) { if (!String.IsNullOrEmpty(streamUrl)) { ISystemResolver systemResolver = ServiceRegistration.Get<ISystemResolver>(); IDictionary<Guid, MediaItemAspect> aspects = new Dictionary<Guid, MediaItemAspect>(); MediaItemAspect providerResourceAspect; MediaItemAspect mediaAspect; SlimTvResourceAccessor resourceAccessor = new SlimTvResourceAccessor(slotIndex, streamUrl); aspects[ProviderResourceAspect.ASPECT_ID] = providerResourceAspect = new MediaItemAspect(ProviderResourceAspect.Metadata); aspects[MediaAspect.ASPECT_ID] = mediaAspect = new MediaItemAspect(MediaAspect.Metadata); // videoaspect needs to be included to associate player later! aspects[VideoAspect.ASPECT_ID] = new MediaItemAspect(VideoAspect.Metadata); providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, systemResolver.LocalSystemId); String raPath = resourceAccessor.CanonicalLocalResourcePath.Serialize(); providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, raPath); mediaAspect.SetAttribute(MediaAspect.ATTR_TITLE, "Live TV"); mediaAspect.SetAttribute(MediaAspect.ATTR_MIME_TYPE, "video/livetv"); //Custom mimetype for LiveTv LiveTvMediaItem tvStream = new LiveTvMediaItem(new Guid(), aspects); tvStream.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX] = slotIndex; tvStream.AdditionalProperties[LiveTvMediaItem.CHANNEL] = channel; tvStream.AdditionalProperties[LiveTvMediaItem.TUNING_TIME] = DateTime.Now; IProgram currentProgram; if (GetCurrentProgram(channel, out currentProgram)) tvStream.AdditionalProperties[LiveTvMediaItem.CURRENT_PROGRAM] = currentProgram; IProgram nextProgram; if (GetNextProgram(channel, out nextProgram)) tvStream.AdditionalProperties[LiveTvMediaItem.NEXT_PROGRAM] = nextProgram; return tvStream; } return null; }