internal static WebChannelDetailed ChannelDetailed(IChannel channel)
        {
            IProgramInfoAsync programInfo = ServiceRegistration.Get <ITvProvider>() as IProgramInfoAsync;

            var             programs        = programInfo.GetNowNextProgramAsync(channel).Result;
            WebChannelBasic webChannelBasic = BaseChannelBasic.ChannelBasic(channel);

            WebChannelDetailed webChannelDetailed = new WebChannelDetailed
            {
                // From Basic
                Id      = webChannelBasic.Id,
                IsRadio = webChannelBasic.IsRadio,
                IsTv    = webChannelBasic.IsTv,
                Title   = webChannelBasic.Title,

                CurrentProgram   = ProgramDetailed(programs.Result[0]),
                NextProgram      = ProgramDetailed(programs.Result[1]),
                EpgHasGaps       = channel.EpgHasGaps,
                ExternalId       = channel.ExternalId,
                GrabEpg          = channel.GrapEpg,
                GroupNames       = channel.GroupNames,
                LastGrabTime     = channel.LastGrabTime ?? DateTime.Now,
                TimesWatched     = channel.TimesWatched,
                TotalTimeWatched = channel.TotalTimeWatched ?? DateTime.Now,
                VisibleInGuide   = channel.VisibleInGuide,
            };

            return(webChannelDetailed);
        }
예제 #2
0
        public async Task <AsyncResult <IChannel> > GetChannelAsync(int channelId)
        {
            IChannel channel;

            if (_channelCache.TryGetValue(channelId, out channel))
            {
                return(new AsyncResult <IChannel>(true, channel));
            }

            // TODO: lookup by ID cannot guess which server might be adressed, so we force the first one.
            int serverIndex = 0;

            if (!CheckConnection(serverIndex))
            {
                return(new AsyncResult <IChannel>(false, null));
            }
            try
            {
                WebChannelBasic webChannel = TvServer(serverIndex).GetChannelBasicById(channelId);
                channel = new Channel {
                    ChannelId = webChannel.Id, Name = webChannel.Title, ServerIndex = serverIndex
                };
                _channelCache[channelId] = channel;
                return(new AsyncResult <IChannel>(true, channel));
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error(ex.Message);
                return(new AsyncResult <IChannel>(false, null));
            }
        }
        public bool GetChannel(IProgram program, out IChannel channel)
        {
            channel = null;
            Program indexProgram = program as Program;

            if (indexProgram == null)
            {
                return(false);
            }

            if (!CheckConnection(indexProgram.ServerIndex))
            {
                return(false);
            }

            try
            {
                WebChannelBasic tvChannel = TvServer(indexProgram.ServerIndex).GetChannelBasicById(indexProgram.ChannelId);
                if (tvChannel != null)
                {
                    channel = new Channel {
                        ChannelId = tvChannel.Id, Name = tvChannel.Title, ServerIndex = indexProgram.ServerIndex
                    };
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error(ex.Message);
            }
            return(false);
        }
예제 #4
0
        public TVGuideChannelViewModel(WebChannelBasic channel, DateTime guideStart, DateTime guideEnd)
        {
            Id          = channel.Id;
            DisplayName = channel.DisplayName;

            programList = MPEServices.TAS.GetProgramsBasicForChannel(Id, guideStart, guideEnd);
            Programs    = programList.Select(x => new TVGuideProgramViewModel(x, guideStart, guideEnd));
        }
예제 #5
0
        public static Channel ToChannel(this WebChannelBasic ch)
        {
            if (ch == null)
            {
                return(null);
            }

            return(Channel.Retrieve(ch.Id));
        }
예제 #6
0
        private void cmdInitChannel_Click(object sender, EventArgs e)
        {
            mIdentifier = "Test_" + new Random().Next(0, 1000000).ToString();
            WebChannelBasic channel = mChannels[cbChannels.SelectedIndex];

            mName = channel.Title;
            Log("Init Stream with channel " + channel.Title);
            bool success = mWebStreamClient.InitStream(WebMediaType.TV, 0, channel.Id.ToString(), 0, CLIENT_NAME, mIdentifier, null);

            Log("Success = " + success);
            LoadMediaInfo(mWebStreamClient.GetMediaInfo(WebMediaType.TV, 0, mIdentifier, 0));
        }
예제 #7
0
        internal static WebChannelBasic ChannelBasic(IChannel channel)
        {
            WebChannelBasic webChannelBasic = new WebChannelBasic
            {
                Id      = channel.ChannelId,
                IsRadio = channel.MediaType == MediaType.Radio,
                IsTv    = channel.MediaType == MediaType.TV,
                Title   = channel.Name,
            };

            return(webChannelBasic);
        }