Sponsored Links

Sponsored Links

Quickstart to PS3 Plugin Development in Showtime by Facanferff


Sponsored Links
52w ago - Following up on the previous update, today PlayStation 3 developer facanferff has made available a Quickstart to PS3 Plugin Development in Showtime with details below.

To quote: Since a long time ago, some users have requested me to write a tutorial so they could create their own Showtime plugins. This is an initial attempt to it, I hope you like. If I make some mistake, I'm sorry, I'm not a teacher.

Overview

Before we get our hands dirty, it’s important to explain some little things that might help you later in making your own plugins. Plugins for Showtime (also known as Apps) are exclusively written, at the moment, in Javascript. To bring plugins to life, Showtime uses a Javascript engine called Spidermonkey (as of now, Showtime uses Spidermonkey 1.8.0-rc1). To learn more about this engine, you may go to developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey.

If you ever did web development, you may wonder if the Javascript API that work in normal web browser might work here, well, the answer is no. Due to this, you will not find things like DOM or AJAX in your toolbox, but you may and should use the basic Javascript.

In this quickstart, I will assume the reader has good understanding of Javascript. If you don’t know it, you may check the several resources available online/offline. From these, I recommend check this: codecademy.com

The Showtime plugins’ job is to respond to browse and search requests and populate the internal data model with the actual information to be shown to the user via Showtime’s user interface(s).

Since there are different types of plugins, I will focus in this tutorial in only a type, plugins that browse content in the web and show it to user (e.g. Youtube plugin).

Structure of a plugin

Every plugin lives in a directory of their own. From the several files this directory may have, you need to have at least one file in the root of the plugin, plugin.json, which contains information about the plugin and the author. You may use sub-directories and custom names for other files in order to organize it better.

plugin.json

plugin.json is a JSON (json.org) encoded text file containing information about the plugin and its author. Example of a plugin.json file (from the Channel9 plugin):

[Register or Login to view code]

Now it’s time to learn more about each field and which ones are required for every plugin:

[Register or Login to view code]

Getting Started

To run a plugin in a development environment, you may call from a terminal:

[Register or Login to view code]

The flag –p means that you want to load a plugin in development environment.

If you ran this already, you might get the following error: This will output something like: plugins [ERROR]: Unable to load development plugin: testplugin Unable to load testplugin/plugin.json -- File not found. This means or we don’t have a testplugin directory or we don’t have a plugin.json inside it. To create the directory do:

[Register or Login to view code]

Now, to edit the plugin.json, open the file testplugin/plugin.json in any text editor that you like.
In there, let’s make our initial plugin.json:

[Register or Login to view code]

With this, we specified that the plugin testplugin uses Javascript engine, has an ID ‘testplugin’ and the script is ‘testplugin.js’.

Whenever you want to reload the plugin you can use Shift+F5 in Showtime. This is helpful when you make changes to a plugin already in development environment inside Showtime, without the need of restarting Showtime. Even if the plugin gave an error, you may use this to try to reload it. When you reload it, all hooks and resources associated to the plugin are removed. This phenomenon happens also when a user removes a plugin from Showtime.

In case you are already in a page that belongs to the plugin itself, Showtime will reload the plugin and reload the page itself.

Now open your testplugin/testplugin.js in a text editor. Since we want to have a plugin that lives forever (so it can be called anytime) we need to have a scope where all local variables will live and also need to remember ‘this’ which is, when the script is invoked, a plugin object created by Showtime itself (showtimemediacenter.com/projects/showtime/wiki/JSAPI_plugin).

So, let’s edit this file:

[Register or Login to view code]

Reload the plugin now with Shift+F5, if you look in the terminal windows from which you opened Showtime, you will find a line saying ‘Hello, Showtime XXX’ where XXX is your current Showtime version that was obtained via showtime.currentVersionString .

Routing an URI to the plugin

Since our plugin will respond to browse requests we need to have an URI associated to it. An URI is something like a URL you use to browse the Internet, but in this case it is used to browse in Showtime. Every plugin reservers URI space starting with the plugin’s ID specified in plugin.json. These URI routes registered by plugins have higher priority than URI routes that Showtime itself handles, so you can create an URI route like it is in a web browser (e.g. youtube.com)

