Change channel by channelNumber or SID (w. code) (4 Viewers)

W_Z

Portal Member
April 6, 2007
13
1
Home Country
Canada Canada
North American satellite users (and perhaps others) are used to having channel numbers that are based on serviceID. Currently, when you type in a number in the guide it goes to the offset in the guide. Also, there is a hardcoded limit of two digits. As far as I can tell this was partially corrected in the standalone MP but never made it to the TV plugin.

Here is code that allows for channel numbers of 3 digits in length and changes based on channelNumber. I haven't looked at the code for fullscreen and miniepg yet so this is only for finding channels in the guide.

TvGuideBase.cs
Code:
void OnKeyCode(char chKey)
    {
      if (chKey >= '0' && chKey <= '9') //Make sure it's only for the remote
      {
        TimeSpan ts = DateTime.Now - _keyPressedTimer;
        if (_lineInput.Length >= 3 || ts.TotalMilliseconds >= 800)
        {
          _lineInput = String.Empty;
        }
        _keyPressedTimer = DateTime.Now;
        if (chKey == '0' && _lineInput.Length == 0)
          return;
        _lineInput += chKey;
        if (_lineInput.Length == 3)
        {
          // change channel
          int iChannel = Int32.Parse(_lineInput);
          ChangeChannelNr(iChannel);

        }
      }
    }

    void ChangeChannelNr(int iChannelNr)
    {
     // iChannelNr--;

      int iCounter = 0;
      bool found = false;

      Channel chan;

      while (iCounter < _channelList.Count && found == false)
      {
          chan = (Channel)_channelList[iCounter];

          foreach (TuningDetail detail in chan.ReferringTuningDetail())
          {
              if (detail.channelNumber == iChannelNr)
              {
                  iChannelNr = iCounter;
                  found = true;
              }
          }
          iCounter++;
      }

      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();
      }
    }


I propose that instead of serviceID we use channelNumber as this should be a more universal system because I believe analog input devices, etc already populate this field. With this setup we'd need to have the channelNumber field in the database populated with serviceID when a scan is done. I think this would only be for North American users so we may need a checkbox next to the scan button. Users can use the following query in the meantime to manually copy SID to channelNumber:

Code:
UPDATE dbo.TuningDetail SET channelNumber = serviceId;
 

IcePickrg

Portal Member
March 12, 2007
29
0
Denver, Colorado
Home Country
United States of America United States of America
I want to thank W_Z for working on this code - it is awesome to finally see this fix!

I think rather then having a max digit input that we extend and/or make configurable the timeout value. This would allow for fine tuning for remote.

I beleive this code is what is causing my 0 issue.

<code>_lineInput = String.Empty;
}
_keyPressedTimer = DateTime.Now;
if (chKey == '0' && _lineInput.Length == 0)
return;
</code>
 

W_Z

Portal Member
April 6, 2007
13
1
Home Country
Canada Canada
I have improved my code a bit.

Here’s my list of updates in this. It should have no effect on non-NA users whatsoever now.
- the indexed channel number option in MP setup should function correctly now - it is either by channel number or index.
- if you enter a channel number and it doesn’t exist it will go to the nearest number.
- the first “time” label at the top of the guide has been used to show the channel numbers as you enter them. When you finish or let it time out (800ms) it goes back to how it was.
- options for ‘show channel number in guide’ and ‘channel number max. length’ have been added in MP setup.

To do:
-make channel entry work in fullscreen and miniepg
-add an option to sort by channel name in TVE3. I think adding a ‘Channel Number’ column header that you could click on to sort would be perfect.
-add a checkbox/option to set channelNumber field to SID when scanning dvb.

Hopefully this will get tested and added to SVN soon.

Thanks for the feedback so far.

Code is attached as I know some of you are interested.
 

Muldini

Retired Team Member
  • Premium Supporter
  • February 11, 2007
    206
    0
    Home Country
    Germany Germany
    Just had the chance to test this, what he coded so far works like a charm for me. Keep up the good work.

    Regards,
    Muldini
     

    Frodo

    Retired Team Member
  • Premium Supporter
  • April 22, 2004
    1,518
    121
    53
    The Netherlands
    Home Country
    Netherlands Netherlands
    Please post the complete new/modified files and not a .patch file
    Then i'll add it to svn

    Frodo
     

    jdugas

    Portal Member
    April 19, 2006
    34
    1
    NY
    Home Country
    United States of America United States of America
    Please see: http://sourceforge.net/tracker/index.php?func=detail&aid=1759398&group_id=107397&atid=647927

    NOTE: Users will need to manually copy serviceID to channelNumber in the
    database until scanning can populate the channelNumber field.

    Use:
    Code:
    UPDATE dbo.TuningDetail SET channelNumber = serviceId;

    Thanks for the update W_Z. I cant wait to try this out. For those that use more than one Sat provider (Dish and Bev), this Query may be useful... I like to number my Dish channels the same as the SID and the Bev channels the SID + 1000.

    For those that are not familiar with the MS SQL Server Management Studio Express utility, open it up and log in using the username/password that you provided when setting up the TV Server.

    Drill down until you find the TvLibrary under the Databases section on the left of the screen. Right click on TvLibrary and choose Tasks > Back Up > backup your database before doing the next steps (Just in case).

    Now, Click on New Query, paste the following into the query editor:

    UPDATE dbo.TuningDetail
    SET channelNumber = serviceId
    WHERE networkId = 4100

    UPDATE dbo.TuningDetail
    SET channelNumber = serviceId
    WHERE networkId = 4102

    UPDATE dbo.TuningDetail
    SET channelNumber = 1000 + serviceId
    WHERE networkId = 256

    UPDATE dbo.TuningDetail
    SET channelNumber = 1000 + serviceId
    WHERE networkId = 257

    After you have this in the query editor, click on the Execute button.

    This query will only work with Dish/Bev setups... you will need to modify it to work with other sats.
     

    Users who are viewing this thread

    Top Bottom