Ejemplo n.º 1
0
 protected Item(ItemContainer parent, P2pProxyDevice device)
 {
     Title = "Unknown";
     Id = "0";
     ParentId = "0";
     IconUrl = null;
     this.parent = parent;
     _device = device;
 }
Ejemplo n.º 2
0
 public ItemStream(ItemContainer parent, MediaType type, P2pProxyDevice device, string file_ext = ".m2ts") : base(parent, device)
 {
     Type = type;
     _info = device.UpnpSettings.Profile.Live.Info.FirstOrDefault(info => info.FileExt.Equals(file_ext, StringComparison.OrdinalIgnoreCase)) ??
             device.UpnpSettings.Profile.Live.Info[0];
 }
Ejemplo n.º 3
0
        private Item GetItem(IPluginContent content, string host)
        {
            Item item;
            if (content is IPluginContainer)
            {
                item = new ItemContainer(null, _device) {Title = "[" + content.Title + "]"};
            }
            else if (content.Translation == TranslationType.VoD)
            {
                item = new ItemVideo(null, _device) {Title = content.Title};
                item.ContentUrl = host + "/" + _plugin.Id + "/play?id=" + content.Id;
            }
            else
            {
                item = new ItemStream(null, MediaType.Video, _device)
                {
                    Title = content.Title,
                    ContentUrl =
                        string.IsNullOrEmpty(content.GetUrl(host))
                            ? string.Format("{0}/{1}/play?id={2}", host, Id, content.Id)
                            : content.GetUrl(host)
                };
            }


            item.ParentId = ParentId + "_" + Id;
            item.Id = item.ParentId + "_" + content.Id;
            if (!string.IsNullOrEmpty(content.Parent.Id))
                item.ParentId = item.ParentId + "_" + content.Parent.Id;
            item.IconUrl = content.Icon;
            
            
            item.Type = MediaType.Video;
            return item;

        }
Ejemplo n.º 4
0
 public ItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     _childItems = new List<Item>();
 }
Ejemplo n.º 5
0
 public PluginContainer(ItemContainer parent, P2pProxyDevice device, IPluginProxy plugin) : base(parent, device)
 {
     _plugin = plugin;
     Id = _plugin.Id;
     Title = _plugin.Name;
     if (parent != null)
         ParentId = parent.GetIds();
     Type = MediaType.Video;
 }
Ejemplo n.º 6
0
 public RecordItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Id = "records";
     Title = "Локальные записи";
     Type = MediaType.Video;
 }
Ejemplo n.º 7
0
        public void UpdateChannels()
        {
            if (_lastUpdate + _maxAge < DateTime.Now)
            {
                _childItems.Clear();
                var channels = new TTVApi.ArcList().Run(_device.Proxy.SessionState.session);
                if (!channels.IsSuccess)
                {
                    while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect)
                    {

                    }
                    if (!_device.Proxy.SessionState.IsSuccess)
                        throw new Exception("No authorized");
                }
                foreach (var channel in channels.channels)
                {
                    ItemContainer container = new ItemContainer(this, _device)
                        {
                            Type = MediaType.Video,
                            IconUrl = channel.ObsaluteLogo,
                            Id = channel.epg_id + "|" + DateTime.Today.ToShortDateString(),
                            Title = channel.name,
                            ParentId = ParentId + "_" + Id,
                            Tag = DateTime.Today.AddTicks(2)
                        };
                    AddChild(container);
                }
            }
        }
Ejemplo n.º 8
0
 private ItemContainer GetContainterByDate(DateTime date, ItemContainer container)
 {  
     if (container.Count() == 0 || date == DateTime.Today)
         return container;
     ItemContainer ch = (ItemContainer)container.GetChild(0);
     TimeSpan ts = DateTime.Today - date;
     for (int i = 0; i < ts.Days - 1 && ch.Count() > 0; i++)
     {
         ch = (ItemContainer) ch.GetChild(0);
     }
     return ch;
 }
