WebEngine SDK

From wiki.jriver.com
Revision as of 20:53, 23 June 2010 by Matt (talk | contribs)
Jump to navigation Jump to search

Introduction

Media Center 15 introduced the ability to browse, control, or play from a library on a phone or other Internet connected device using WebPlay and WebRemote.

Both WebPlay and WebRemote are fully customizable. This includes both the appearance and the functionality.

Location

The files used to customize WebPlay and WebRemote are located at:

  • WebPlay: [Media Center Install Path]\Data\WebPlay\[Name]
  • WebRemote: [Media Center Install Path]\Data\WebRemote\[Name]

The default appearances are called 'Default'. They offer a good starting point. You can make a copy of the 'Default' folder and name it anything you like.

You will then be able to select your new customization in Options > Media Network inside the program.

Web Template Language

The HTML files in a customization are sent through a rendering engine that can fill in values based on the current view, perform translation, and do other helpful tasks.

Tokens

Any text between square braces will be considered a 'token'. Tokens are replaced by their corresponding values.

Tokens have the formatting:

  • [Name]
  • [Name(Index)]
  • [Class.Name(Index]]
  • [Class(Index).Name]
  • [Class(Index).Name(Index)]

A list of available tokens is below.

Translation

Any text in curly braces {} will be translated using the current translation.

Loops

Loops provide a way to use far less HTML code for redundant sections. Showing an example is probably the easiest way to see how they work:

<!-- begin: loop(z, 0, min(4, [LibraryItemCount] - 1)) -->
<li>[LibraryItem([z]).Name]</li>
<!-- end: loop -->

You can use any loop variable you like. Above, we use the letter z.

You can use basic math and other tokens in the to and from range for the loop. Above, you can see it uses the function min(...), the token [TopSongCount], and subtraction.

It is important to remember that the loop is inclusive, so looping from 0 to 4 will do 5 steps: 0, 1, 2, 3, 4.

Conditionals (if statements)

If statements can be coded (with math) like:

<!-- begin: if([z] < [ZoneCount]) -->
... code that gets excluded if condition is not met ...
<!-- end: if -->

Web Template Tokens

Below is a list of available web template tokens. The letters x and y are used as index variables for demonstrations purposes. They should be filled by your loop variable (or similar) when building actual pages.

Class: Zone(index)

The index is the index (0-based) of the zone.

  • [Zone(x).Name]: name of the zone

Class: LibraryItem(index)

When browsing, the individual items that make up a library view. For example, they could be an artist, album, keyword, etc.

  • [LibraryItem(x).Name]: name of item
  • [LibraryItem(x).ImageLink]: URL to a thumbnail (JPEG) for the item
  • [LibraryItem(x).IntoLink]: URL to navigate into this item
  • [LibraryItem(x).ShowPlay]: whether it makes sense to show play commands for this item (0 or 1)
  • [LibraryItem(x).PlayLink]: URL to play the library item on the server machine
  • [LibraryItem(x).AddLink]: URL to add the library item to Playing Now on the server machine
  • [LibraryItem(x).ShuffleLink]: URL to play (with shuffle) the library item on the server machine
  • [LibraryItem(x).M3ULink]: URL that will provide an M3U playlist of the files in the library item
  • [LibraryItem(x).ASXLink]: URL that will provide an ASX playlist of the files in the library item
  • [LibraryItem(x).MPLLink]: URL that will provide an MPL playlist of the files in the library item
  • [LibraryItem(x).WebPlayPlayLink]: URL that will play the library item files on the client
  • [LibraryItem(x).WebPlayShuffleLink]: URL that will play (with shuffle) the library item files on the client


Functionality

The functionality to play, pause, etc. is provided by the Web Service Interface, called MCWS. Please see the documentation for the web service to learn about the possible functionality.

The default skins use AJAX to do some processing. For example, this allows the 'Playing Now' screen to update periodically using information from the server without requiring page reloads.

More