Fix "My RTHK Radio Player" Windows Gadget

Although looking elegant, the My RTHK radio player available in the official site (at least the Windows gadget version) suffers from two critical problems on displaying the schedule.
  • If you are in a time zone different from HKT (GMT +8), the on-air program shown in minimized mode is based on the program schedule of the day and your local time. Suppose you are in the US. At the time you are in your morning while Hong Kong is at night, the live stream plays the night show, but the on-air program shown is some
    morning show.
  • The gadget retrieves program schedules which is updated every midnight. However, each schedule covers time from 6.00am - 5.59am the next day. This means when you are at time from 0.00am - 5.59am, the schedules you have are for the next day.
Fix:
  1. Download the gadget file.
  2. Unzip it. (Renaming the extension to .zip may help.)
  3. Open script/common.js as a text file (with Notepad,
    for example). Look for the line
    var currentH = current.getHours();
    (which is in the definition of the function isOnAir(obj))
    Add the following line
    currentH = (currentH + current.getTimezoneOffset()/60 + 8)%24;
    This fixes problem 1.
  4. In the same file, look for the line
    var fullRe = new
    RegExp(/([0-9]{2})\:([0-9]{2})-([0-9]{2})\:([0-9]{2})[^a]*]*>(.*?)<\/a>/);
    (which is in the definition of the function rthk_parseSchedule(str))
    Replace it with
    var fullRe = new RegExp(/([0-9]{2})\:([0-9]{2}) -
    ([0-9]{2})\:([0-9]{2})[^a]*<a target=_blank
    href="([^"]+)"[^>]*>(.*?)<\
    /a>/);
  5. In the same file, look for the line
    link:result[5],
    (which is in the definition of the function rthk_parseSchedule(str))
    Replace it with
    link:'http://www.rthk.org.hk'+result[5],
  6. Open RadioPlayer.js as a text file. Look for the block
    // Parser RSS Data to array
    // For Version 1.0.0
    // var data = rthk_parseSchedule(gReader.req.responseText);

    // For Version 1.0.2
    var data = rthk_parseScheduleV2(gReader.req.responseText);
    lslib.trace('# onReaderLoaded:'+ data.length);

    Change it to the following:
    // Parser RSS Data to array
    // For Version 1.0.0
    var data = rthk_parseSchedule(gReader.req.responseText);

    // For Version 1.0.2

    //var data = rthk_parseScheduleV2(gReader.req.responseText);
    //lslib.trace('# onReaderLoaded:'+ data.length);
  7. Open AppConfig.js as a text file. Change the following lines as instructed below:
    • schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio1_schedule.xml',
      to
      schedule:'http://www.rthk.org.hk/rthk/schedule/radio1',
    • schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio2_schedule.xml',
      to
      schedule:'http://www.rthk.org.hk/rthk/schedule/radio2',
    • schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio3_schedule.xml',
      to
      schedule:'http://www.rthk.org.hk/rthk/schedule/radio3',
    • schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio4_schedule.xml',
      to
      schedule:'http://www.rthk.org.hk/rthk/schedule/radio4',
    • schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio5_schedule.xml',
      to
      schedule:'http://www.rthk.org.hk/rthk/schedule/radio5',
    • schedule:'http://www.rthk.org.hk/rthk_include/rthk_pth_schedule.xml',
      to
      schedule:'http://www.rthk.org.hk/rthk/schedule/pth',
    This fixes the 2nd problem by turning the schedule source to one which updates at 6.00am every day.
  8. To make sure that the schedule in the program is always up-to-date, in AppConfig.js find the line
    DATA_REFRESH_TIME = 60; // Data Updates Time, by mintues
    Change it to
    DATA_REFRESH_TIME = 1; // Data Updates Time, by mintues
    So the program retrieves the schedule every minute. Sometimes it may be necessary because the schedule located in the remote RTHK site may not have updated at 6.00am HKT sharp, when the program is supposed to retrieve the schedule again.
  9. Zip all the folders and files again. Name with whatever you like, but with a .gadget extension. Then double-click it to install.
Afternoon in New York, morning in Hong Kong
Morning show title in the modified gadget (at top right),
but evening news shown as title in original gadget (at middle right)

Comments

Popular posts from this blog

Using PlayStation 1 Densha de Go controller on emulators

Using PS1/PC Densha de Go! controller SLPH-00051/TCPP-20001/DGOC-44U on PS4/Switch Densha de Go!!

Play octoshape stream on windows with VLC player