Channels tuned externally won't change by channel number (1 Viewer)

delicious

Portal Member
July 13, 2006
27
0
Area: Media Portal Program
MP Version: 0.2
Stuff that doesn't matter: n/a
Pertinent portions of Log:

what it looks like
7/16/2006 4:43:07 AM ChangeChannelNr()
7/16/2006 4:43:07 AM UpdateOSD()
7/16/2006 4:43:07 AM window:MediaPortal.GUI.TV.GUITVZAPOSD init
7/16/2006 4:43:07 AM ZAP OSD:ON
7/16/2006 4:43:11 AM g_Player.Stop()

what it should look like
7/16/2006 4:47:10 AM ChangeChannelNr()
7/16/2006 4:47:10 AM UpdateOSD()
7/16/2006 4:47:10 AM window:MediaPortal.GUI.TV.GUITVZAPOSD init
7/16/2006 4:47:10 AM ZAP OSD:ON
7/16/2006 4:47:10 AM Channel change:206 ESPN
7/16/2006 4:47:10 AM GUITVHome.ViewChannel(): View channel=206 ESPN ts:True
7/16/2006 4:47:10 AM g_Player.Stop()


Synopsis:

When using an external set top box, it's not possible to change channels via logical channel numbering. It is possible using indexing.

The Issue:

When attempting to use logical channel numbering (unchecking the box "Select channel number by index (non-us)", to change channels for an external box, it does not work. I did some research on the subject. When this option is set, it calls GUITVHome.Navigator.ZapToChannelNumber to change the channel. (Otherwise it calls GUITVHome.Navigator.ZapToChannel to change the channel by index number).

This is in \WindowsPlugins\GUITV\GUITVHome.cs -

.. snipped


public void ZapToChannelNumber( int channelNr, bool useZapDelay )
{
List<TVChannel> channels = CurrentGroup.TvChannels;
if ( channelNr >= 0 )
{
bool found = false;
int ChannelCnt = 0;
TVChannel chan;
while ( found == false && ChannelCnt < channels.Count )
{
chan = (TVChannel)channels[ChannelCnt];
if ( chan.Number == channelNr )
{
ZapToChannel(chan.Name, useZapDelay);
found = true;
}
else
ChannelCnt++;
}
}
}

Well, a quick look at the code and it's obvious why it does not work. chan.Number for external channels is set to 25000+. This loops until it has looked at all the channels in the dataset, looking for a match. Even if the dataset had over 25000 entries, it still wouldn't hit the correct channel. :wink:

The solution (possibly):

Add an if statement to the code to check if the channel is listed in the External Channel List. (There are other ways to tackle it, but I think this is the simplest.) So it would look something like this:

public void ZapToChannelNumber( int channelNr, bool useZapDelay )
{
List<TVChannel> channels = CurrentGroup.TvChannels;
if ( channelNr >= 0 )
{

bool found = false;
int ChannelCnt = 0;
TVChannel chan;
while ( found == false && ChannelCnt < channels.Count )
{
chan = (TVChannel)channels[ChannelCnt];
if ( chan.Number == channelNr )
{
ZapToChannel(chan.Name, useZapDelay);
found = true;
}
else if (chan.EternalTunerChannel == channelNr)
{
ZapToChannel(chan.Name, useZapDelay);
found = true;
}
else
ChannelCnt++;
}
}
}
}

I'm not exactly sure on the syntax, if chan.ExternalTunerChannel is available, or if this would even work.

Thank you for your attention!

P.S. It'd be nice to get something similar working in the epg.

P.P.S. The posting process seems to have gotten rid of my formatting in the code...
 

CHli

Portal Pro
July 5, 2005
1,251
14
Switzerland
Home Country
Switzerland Switzerland
to post code in the forum use this syntax :
Code:
[code]public void ZapToChannelNumber(int channelNr, bool useZapDelay)
        {
            List<TVChannel> channels = CurrentGroup.TvChannels;
            if (channelNr >= 0)
            {

                bool found = false;
                int ChannelCnt = 0;
                TVChannel chan;
                while (found == false && ChannelCnt < channels.Count)
                {
                    chan = (TVChannel)channels[ChannelCnt];
                    if (chan.Number == channelNr)
                    {
                        ZapToChannel(chan.Name, useZapDelay);
                        found = true;
                    }
                    else if (chan.EternalTunerChannel == channelNr)
                    {
                        ZapToChannel(chan.Name, useZapDelay);
                        found = true;
                    }
                    else
                        ChannelCnt++;
                }
            }
        }
[/code]
 

delicious

Portal Member
July 13, 2006
27
0
First off, thanks for showing me that, CHli.

Second of all, I got a hold of the svn and VC#Express and am attempting to implement the previous code, but I get the following error:

Operator '==' cannot be applied to operands of type 'string' and 'int'

(chan.EternalTunerChannel == channelNr) is at fault.

So, does anyone know:
a) In which file TVDatabaseV21.db3 is opened and initialized? I'm hoping to change the way that chan.ExternalTunerChannel is imported. But, that depends on...

b) Is chan.ExternalTunerChannel ever used anywhere else?
 

delicious

Portal Member
July 13, 2006
27
0
Well, I found it, but in lieu of rewriting the entire database, I suggest the following. (That and the fact the exteral channel number will be set to the tuner input channel for usb-uirt controlled devices).

Code:
    public void ZapToChannelNumber( int channelNr, bool useZapDelay )
    {
      List<TVChannel> channels = CurrentGroup.TvChannels;
      if ( channelNr >= 0 )
      {
        bool found = false;
        int ChannelCnt = 0;
        TVChannel chan;
        while ( found == false && ChannelCnt < channels.Count )
        {
          chan = (TVChannel)channels[ChannelCnt];
          if ( chan.Number == channelNr )
          {
            ZapToChannel(chan.Name, useZapDelay);
            found = true;
          }
          else if ( chan.Sort == channelNr )
          {
              ZapToChannel(chan.Name, useZapDelay);
              found = true;
          }
          else
            ChannelCnt++;
        }
      }
    }

I have iSort and ExternalTunerChannel set the same, so it should work. If I figure out how, I'll rebuild it and test it.
 

delicious

Portal Member
July 13, 2006
27
0
It works. The sql command
Code:
UPDATE channel SET [iSort]=[ExternalChannel]
needs to be run first to make iSort match up to the channels. It also lines up the channels correctly for the epg.
 

garry

Portal Pro
December 11, 2005
227
17
California
Home Country
United States of America United States of America
A similar change to ChangeChannelNr() in GUITvBase.cs is necessary to allow the direct channel change to work on the EPG screen. I'm testing my change now, will post source once I have it working correctly.
 

Users who are viewing this thread

Top Bottom