MediaPortal Version: 0.2.0.4 and greater
There is a bug in the MP source code in the TVguide section that it is impossible to change channels by channel number even if the "select channel by index" is unchecked because this value is never used in the TV Guide source code! See the code for GUITvGuideBase.cs. The function ChangeChannelNr does not check the value of _byIndex because it is not even referenced in that class. Here is an updated version of the function ChangeChannelNr which should work and also include support for externalchannels which is so desperately needed:
Of course, the variable _byIndex needs to be added to the class, so I added it in the same way as it is in the GUITVHome.cs file.
Then the LoadSettings() method should also include the _byIndex variable as:
Great, now we should be able to change channels by channel number correctly in the TV guide even with external channels if they are setup correctly (i.e externalchannel number field is populated).
Now, we have the problem of external channels not supported in the LiveTV. Here is the relevant code that fixes that problem as well. In the GUITVHome.cs file, the function ZapToChannelNumber should be
Now we have full support for changing channels by number and support for external channels.
There is also another problem. I have satellite TV in the US. The majority of the channels have three digits, but it is hardcoded in the OnKeyCode function in the GUITvGuideBase.cs file to only accept 2 digits. Can this be made a variable and put in the TV configuration section? I will post separately if necessary.
Developers, please look at this code and let me and everyone else know what you think. I believe this should fix all of the problems that us U.S. users are having with changing channel by actual channel numbers and also support external channels for a STB.
Jesse
There is a bug in the MP source code in the TVguide section that it is impossible to change channels by channel number even if the "select channel by index" is unchecked because this value is never used in the TV Guide source code! See the code for GUITvGuideBase.cs. The function ChangeChannelNr does not check the value of _byIndex because it is not even referenced in that class. Here is an updated version of the function ChangeChannelNr which should work and also include support for externalchannels which is so desperately needed:
Code:
void ChangeChannelNr(int iChannelNr)
{
if (_byIndex) // Check if channel changing should be byIndex
{
// Channel change by index
iChannelNr--;
}
else
{
// Change channel by using actual channel number
int iCounter = 0;
bool found = false;
TVChannel chan;
// Loop through complete channel list until match is found
while (iCounter < _channelList.Count && found == false)
{
chan = (TVChannel)_channelList[iCounter];
// Check if channel is an external channel
if (chan.External == false)
{
//Not External Channel
if (chan.Number == iChannelNr)
{
iChannelNr = iCounter;
found = true;
}
}
else
{
//External channel
if (Int32.Parse(chan.ExternalTunerChannel) == iChannelNr)
{
iChannelNr = iCounter;
found = true;
}
}
iCounter++; // Increment loop counter
}
}
if (iChannelNr >= 0 && iChannelNr < _channelList.Count)
{
UnFocus();
_channelOffset = 0;
_cursorX = 0;
// Last page adjust (To get a full page channel listing)
if (iChannelNr > _channelList.Count - _channelCount + 1)
{
_channelOffset = _channelList.Count - _channelCount;
iChannelNr = iChannelNr - _channelOffset;
}
while (iChannelNr >= _channelCount)
{
iChannelNr -= _channelCount;
_channelOffset += _channelCount;
}
_cursorX = iChannelNr;
Update(false);
SetFocus();
}
}
Of course, the variable _byIndex needs to be added to the class, so I added it in the same way as it is in the GUITVHome.cs file.
Code:
#region variables
...snip
bool _byIndex = false;
...snip
#endregion
Then the LoadSettings() method should also include the _byIndex variable as:
Code:
void LoadSettings()
{
using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.Get(Config.Dir.Config) + "MediaPortal.xml"))
{
_currentTvChannel = xmlreader.GetValueAsString("tvguide", "channel", String.Empty);
_cursorX = xmlreader.GetValueAsInt("tvguide", "ypos", 0);
_channelOffset = xmlreader.GetValueAsInt("tvguide", "yoffset", 0);
_autoTurnOnTv = xmlreader.GetValueAsBool("mytv", "autoturnontv", false);
_disableXMLTVImportOption = xmlreader.GetValueAsBool("plugins", "TV Movie Clickfinder", false);
_byIndex = xmlreader.GetValueAsBool("mytv", "byindex", true);
}
}
Great, now we should be able to change channels by channel number correctly in the TV guide even with external channels if they are setup correctly (i.e externalchannel number field is populated).
Now, we have the problem of external channels not supported in the LiveTV. Here is the relevant code that fixes that problem as well. In the GUITVHome.cs file, the function ZapToChannelNumber should be
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.External == false)
{
if (chan.Number == channelNr)
{
ZapToChannel(chan.Name, useZapDelay);
found = true;
}
}
else
{
if (Int32.Parse(chan.ExternalTunerChannel) == channelNr)
{
ZapToChannel(chan.Name, useZapDelay);
found = true;
}
}
ChannelCnt++;
}
}
}
Now we have full support for changing channels by number and support for external channels.
There is also another problem. I have satellite TV in the US. The majority of the channels have three digits, but it is hardcoded in the OnKeyCode function in the GUITvGuideBase.cs file to only accept 2 digits. Can this be made a variable and put in the TV configuration section? I will post separately if necessary.
Developers, please look at this code and let me and everyone else know what you think. I believe this should fix all of the problems that us U.S. users are having with changing channel by actual channel numbers and also support external channels for a STB.
Jesse
United States of America