WebEngine SDK: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
No edit summary
Line 39: Line 39:
<nowiki>
<nowiki>
<!-- begin: loop(z, 0, min(4, [LibraryItemCount] - 1)) -->
<!-- begin: loop(z, 0, min(4, [LibraryItemCount] - 1)) -->


<li>[LibraryItem([z]).Name]</li>
<li>[LibraryItem([z]).Name]</li>

<!-- end: loop

<!-- end: loop -->
</nowiki>
</nowiki>


Line 48: Line 52:


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.
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:
<nowiki>
<!-- begin: if([z] < [ZoneCount]) -->


... code that gets excluded if condition is not met ...


<!-- end: if -->
</nowiki>


== Functionality ==
== Functionality ==

Revision as of 20:29, 23 June 2010

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)]

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 -->

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