Difference between revisions of "DevelopWDTVExtPlugin"

From WikiDLXTV
Jump to: navigation, search
Line 45: Line 45:
  
 
<code>YourPlugin.prototype.onPageTimer =  function(page){ }</code>
 
<code>YourPlugin.prototype.onPageTimer =  function(page){ }</code>
 +
 +
=== Getting Started... ===
 +
I will try to explain here how to start developing WDTVExt plugins. I'm by no means a 'programmer' and learned javascript just recently while dicovering WDTVExt. So if I'm doing thins wrong here, please correct me.
 +
 +
==== What can we do with WDTVExt? (v0.23.5) ====
 +
* File [https://developer.mozilla.org/en/SpiderMonkey/File_object]
 +
** read and write files (can also be used to execute shell commands and retrieve the output)
 +
* XML [https://developer.mozilla.org/En/E4X/Processing_XML_with_E4X]
 +
** parse/manipulate XML content
 +
* Curl
 +
** fetch web content with curl
 +
* Page Control
 +
** add extra XML content
 +
** introduce new @@variables to page
 +
** read all @@variables from page
 +
** write all @@variables to page
 +
** force redraw of page
 +
** react to keys pressed on remote
 +
* Menu Control
 +
** add new menu items
 +
** add new submenu item
 +
** maniplulate menu and submenu items (title, image, focusedImage, handler, ...)
 +
 +
==== What can't we do with WDTVExt? (v0.23.5) ====
 +
* create entire custom pages
 +
* create menu items that link to a folder or file
 +
* create setup pages
 +
 +
 +
Now, let's start creating our first WDTVext plugin: '''Example.plugin.js'''
 +
 +
==== Example Plugin ====
 +
 +
===== Basic Plugin Skeleton =====
 +
 +
Every Plugin strats with some basic plugin constructor:
 +
<pre>
 +
// all traces both trace and traceln will output in /tmp/dmaosd.log (or /tmp/wdtvext.log)
 +
traceln("Plugin.Example: Start loading Example plugin")
 +
 +
function ExamplePlugin(path) {
 +
        this.rootPath = path;
 +
        traceln("Plugin.Example:  base path is " + this.rootPath);
 +
}
 +
 +
// chain ExamplePlugin with proper inheritance - classical in javascript
 +
ExamplePlugin.prototype = new Plugin();
 +
ExamplePlugin.prototype.constructor = ExamplePlugin;
 +
 +
//
 +
// our later to develop code and functions will
 +
//
 +
// go here, left blank for now
 +
//
 +
 +
// create our plugin with baseParg pointing to current script path
 +
// global variables scriptName, scriptLocation and scriptFullPath are available, no need to do the following
 +
ExamplePlugin.instance = new ExamplePlugin(scriptPath);
 +
 +
// register our plugin with WDTVext
 +
Plugin.registerPlugin(ExamplePlugin.instance);
 +
 +
traceln("Plugin.MediaFolder: End loading MediaFolder plugin");
 +
</pre>
 +
All occurances of '''ExamplePlugin''' are of course to be substituted with the name of your plugin.
 +
 +
===== Page Control =====

Revision as of 07:13, 23 May 2010

Develop - WDTV Ext's Plugin

WDTV Ext allow to add custom plugins/extensions to WDlxTV firmware.

All plugins start with Javascript file.

Filename

To load your plugin, the first Javascript filename needs to ends with ".plugin.js".

Event

Menu Event

Variable
  • menuitem
    • name - Menu name
    • title - Menu displayed title
    • image - Path to menu displayed icon
    • focusedImage - Path to selected menu icon
    • visible - Visible or not
Event

YourPlugin.prototype.doBuildMenus = function() { }

YourPlugin.prototype.onMenuSelect = function(menuItem){ }

YourPlugin.prototype.onMenuDeselect = function(menuItem) { }

Page Event

Variable
  • page
    • markupFileName - OSD XML Filename
    • extraContent - XML Content to append the original XML File
    • isMediaListPage
    • selectedMedia
      • name
      • folder
      • path
    • setParam(paramName, value)
    • getParam(paramName)
Event

YourPlugin.prototype.onPageCreated = function(page){ }

YourPlugin.prototype.onPageEnter = function(page){ }

YourPlugin.prototype.onPageKey = function(page, key){ }

YourPlugin.prototype.onPageLeave = function(page){ }

YourPlugin.prototype.onPageTimer = function(page){ }

Getting Started...

I will try to explain here how to start developing WDTVExt plugins. I'm by no means a 'programmer' and learned javascript just recently while dicovering WDTVExt. So if I'm doing thins wrong here, please correct me.

What can we do with WDTVExt? (v0.23.5)

  • File [1]
    • read and write files (can also be used to execute shell commands and retrieve the output)
  • XML [2]
    • parse/manipulate XML content
  • Curl
    • fetch web content with curl
  • Page Control
    • add extra XML content
    • introduce new @@variables to page
    • read all @@variables from page
    • write all @@variables to page
    • force redraw of page
    • react to keys pressed on remote
  • Menu Control
    • add new menu items
    • add new submenu item
    • maniplulate menu and submenu items (title, image, focusedImage, handler, ...)

What can't we do with WDTVExt? (v0.23.5)

  • create entire custom pages
  • create menu items that link to a folder or file
  • create setup pages


Now, let's start creating our first WDTVext plugin: Example.plugin.js

Example Plugin

Basic Plugin Skeleton

Every Plugin strats with some basic plugin constructor:

// all traces both trace and traceln will output in /tmp/dmaosd.log (or /tmp/wdtvext.log)
traceln("Plugin.Example: Start loading Example plugin")

function ExamplePlugin(path) {
        this.rootPath = path;
        traceln("Plugin.Example:   base path is " + this.rootPath);
}

// chain ExamplePlugin with proper inheritance - classical in javascript
ExamplePlugin.prototype = new Plugin();
ExamplePlugin.prototype.constructor = ExamplePlugin;

//
// our later to develop code and functions will
//
// go here, left blank for now
//

// create our plugin with baseParg pointing to current script path
// global variables scriptName, scriptLocation and scriptFullPath are available, no need to do the following
ExamplePlugin.instance = new ExamplePlugin(scriptPath);

// register our plugin with WDTVext
Plugin.registerPlugin(ExamplePlugin.instance);

traceln("Plugin.MediaFolder: End loading MediaFolder plugin");

All occurances of ExamplePlugin are of course to be substituted with the name of your plugin.

Page Control