With this new knowledge let’s make it in use (edit it to match this code):

[Register or Login to view code]

Now, reload the plugin and if you type “testplugin:hello” in the search input field on Showtime’s home page, you will notice Showtime will open a new page with only a loading symbol, but in the terminal it will show the message provided to showtime.print.

A look in a real plugin

For this tutorial, I decided to use a real plugin made by me, which is called Videocopilot. The plugin source is located at github.com/facanferff/showtime-plugins/tree/master/videocopilot and its a plugin for Web site videocopilot.net.

I will not discuss the plugin.json of the plugin ([Register or Login to view links]) in this tutorial.
The lines of code or numbers of line are relative to version 0.9 (the most updated version at this moment).

Lets see then the plugin script (github.com/facanferff/showtime-plugins/blob/master/videocopilot/videocopilot.js).

To make Showtime provide a link in home page to the plugin’s start page we need to create a service:

[Register or Login to view code]

Lets check each argument given to plugin.createService:

  • 1st: “Video Copilot” is the display name of the service
  • 2nd: PREFIX (which is a global variable specified as “videocopilot” + “:start” is the initial route of the service (the URI where is located the home page of the plugin)
  • 3rd: “video” tells Showtime this plugin provides video resources
  • 4th: true means the service should be enabled immediately, making it visible to user and
  • 5th: plugin.path (gives you the full path to the plugin’s root directory) + “logo.png” is the path to an image that identifies the plugin.

Since we registered the home page’s URI route, we need to specify what does that URI route:

[Register or Login to view code]

Here, plugin.addURI registers a new URI route, in this case called “videocopilot:start” and startPage is the function to be called when this route is open by user request. The function provided to addURI should accept at least one argument, where the 1st one is a page object created by Showtime and used to manipulate the page.

function startPage:

[Register or Login to view code]

Here, page.appendItem will append a new item to the current page. Lets see the arguments:

  • 1st: PREFIX + ':browse:' + escape('http://www.videocopilot.net/tutorials/') + ':undefined' , is the URI route that should be called when the user clicks this item
  • 2nd: type of item, from the several ones, the most used are: directory, used to specify this item will open a new page to browse contents; and video that specified this item will open a video resource
  • 3rd: metadata for the item, you may provide any information about this item as you want. The most used are: title, title of the item; icon, image to be shown associated to the item; description, a description of the item

[Register or Login to view code]

Means this page is a directory to browse content.

[Register or Login to view code]

Tells Showtime that the contents of this page are “items”, in most cases, you want to use this one, we will use it for this tutorial.

[Register or Login to view code]

Tells Showtime that we don’t want anymore the loading symbol to be shown to user.

Function getVideoList:

[Register or Login to view code]

Here, showtime.httpGet is a function you may call to do a GET request to a page (e.g. to obtains its source code) and .toString() is to convert its response to a Javascript String to manipulate.

plugin.addURI(PREFIX + ":video:simple: (.*)", function(page, link):

[Register or Login to view code]

This is a Javascript object where we specify only the title of a video (displayed in video playback) and sources is an array where each object contains at least the url (e.g. the video’s url).

[Register or Login to view code]

Here, page.source is the way to tell Showtime what we want to reproduce. Since we want to play a video we need to put always “videoparams:” before the parameters of video as specified before encoded in a JSON string.

[Register or Login to view code]

This finally tells Showtime we have a video, so Showtime can handle everything to prepare video playback.

[Register or Login to view code]

This function is used to add continuously items to a page. In the current version of the tutorial, I will not explain this, so whenever you want to show more items (e.g. of a second page) use page.appendItem and pass what you need.

[Register or Login to view code]

This function adds a searcher to Showtime that can be used when a user searches for something (not a URI route) in search input field in Showtime’s home page. This function accepts 3 arguments:

  • 1st: title of the searcher, shown to user when searching something
  • 2nd: image of the search, also shown to user
  • 3rd: function that receives a page and query arguments (page is the same as specified before in the tutorial and query is a string containing what to search). This function is runs always whenever a user searches for something.

Note: In the function passed to plugin.addSearcher you need to specify somewhere the number of found entries via page.entries, otherwise Showtime will not show your searcher to user for that query.

I recommend you study carefully the code at: github.com/facanferff/showtime-plugins/blob/master/videocopilot/videocopilot.js

Publishing plugins

You may check showtimemediacenter.com/projects/showtime/wiki/SPMC for all details about it.

Bibliography

showtimemediacenter.com/projects/showtime/wiki/PluginDevelopment (maintained by Andreas Oman (andoma), Fábio Ferreira (facanferff) and Leonid Protasov (lprot))

Thanks

andoma: for creating Showtime

Final notes

I hope, you learned a little about plugin development in Showtime with this small tutorial. This tutorial is far away from being finished, I just wanted to give you an initial overview to the process of creating plugins for Showtime.

With a look in a real plugin, I believe you have now the fundamental tools to study better existing plugins and create new plugins. Whenever I can, I will try to update this tutorial to make it more complete and easier to understand.

For a reference of the functions Showtime provides I recommend you check showtimemediacenter.com/projects/showtime/wiki/JSAPIREF

And to conclude I leave here a screenshot of plugin TMDb so you can see the potential you can get from a plugin (below).

I hope you liked, facanferff.






Stay tuned for more PS3 Hacks and PS3 CFW news, follow us on Twitter and be sure to drop by the PS3 Hacks and PS3 Custom Firmware Forums for the latest PlayStation 3 scene updates and homebrew releases!

Comments 556 Comments - Go to Forum Thread »

• Please Register at PS3News.com or Login to make comments on Site News articles. Thanks!

myjunkhurts's Avatar
#526 - myjunkhurts - 90w ago
sweet update

matrixreaver's Avatar
#525 - matrixreaver - 90w ago
Is it normal for most of the online movies to skip a lot when watching them on the PS3 thru say like Navi?

PS3 News's Avatar
#524 - PS3 News - 93w ago
Not long after the last Stable 4.2 Build, today PlayStation 3 homebrew developer Andreas Oman has updated the Showtime PS3 Media Player Testing Build to version 4.3.21 followed by 4.3.41, 4.3.207, 4.3.227, 4.3.228, v4.3.263 and v4.3.313 with the changes outlined below.

Download: [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links] / [Register or Login to view links]

4.3.536

HLS: Fix crash when HLS streamer encountered corrupt streams
glw/video: Remove unused fields
glw: Add a simple grid widget
glw: Tentative support for requested aspect during image load
hls: Keep track of h264 profile and level
Add 'Exit to Standby' in Settings -> General

4.3.515

Always upgrade using patches on platforms that support it
Fix build break
hls: If streaming live, never try to resume last position as it just screw things up
hls: Respect playback priority
rpi: Various OMX fixes to hopefully avoid some hangs

4.3.509

Make 'force screensaver' work again
rpi: Avoid getting stuck in hw accelerated image decoder if image is corrupt
ssa/ass: WIP on encoding detection
glw: Reduce memory footprint my rearranging struct members

4.3.486

Update pl_PL.lang
rpi: Avoid crash when video ends

4.3.482

Make subtitle font setting actually work.
Fix broken browsing. Right pane in UI did not update correctly because URL was not set in fontstash model.
Fix problem making subtitle scanner crash if it found a file without file ending.

4.3.478

rpi: Rework seeking code to be more stable (hopefully)
rpi: Do MPEG-4 part 2 and h263 in VideoCore

4.3.475

FTP-server: Add delete,rmdir,makedir,rename support
Check for showtime upgrades daily
rpi: Fix showtime exit problems

4.3.459

Make it possible to set path to persistent storage (settings)
Add libyuv revision 775
Fix broken save of multiopt settings in javascript …

4.3.443

Fix crash when deleting exported bookmarks …
Update language files: fr_FR.lang and ru_RU.lang
Add subtitle support when playing HLS
osk: Make ESC exit on screen keyboard
Fix typos in displayed strings

4.3.417

Add FTP server support. Can be enabled in Settings -> Network settings
Update ru_RU.lang
Fix problem with underscan settings. Recent regression. Fixes #1727
ps3: Fix mutex init problems

4.3.386

Fix issues with list wrapping and pagination
Detect command to compute sha1
Initial work of building for Android

4.3.375

Fixes issue when, in external subtitles, new overlays appear before all previous overlays have disappeared (Fixes #1723)
Fix broken handling of permanent redirects
Keep navigator when closing window

4.3.372

Fix: No default value was set after the rewrite of the setting system (Fixes #1722)
Improve charset decoding: Add new codepages 1254, 1257 and 1258
Refresh language files
Rename setting 'Userinterface size' to 'Font and icon size'

4.3.366

multiopt: Do the right thing if current options is deleted.
Fix recent regression for HEAD requests
Make (cancel) work in Showtime's own OSK

4.3.356

Add 'Mark all as seen' and 'Mark all as unseen' in page menu …
Rework Showtime's HTTP client …
skin: Rework how background image is set
Add missing mutex lock
Remember set video/audio/subtitles playback settings for each video.

4.3.313

subtitles: Get canvas dimensions from codec context

4.3.312

When deleting RAR file, delete all files in multivolume archive

4.3.311

ps3: Select + Square starts screen saver Add option to enter system standby after current video ends
Update portuguese translation
ps3: Make it possible to configure seeking using L2/R2 Allow user to adjust position of subtitles from video playback menues

4.3.301

Disable binary patches on ps3
Update rusian and chinese translations
Make cache resilient to clock going backwards

4.3.30

Add multi language support to TheTVDB integration

Fixes #1544

4.3.291

Update Polish, German and Swedish translations
Add support for Windows code page 1256
Fix broken PNG decoder for rpi
HLS: Fix playcount and resume position
On tiled home page, only show enabled services. Fixes #1568

4.3.279

Fix an issue with subtitle scanning
This might fix some recent crashes people have seen when Showtime scans for subtitles Fixes #1715 (maybe)

4.3.263

No longer ignore 'The' prefix when sorting. The old behavior can be re-enabled under Settings -> Languages

4.3.230

Add confirmation when just deleting one file as well

4.3.228

Add support for recursive delete of files. Also, in case when deleting a directory, ask user for confirmation

4.3.227

Add support for deleting files and empty directories over SMB Fixes #1062

4.3.226

Support deleting directories (and not only files) Refs #1062

4.3.225

Make sure we count video as played if we reach 100% of playback

4.3.223

Add support for deleting files. This currently only works for local file systems and must be enabled in Settings -> General

4.3.21

Fix recent regression causing vertical lines in images on PS3

Fixes #1617

4.3.207

Fix bug making 'Refresh metdata...' option in item menu not to work at all

4.3.206

Avoid loading .mkv attachments into RAM

Instead we keep a reference to where in the MKV file the attachment is located and we can later open a slice of the mkv-file as the attachment.

This combined with the fact that freetype can open fonts from a file handle reduces the static memory use for attachments to 0 bytes

Fixes #1689 (out of memory (av error -12) with certain MKV files)

4.3.203

Initial attempt of a built-in FTP client in Showtime

To use it enter 'ftp://ip.address.of.ftpserver' in search bar or create a bookmark (much like the CIFS/SMB client)

Note that the code has only been tested against a few FTP servers so it's probably still buggy. If you find any problems and want to report please turn on "FTP logging" in settings:dev and include the logfile in ticket.

4.3.20

Add support for sorting on filename and date when browsing over UPNP

4.3.199

upnp: Include video playback URL in canonical URL

Fixes problem with UPNP servers that just give sequential numbers to directory items. If just using the URL items would be confused with other items if video are removed from the directory

Fixes #1697

4.3.196

Add Danish translation

4.3.189

Fix bug that caused "Custom search query" to disappear for video items

Fixes #1696

4.3.188

Fix a bunch of memory leaks

4.3.17

Make sure metadata scanner stops when we leave a directory

Also fix possible crashes related to those occations
Fixes #1601

4.2

ps3: Remove "/dev_hdd0/tmp/turnoff" before shutting down system

Fixes #1594

4.1.480

Fix broken colors in VOBSUB

Fixes #1579

4.1.479

Fix regression causing crash with embedded DVD/VOBSUB tracks

Fixes #1577

4.1.477

httpclient: Fix a regression when using range queries to determine filesize

Caused problems with minidlna (possibly other servers)

Fixes #1576

4.1.470

Fix the oversized album art during music playback

4.1.456

ps3: Fix video stuttering in some high bitrate video streams

4.1.454

Fix broken date-sorting (Allow user to sort on newest or oldest first)

Fixes #1297

4.1.451

Rework subtitle scheduling

This allows us to pick subtitles that are out of sync with video stream. Also makes it possible to do negative subtitle time shifting for embedded subs

Fixes #727
Fixes #1470

4.1.445

ps3: Increase audio buffer size

Fix stuttering playback with some audio formats (APE is one)

Fixes #1451

4.1.441

Fix problem that caused picture stuttering in some movies after 20-25 minutes

Fixes #1483

4.1.427

Add support for LPCM in DVD playback

Fixes #1046

4.1.422

Add movie chapters support where supported by file formats

Chapters can be found in menu during video playback next to seek thumbnails and audio/subltitle tracks

Fixes #786

4.1.414

Fix broken seeking in FLAC files

Fixes #1435

4.1.404

Add support for subtitle plugins. This also removes the built-in support for opensubtitles. Opensubtitles is now available as a plugin. No username + password is needed as opensubtitles.org allows anonymous logins

4.1.401

The list of subtitles are now sorted based on user preferred languages

4.1.398

Fix a bug that made "Custom query" impossible to erase in the metadata editor. It would come back next time the item was scanned

4.1.397

Fix a crash that was caused by invalid markup tags in SRT files

Typically this would happen if the SRT file contained a subtitle entry with just one tag that was invalid. Now such invalid tags will be presented as normal text instead.

Fixes #1501

4.1.394

ps3: Fix a crash on PS3 when playing AAC HEv2 files. This was caused by too small stack for the threads

Fixes #1515

4.1.387

Fix recently introduced crash in opensubtitles.org module

4.1.386

Add stretch-to-widescreen and stretch-to-fullscreen as options during video playback

Fixes #1334

4.1.383

Add support for getting metadata from thetvdb.com

4.1.382

Allow user to adjust subtitle timing ±10 minuts in increments of 0.5 seconds

4.1.380

Improved support for opensubtitles.org

Showtime will now search in opensubtitles.org database using the movie title and optionally the IMDB ID if it manages to resolve that

To limit the number of returned results it will only include the subtitles that matches the languages configured in Settings -> Languages.
If no such configuration has been entered all results will be displayed.

4.1.373

ps3: Sign pkg files to work with 4.xx CFW

4.1.372

Fix some issues related to mono audio in videos

4.1.371

Use external metadata (TMDB, etc) for video title in video OSD

4.1.369

Avoid doing external metadata lookup for very short file names

4.1.321

Add support for playback of HLS (Http Live Streaming) URLs

4.1.301

Add support for user configurable fonts

To install and use a new font put the font someplace where Showtime can browse it. When clicking on the font Showtime will what you want to use the font for. Showtime will copy the font to an internal storage location. To select between installed fonts or to reset to default, go to Settings -> Look and Feel -> Fonts

More PlayStation 3 News...

Mtealo's Avatar
#523 - Mtealo - 93w ago
Short answer NO. You need CFW and will get banned if you play online.

sticky876's Avatar
#522 - sticky876 - 93w ago
Hi everyone, I'm new to play station 3 but I love online gaming, I also love watching movies but what I want to know is. Can I install showtime/navi-x on my ps3 slim & still be able to receive updates from playstation, access psn & online gaming? I don't want to install showtime/navi-x & lose the ability to upgrade & play online.

Please let me know. Thank you.

Sponsored Links

Sponsored Links
Sponsored Links

Sponsored Links







Advertising - Affiliates - Contact Us - PS3 Downloads - Privacy Statement - Site Rules - Top - © 2014 PlayStation 3 News