Adding new PCast menus for the LinkTheatre
This investigation was inspired by Articles/GeneralFunWithPCast. It looked like it would be possible to change the PCast html files stored on the LinkStation to extend the menus and functionality of the LinkTheatre. I had the idea of checking for new emails in the lounge/kitchen/wherever, but the possibilities are probably endless. In fact this intrigue even caused me to buy a LinkTheatre to satisfy my curiosity - I didn't have one already!!
The current set of files held in /etc/pcast/theme/pcast from this project are available here: pcast themes
|Side note on the LinkTheatre|
The LinkTheatre works well on my 802.11g network - streaming Photos, Music and Video from the LinkStation. I was concerned about the bandwidth requirements for video, but this appears to be largely unfounded, and I use a variety of video formats including mpeg, DivX, XviD, mp4 and VOBs. The user interface is browser based, taking content from the media server (the LinkStation in this case) so displaying menus is not instantaneous. On the LinkTheatre there's a 'go back' function akin to a go back in a web browser, but there is no easy way to navigate up a level when browsing directories. The HTML code indicates that the Red button on a remote performs this function, but the LinkTheatre remote doesn't have the equivalent of the red button (it does have the equivalent of the other three, but they are not actually coloured - they have the video, music and picture icons on them).
I had already replaced the original LinkStation firmware on a MIPSel device with an Projects/OpenLink firmware downloaded from LinkStationWiki. This enables command-line access using ssh (I use the PuTTY client). I have made various changes, and installed some additional packages, but these are not relevent to the PCast functionality.
You may also need a graphics editor such as Photoshop, Paint Shop Pro, The Gimp or even Microsoft Paint.
PCast HTML Setup
PCast holds it's HTML templates in a directory structure. The skin_root entry in the /etc/pcast/pcast.conf file points to that directory. The default is /etc/pcast/theme/pcast. When experimenting with a theme/skin it makes sense to copy an existing theme to a new diectory, changing the skin_root entry in the /etc/pcast/pcast.conf file to point to thart new directory and restart PCast. Should something go wrong it is easy to revert the settings in /etc/pcast/pcast.conf and continue with the original theme.
For this article, however, all work was performed in the /etc/pcast/theme/pcast directory on the LinkStation.
As noted in Articles/GeneralFunWithPCast, the html is prepocessed by the PCast executable /usr/sbin/pcastd as part of a templating system. This replaces variables embedded in the html files, and also builds pages using multiple files from the /etc/pcast/theme/pcast directory.
head_xxx.html is used for the menu functions
line_xxx.html is used for content
tail.html is a common trailer
There is a set of these files for each type of media, where xxx = image, movie and music. There are also some additional 'line' templates to create a content line (on the right hand side of the screen) containing a subdirectory (line_dir.html), blank line (line_space.html), and for when the file type is unknown (line_unknown.html).
The recommended first step is to take a backup of all files under /etc/pcast/theme/pcast! Alternatively, place a copy of /etc/pcast/theme/pcast in a new subdirectory and change the skin_root in /etc/pcast/pcast.conf to point to that new directory and restart PCast
The LinkTheatre provides support for standard and HD TV resolution menus. There is a checkbox in the LinkTheatre 'setup' menu to select the higher resolution menus. The effect is to use a different set of html files, suffexed by '_high.html' (and similarly for image files). I have ignored the 'high' files in the article, but changes to standard menus could equally apply to the high def set.
The first step I took in extending the functionality available to the LinkTheatre was to add a fifth entry to the main menu. The standard four are 'home' and buttons to select the video, image and music content. Each of these three buttons invoke the same (unknown, because of the templating system) PCast function with a filter parameter to list the appropriate type of media.
This was a simple task - editting top.html; repeating the html code of one of the previous menu entries and changing the A tag to simply load a new html file instead of using the PCast macro. This is what I included (it's just another row in the left hand side table)
<TD width=0 height=40>
<TD width=125 height=40>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<A href="extras.html" tvid="blue"><B>extras</B></A>
I've included the tvid="blue" tag - I made blue up, given that there was already red, green and yellow. The colours apparently refer to buttons on the remote control of some Syabas devices, but the LinkStation remote doesn't actually have the coloured buttons itself.
I originally used email.html, but have now generalised this to extras.html as the new page provides more services, not just email.
Changing the background
Adding a menu entry produces a new navigatable link, but there is a standard background graphic that contains the depiction of 4 buttons, on which the menu option text is overlaid (the main menu plus the three media functions.) To create the new button background image it is a simple task to copy the tv.jpg file across to a shared directory on the LinkStation, edit it using your favourite graphics editing tool and copy it back across again.
Note that there is also a background.jpg file. This is displayed when you point your web browser to the linkstation, but meta-tags within the html cause the LinkTheatre to use to tv.jpg file.
You can check your progress using the LinkTheatre, but may have to go to the 'Log In' screen (using the 'Home' button on the remote) and re-select the LinkStation to see the updated menus. Alternatively, you can point a browser to h ttp://<your linkstation>:8000 and press reload to see changes. Just remember that the LinkTheatre does not understand all HTML, so a final check with a LinkTheatre is in order.
In a similar way to the top menu, each of the Photo, Music and Video header html files need to be updated to introduce the new menu entry. i.e. head_image.html, head_music.html and head_movie.html. (See the Automation section for a way to avoid this). They all use the same background graphic, so this is already addressed.
PCast does not provide any facility for dynamic updates to web pages (other than that built into the PCast executable - see the reference section). It is therefore necessary to dynamically recreate the HTML if you wish to inject other live content into the LinkTheatre pages. The OpenLink firmware includes cron which can be used to schedule automated updates. However to retrieve information from other systems it is necessary to install some additional software - such as an ftp client, telnet or netcat.
HTML Template Directives
Inside the template html files a number of PCast specific directives can be used. These directives have the form of HTML comments, so they do not interfere with normal HTML, and e.g. allow to edit a PCast template file with a normal HTML editor.
The spelling of the directives is rather strange. To simplify the interpretation, the following list provides the principle meaning of the phrases used in the directive names:
- PCASTD_DEL_IS_... - Do not show the enclosed HTML, if...
- PCASTD_DEL_IS_NO... - Show the enclosed HTML, if...
- PCASTD_INS_... - Replace the directive with ...
- PCASTD_INS_LINE... - Replace the directive with information/property ... of a media file.
- PCASTD_..._LINK - Replace the directive with value ... formatted to be used in the href attribute of an HTML <A> anchor link. Often there is a corresponding directive, without the ..._LINK suffix. That one is supposed to be used as the anchor text which follows. For example:
<a href="<!--PCASTD_...LINK-->" tvid="<!--PCASTD_INS_LINE_TVID-->"><!--PCASTD_...--></a>
The known directives are as follows:
- <!--PCASTD_DEL_IS_HAVE_MP3_TAGS-->some html<!--/PCASTD_DEL_IS_HAVE_MP3_TAGS--> - Show some html if file does not [sic!] have MP3 ID3 tags. This is the opposite of PCASTD_DEL_IS_NO_MP3_TAGS and is useful when dealing with MP3 files without ID3 tags. In this case it makes sense to e.g. include HTML and directives to display the file name, instead of the non-existing artist and title tags. Note: The directive name is rather counter intuitive.
- <!--PCASTD_DEL_IS_NO_IMAGE_FILES-->some html<!--/PCASTD_DEL_IS_NO_IMAGE_FILES--> - Show some html if file is an image file type.
- <!--PCASTD_DEL_IS_NO_MOVIE_FILES-->some html<!--/PCASTD_DEL_IS_NO_MOVIE_FILES--> - Show some html if file is a movie file type.
- <!--PCASTD_DEL_IS_NO_MP3_TAGS-->some html<!--/PCASTD_DEL_IS_NO_MP3_TAGS--> - Show some html if file has [sic!] MP3 tags. This is the opposite of PCASTD_DEL_IS_HAVE_MP3_TAGS. It can be used to trigger the display of ID3 tags from an MP3 file in case this file contains ID3 tags. See the PCASTD_INS_LINE_MP3TAG_... directives for a list of tags PCast can extract from an MP3 file.
- <!--PCASTD_DEL_IS_NO_MUSIC_FILES-->some html<!--/PCASTD_DEL_IS_NO_MUSIC_FILES-->:Show some html if file is a sound file type.
- <!--PCASTD_DEL_IS_ROOTDIR-->some html<!--/PCASTD_DEL_IS_ROOTDIR--> - Show some html if file is not the media root directory.
- <!--PCASTD_INS_CURRENT_FILTER--> - Replaced by current active filer name.
- <!--PCASTD_INS_CURRENT_PAGE--> - Replaced by current page number. This is useful when assembling a navigation bar, e.g. together with the PCASTD_INS_MAX_PAGE directive to display Page X of Y.
- <!--PCASTD_INS_CURRENT_PATH--> - Replaced by the current path name.
- <!--PCASTD_INS_CURRENT_PATH_LINK--> - Replaced by a link to the current path. The data is supposed to be used in the href attribute of an HTML <A> anchor link.
- <!--PCASTD_INS_CURRENT_PATH_LINK_NO_SORT--> - Replaced by the current path, used to specify a particular sort. To be used in the href attribute of an HTML <A> anchor link.
- <!--PCASTD_INS_END_FILE_NUM--> - Replaced by last file number (useful in file X of Y displays).
- <!--PCASTD_INS_FILE_NUM--> - Replaced by current file number.
- <!--PCASTD_INS_HOST_IP--> - Replaced by the client's (e.g. a LinkTheatre) IP address (Note: Once again, the seppling of the directive is strange, using the term HOST to indicate a client). PCast does not try to resolve the client's IP addres to the client's host name. Which is in general a good idea, since it would require a DNS server in the home network, or a correctly configured entry in the LinkStation /etc/hosts file. None of this is typically done.
- <!--PCASTD_INS_LINE_FILE_EXT--> - Replaced by the file extension of the file to be displayed in this line.
- <!--PCASTD_INS_LINE_FILE_LINK--> - Replaced by a link to the PCast specific play information for the particular file. To be used in the href attribute of an HTML <A> anchor link.
- <!--PCASTD_INS_LINE_FILE_NAME--> - Replaced by the file name of the file to be displayed in this line (including file name extension).
- <!--PCASTD_INS_LINE_FILE_NAME_NO_EXT--> - Replaced by the file name of the file to be displayed in this line (without file name extension).
- <!--PCASTD_INS_LINE_FILE_POD--> - Syabas POD information?
- <!--PCASTD_INS_LINE_FILE_SIZE--> - Replaced by the size of of the file to be displayed in this line.
- <!--PCASTD_INS_LINE_FILE_VOD--> - Syabas VOD information?
- <!--PCASTD_INS_LINE_MP3TAG_ALBUM--> - Replaced by the MP3 Album name taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
- <!--PCASTD_INS_LINE_MP3TAG_ARTIST--> - Replaced by the MP3 artist name taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
- <!--PCASTD_INS_LINE_MP3TAG_COMMENT--> - Replaced by the MP3 comment taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
- <!--PCASTD_INS_LINE_MP3TAG_TITLE--> - Replaced by the MP3 song title taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
- <!--PCASTD_INS_LINE_MP3TAG_TITLE_INFO--> - Replaced by the MP3 title information taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
- <!--PCASTD_INS_LINE_MP3TAG_YEAR--> - Replaced by the MP3 year information taken from the tags of the MP3 file to be displayed in this line (should be wrapped in a PCASTD_DEL_IS_NO_MP3_TAGS).
- <!--PCASTD_INS_LINE_TVID--> - LinkTheatre/syabas coloured button ID
Links have been lost from the original article.