Ejemplo n.º 9
0
 public ArchiveItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Type = MediaType.Video;
     _childItems = new List<Item>();
     IconUrl = "";
     Id = "archives";
     Title = "Архив";
     ParentId = parent.GetIds();
     this.parent = parent;
     
 }
Ejemplo n.º 10
0
        public ItemRootContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
        {
            Title = "Root";
            Id = "0";
            ParentId = "0";
            _childItems.Add(new ChannelItemContainer(this, device));
            _childItems.Add(new ArchiveItemContainer(this, device));
            _childItems.Add(new RecordItemContainer(this, device));

            var plugs = _device.PluginProvider.GetPlugins();
            foreach (var plug in plugs)
            {
                try
                {
                    if (plug.GetContent(null) != null)
                        _childItems.Add(new PluginContainer(this, device, plug));
                }
                catch (Exception e)
                {
                    P2pProxyApp.Log.Write(e.Message, TypeMessage.Error);
                }
            }
        }
Ejemplo n.º 11
0
 public BlockItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Title = "Доступно только в полной версии";
     Id = "block";
     ParentId = "0";
     _childItems.Add(this);
 }
Ejemplo n.º 12
0
        private void UpdatePlaylist(string host)
        {
            if (_lastUpdate + _maxAge < DateTime.Now)
            {
                _childItems.Clear();
                var res = new TTVApi.TranslationList(TTVApi.FilterType.all).Run(_device.Proxy.SessionState.session);
                if (!res.IsSuccess)
                {
                    while (!_device.Proxy.Login() || _device.Proxy.SessionState.Error == TTVApi.ApiError.noconnect)
                    {

                    }
                    if (!_device.Proxy.SessionState.IsSuccess)
                        throw new Exception("No authorized");
                }
                foreach (var cat in res.categories)
                {
                    ItemContainer container = new ItemContainer(this, _device)
                                                  {
                                                      Type = MediaType.Video,
                                                      IconUrl = "RandomFromChild",
                                                      Id = cat.id.ToString(),
                                                      Title = cat.name,
                                                      ParentId = ParentId + "_" + Id
                                                  };
                    TTVApi.ChannelGroup cat1 = cat;
                    foreach (var source in res.channels.Where(channel => channel.group == cat1.id))
                    {
                        container.AddChild(new ItemStream(container, MediaType.Video, _device)
                                               {
                                                   IconUrl = source.ObsaluteLogo,
                                                   Id = source.id.ToString(),
                                                   Title = source.name,
                                                   ParentId = container.GetIds(),
                                                   ContentUrl = String.Format("{0}/channels/play?id={1}", host, source.id) + (!string.IsNullOrEmpty(_device.UpnpSettings.Profile.Live.Info[0].TranscodingProfile) ? "&transcode=" + _device.UpnpSettings.Profile.Live.Info[0].TranscodingProfile : "")
                                               });
                    }
                    AddChild(container);
                }
                _lastUpdate = DateTime.Now;
            }
        }
Ejemplo n.º 13
0
 public ChannelItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Type = MediaType.Video;
     _childItems = new List<Item>();
     IconUrl = "";
     Id = "channels";
     Title = "Каналы";
     ParentId = parent.GetIds();
     this.parent = parent;
 }
Ejemplo n.º 14
0
 public ItemStream(ItemContainer parent, MediaType type, P2pProxyDevice device, string file_ext = ".m2ts") : base(parent, device)
 {
     Type  = type;
     _info = device.UpnpSettings.Profile.Live.Info.FirstOrDefault(info => info.FileExt.Equals(file_ext, StringComparison.OrdinalIgnoreCase)) ??
             device.UpnpSettings.Profile.Live.Info[0];
 }
Ejemplo n.º 15
0
 public ItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     _childItems = new List <Item>();
 }
Ejemplo n.º 16
0
 public RecordItemContainer(ItemContainer parent, P2pProxyDevice device) : base(parent, device)
 {
     Id    = "records";
     Title = "Локальные записи";
     Type  = MediaType.Video;
 }