/// <summary> /// Changes the current channel (based on channel number) after a specified delay. /// </summary> /// <param name="channelNr">The nr of the channel to change to.</param> /// <param name="useZapDelay">If true, the configured zap delay is used. Otherwise it zaps immediately.</param> public void ZapToChannelNumber(int channelNr, bool useZapDelay) { IList <GroupMap> channels = CurrentGroup.ReferringGroupMap(); if (channelNr >= 0) { Log.Debug("channels.Count {0}", channels.Count); bool found = false; int iCounter = 0; Channel chan; while (iCounter < channels.Count && found == false) { chan = ((GroupMap)channels[iCounter]).ReferencedChannel(); Log.Debug("chan {0}", chan.DisplayName); if (chan.VisibleInGuide) { if (chan.ChannelNumber == channelNr) { Log.Debug("find channel: iCounter {0}, chan.ChannelNumber {1}, chan.DisplayName {2}, channels.Count {3}", iCounter, chan.ChannelNumber, chan.DisplayName, channels.Count); found = true; ZapToChannel(iCounter + 1, useZapDelay); } } iCounter++; } if (found) { m_zapChannelNr = channelNr; } } }
/// <summary> /// Changes the current channel after a specified delay. /// </summary> /// <param name="channelIdx">The (1 based) index within the group of the channel to change to.</param> /// <param name="useZapDelay">If true, the configured zap delay is used. Otherwise it zaps immediately.</param> public void ZapToChannelIndex(int channelIdx, bool useZapDelay) { IList <GroupMap> channels = CurrentGroup.ReferringGroupMap(); if (channelIdx < 1 || channelIdx > channels.Count) { Log.Debug("ZapToChannelIndex, channelIdx out-of-range:{0}", channelIdx); return; } //Check channelIdx against visible channels in guide GroupMap gm; Channel chan; int guideIdx = 0; for (int i = 0; i < channels.Count; i++) { gm = (GroupMap)channels[i]; chan = (Channel)gm.ReferencedChannel(); if (chan.VisibleInGuide) { guideIdx++; } if (guideIdx == channelIdx) { ZapToChannel(chan, useZapDelay); return; } } }
/// <summary> /// Changes to the previous channel in the current group. /// </summary> /// <param name="useZapDelay">If true, the configured zap delay is used. Otherwise it zaps immediately.</param> public void ZapToPreviousChannel(bool useZapDelay) { Channel currentChan = null; int currindex; if (m_zapchannel == null) { currentChan = Channel; currindex = GetChannelIndex(Channel); } else { currentChan = m_zapchannel; currindex = GetChannelIndex(m_zapchannel); // Zap from last zap channel } GroupMap gm; Channel chan; //check if channel is visible //if not find next visible do { // Step to prev channel currindex--; if (currindex < 0) { currindex = CurrentGroup.ReferringGroupMap().Count - 1; } gm = (GroupMap)CurrentGroup.ReferringGroupMap()[currindex]; chan = (Channel)gm.ReferencedChannel(); } while (!chan.VisibleInGuide); TVHome.UserChannelChanged = true; m_zapchannel = chan; m_zapchannel.CurrentGroup = null; m_zapChannelNr = -1; Log.Info("Navigator:ZapPrevious {0}->{1}", currentChan.DisplayName, m_zapchannel.DisplayName); if (GUIWindowManager.ActiveWindow == (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN) { if (useZapDelay) { m_zaptime = DateTime.Now.AddMilliseconds(m_zapdelay); } else { m_zaptime = DateTime.Now; } } else { m_zaptime = DateTime.Now; } RaiseOnZapChannelEvent(); }
/// <summary> /// Changes to the next channel in the current group. /// </summary> /// <param name="useZapDelay">If true, the configured zap delay is used. Otherwise it zaps immediately.</param> public void ZapToNextChannel(bool useZapDelay) { Channel currentChan = null; int currindex; if (m_zapchannel == null) { currindex = GetChannelIndex(Channel); currentChan = Channel; } else { currindex = GetChannelIndex(m_zapchannel); // Zap from last zap channel currentChan = Channel; } GroupMap gm; Channel chan; //check if channel is visible //if not find next visible do { // Step to next channel currindex++; if (currindex >= CurrentGroup.ReferringGroupMap().Count) { currindex = 0; } gm = (GroupMap)CurrentGroup.ReferringGroupMap()[currindex]; chan = (Channel)gm.ReferencedChannel(); } while (!chan.VisibleInGuide); TVHome.UserChannelChanged = true; ZapChannel = chan; m_zapchannel.CurrentGroup = null; Log.Info("Navigator:ZapNext {0}:{1}->{2}:{3},index:{4}", currentChan.DisplayName, currentChan.ChannelNumber, m_zapchannel.DisplayName, m_zapchannel.ChannelNumber, currindex); if (GUIWindowManager.ActiveWindow == (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN) { if (useZapDelay) { m_zaptime = DateTime.Now.AddMilliseconds(m_zapShortDelay); } else { m_zaptime = DateTime.Now; } } else { m_zaptime = DateTime.Now; } RaiseOnZapChannelEvent(); }
/// <summary> /// Changes the current channel after a specified delay. /// </summary> /// <param name="channelNr">The nr of the channel to change to.</param> /// <param name="useZapDelay">If true, the configured zap delay is used. Otherwise it zaps immediately.</param> public void ZapToChannel(int channelNr, bool useZapDelay) { IList <GroupMap> channels = CurrentGroup.ReferringGroupMap(); m_zapChannelNr = channelNr; channelNr--; if (channelNr >= 0 && channelNr < channels.Count) { GroupMap gm = (GroupMap)channels[channelNr]; Channel chan = gm.ReferencedChannel(); TVHome.UserChannelChanged = true; ZapToChannel(chan, useZapDelay); } }
/// <summary> /// Retrieves the index of the current channel. /// </summary> /// <returns></returns> private int GetChannelIndex(Channel ch) { IList <GroupMap> groupMaps = CurrentGroup.ReferringGroupMap(); for (int i = 0; i < groupMaps.Count; i++) { GroupMap gm = (GroupMap)groupMaps[i]; Channel chan = (Channel)gm.ReferencedChannel(); if (chan.IdChannel == ch.IdChannel) { return(i); } } return(0); // Not found, return first channel index }
/// <summary> /// Changes the current channel (based on channel number) after a specified delay. /// </summary> /// <param name="channelNr">The nr of the channel to change to.</param> /// <param name="useZapDelay">If true, the configured zap delay is used. Otherwise it zaps immediately.</param> public void ZapToChannelNumber(int channelNr, bool useZapDelay) { IList <GroupMap> channels = CurrentGroup.ReferringGroupMap(); if (channelNr >= 0) { Channel chan; for (int i = 0; i < channels.Count; i++) { chan = ((GroupMap)channels[i]).ReferencedChannel(); if (chan.VisibleInGuide) { if (chan.ChannelNumber == channelNr) { Log.Debug("ZapToChannelNumber: found channel, channelNr: {0}, chan.DisplayName: {1}", channelNr, chan.DisplayName); ZapToChannel(chan, useZapDelay); return; } } } } Log.Debug("ZapToChannelNumber: channel not found, channelNr: {0}, channels.Count: {1}", channelNr, channels.Count); }
/// <summary> /// Checks if it is time to zap to a different channel. This is called during Process(). /// </summary> public bool CheckChannelChange() { if (reentrant) { return(false); } try { reentrant = true; // Zapping to another group or channel? if (m_zapgroup != -1 || m_zapchannel != null) { // Time to zap? if (DateTime.Now >= m_zaptime) { // Zapping to another group? if (m_zapgroup != -1 && m_zapgroup != m_currentgroup) { // Change current group and zap to the first channel of the group m_currentgroup = m_zapgroup; if (CurrentGroup != null && CurrentGroup.ReferringGroupMap().Count > 0) { GroupMap gm = (GroupMap)CurrentGroup.ReferringGroupMap()[0]; Channel chan = (Channel)gm.ReferencedChannel(); m_zapchannel = chan; } } m_zapgroup = -1; //if (m_zapchannel != m_currentchannel) // lastViewedChannel = m_currentchannel; // Zap to desired channel if (m_zapchannel != null) // might be NULL after tuning failed { Channel zappingTo = m_zapchannel; //remember to apply the new group also. if (m_zapchannel.CurrentGroup != null) { m_currentgroup = GetGroupIndex(m_zapchannel.CurrentGroup.GroupName); Log.Info("Channel change:{0} on group {1}", zappingTo.DisplayName, m_zapchannel.CurrentGroup.GroupName); } else { Log.Info("Channel change:{0}", zappingTo.DisplayName); } m_zapchannel = null; TVHome.ViewChannel(zappingTo); } m_zapChannelNr = -1; reentrant = false; return(true); } } } finally { reentrant = false; } return(false); }