Sponsored Links

Sponsored Links

Quickstart to PS3 Plugin Development in Showtime by Facanferff


Sponsored Links
38w 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):

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

Getting Started

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

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:

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:

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:

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

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:

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:

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:

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

Means this page is a directory to browse content.

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.

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

Function getVideoList:

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

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

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.

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

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.

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 547 Comments - Go to Forum Thread »

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

ooogz's Avatar
#547 - ooogz - 14w ago
Thanks for the update!

PS3 News's Avatar
#546 - PS3 News - 14w ago
Following up on the previous revisions, today PlayStation 3 developer Andreas Oman updated the Showtime PS3 Media Center to version 4.6.10 Stable Build with the changes outlined below.

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


mmanolos's Avatar
#545 - mmanolos - 14w ago
Anyone knows the difference between the standalone and the multiman's version?

I'm asking this because the standalone sometimes became corrupt and refuse to run so I have to reinstall or use the MM one instead.

PS3 News's Avatar
#544 - PS3 News - 14w ago
Following up on Showtime for MultiMAN and the recent Showtime Testing Builds, today PlayStation 3 developer Andreas Oman updated the Showtime PS3 Media Center to version 4.6.4 followed by v4.6.7, v4.6.8 and Testing Builds v4.7.35, v4.7.43, v4.7.116 and v4.7.145 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] / Showtime 4.6.10 ISO / Showtime 4.7 ISO (Cobra) by Mogwai

Showtime 4.6 Changelog:

General features

  • Icecast/Shoutcast radio streaming
  • Per-file and per-folder settings during video playback. Read more below.
  • Support for MPL subtitle format
  • Support for TMPlayer subtitles
  • Support for DVD Subtitle system (.txt) format
  • Improved and more robust parsing of SRT files
  • Improved start time when streaming over HTTP
  • Add audio test generator in Settings -> Audio. Good for testing that your surround speaker setup is correct.
  • Fix problems with various JPEG files.
  • Make it possible to turn off video frame linear interpolation. Traditionally Showtime have interpolated video frames to match display output. Some users find that this may blur the video a bit so this feature can now be turned off.
  • Store per-file settings directly in file system. Read more below.

Per-file and per-folder settings

During video playback the user can adjust per-file specific settings. These are:

  • Audio Volume (New in 4.6)
  • Audio/Video sync adjustment
  • Subtitle sync adjustment
  • Subtitle scaling
  • Subtitle alignment
  • Subtitle vertical displacement
  • Subtitle horizontal displacement
  • Video zoom
  • Video stretch to widescreen
  • Video stretch to full screen
  • Video frame interpolation (New in 4.6)

The settings are remembered per file so when you come back the configuration will be resumed. It's now also possible to apply the configuration to the entire folder. This means that any files loaded from that folder (including new ones) will also have these settings. The user can also apply the current settings as new global defaults.

If the files are located on a SMB/Windows share with write access the corresponding settings will be stored on the server. See below. Store per-file settings directly in file system using Extended Attributes.

Up until now, Showtime have stored per-file settings in an Sqlite database. These settings include things such as "Seen", "Resume position", "Selected subtitle", "Selected audio track" plus all the settings that can be configured during video playback (mentioned above).

Starting from 4.6 Showtime will now try to store these settings directly in the filesystem where the file is also located. It does this by storing the information as "Extended Attribute". This works if Showtime have write access to your SMB/Windows shares. This feature is default on and can be disabled in Settings -> General.

The real upside of this is that if you have multiple devices they will all share the "Seen status", "Resume position", and all other settings. Also if you re-install Showtime this information will be intact.

For details about Extended Attributes, please read: en.wikipedia.org/wiki/Extended_file_attributes

Internationalization

  • Add support for BIG5 character encoding
  • Add support for different On Screen Keyboard layouts.

Raspberry Pi specific changes

  • 8 channel PCM output over HDMI
  • Audio output on analog interface (configurable in Settings -> Audio)
  • Show chip temperature in system menu
  • Much improved video playback pipeline on Raspberry Pi.
  • Added support for more video codecs. The full list is: h264, h263, MPEG-4, VP6, VP8, MJPEG, Theora, MPEG2 (Require license), VC1/WMV3 (Require license)
  • Make system upgrade must more robust. Now it download all files first and write them to disk and then rename over the old ones in one go.

PlayStation 3 specific changes

  • Showtime now uses virtual memory (backed by HDD) on PS3. This should drastically reduce out-of-memory problems.
  • Show a notification if h264 profile/level restrictions is violated.
  • For example if a 1080p video use more than 4 reference frames.

Linux specific changes

  • VDPAU (Nvidia accelerated video playback) rewritten from scartch.
  • Now uses Nvidia's own VDPAU -> OpenGL texture functions. No more tearing on high resolution displays.

OS X specific changes

  • Improve VDA (Video Decoding Acceleration) integration. No longer copies decoded video frames back to CPU RAM. All video decoding and presentation now happens on GPU. Reduces power consumption.

Other changes

  • User interface now only redraws on demand (instead of every frame).
  • This greatly reduce CPU/Power consumption when application is idle.
  • Upgraded to libav 10
  • Over 150 bugs fixed. See showtimemediacenter.com/versions/58

Showtime v4.7.35 (Test Build)

  • ui: Trap "back" and "cancel" (escape) in popup requests
  • Don't deliver frames from demuxer thread. It might crash
  • Don't even send seek events to players that don't want to seek
  • Update fr_FR.lang
  • hls: Detect and filter out bad PTS timestamps …
  • Make it possible to use up/down keys during video playback to adjust per-file volume
  • linux/pulseaudio: Scale volume in Showtime instead of relying on pulse audio (Fixes problem with flat volume mode. i.e. Fedora11+)
  • fa/video: Avoid writing resume position if source cannot seek
  • rtmp/hls/fa: Log when we try to resume
  • Cleanup skip and seek handling a bit and better support live content
  • No longer display a progress bar for live content.
  • Disable seek on live content
  • For content where seek is disabled make skip to previous track do only that (no restarting)
  • htsmsg: Must check f->hmf_childs to know if there are childs or not
  • ui/videomenu: Store current page outsite loaded view so we can retain current page
  • Fix so we don't resume when we skip to next video in list (either due to EOF or user command): Also simplify the per-backend resume logic
  • Black out video if video_player enters error mode
  • glw: Route skip prev/next if video widget is focused
  • svg: Add support for "viewBox" tag …
  • Send suggestfocus to UI when we skip back/fwd between video items: This make sure the currently focused item is updated to the currently playing one
  • prop/nodefiler: Make prop_suggest_focus() work thru nodefilter
  • Don't show "Save as folder default" in video playback settings if we don't have a folder to play from media: Use setting_create() for separators do make sure they get destroyed, settings: Make it possible to create SETTING_SEPARATOR from setting_create(), navigator: Unlink currentpage when redirecting: This fixes problem with stale subscriptions that follows nav.currentpage
  • svg: Add support for 'fill' tag inside 'path' tag
  • svg: Add support for v,V,h,H path commands
  • Add support for probing SVG XML files as images
  • glw: Fix navigation to end of list in some cases
  • ftpserver: Make sure we bail out on invalid paths
  • smb/cifs: Fix race condition between thread during SMB connect
  • restructure xml parser
  • Don't release buffer when we shoudn't
  • htsmsg: Must initialize htsmsg_field to zero in htsmsg_binary_deserialize()

Showtime v4.7.36 (Test Build)

  • First version of a Duktape integration
  • Duktape is a EcmaScript (JavaScript) engine that I hope will replace Spidermonkey eventually.
  • So far much of the Showtime APIs are lacking when plugins run in this engine.

Showtime v4.7.43 Changelog:

  • httpclient: Rework Location header escape handling
  • ecmascript: Improve prop support:
  • Add support for subscriptions
  • Add support for pagination
  • httpclient: Escape improperly encoded redirect URLs
  • linux: Extract distribution from lsb_release and store in gconf.os_info
  • linux: Log more info about current system
  • ecmascript: Make it possible to get an array of all registered ecmascript contexts
  • upgrade duktape to v0.10.0-328-g41366e7
  • First version of a Duktape integration [4.7.36]

Duktape is a EcmaScript (JavaScript) engine that I hope will replace Spidermonkey eventually.
So far much of the Showtime APIs are lacking when plugins run in this engine.

Showtime 4.7.47 Changelog:

  • ecmascript/apiv1: Fix problem when no HTTP args are given
  • duktape: Add support for Array of query arg objects
  • duktape: Add support for searchers
  • htsmsg: Fix broken refcounts

Showtime 4.7.55 Changelog:

  • Fix build deps for debian targets
  • Add .doozer.json build control file
  • More autobuild fixes
  • More builddep fixed in Autobuild/
  • ps3: Need 'wget' to build
  • ps3: Add some missing build deps
  • ps3/autobuild: Force 'yes' when installing packages
  • ecmascript: Support tracking destroy and correct delete of subscriptions

Showtime 4.7.116 Changelog:

  • Add SOCKS5 proxy support: Currently only available as commandline option --proxy hostort
  • connman: If user wants to connect to a service, disconnect it first to avoid unresponsiveness
  • Fix broken if/else ladder
  • connman: Get rid of excessive g_variant_unref()
  • ps3: Reduce time we show 'Forcing level 4.2 for content...
  • linux: Fix broken keyboard input on newer (2013+) Linux dists
  • Fix buffer delay miscalculations for real
  • net: Improve TCP and HTTP debug
  • ecmascript: Make page.loading work
  • Fix use after free (buf_t) in subtitles
  • Fix broken buffer delay estimation when pts is unset
  • rtmp: Set correct duration
  • media: Don't clear audio stream unless it's set to off …
  • rtmp: Set correct mp_framerate
  • media: Fix a debug helper
  • sqlite: Don't log SQLITE_SCHEMA errors as sqlite retries automatically
  • Run up to four metadata queries in parallel: Previously we serialized all lookups. This makes the lookup 4x faster and lot less likely to "choke" on a broken request
  • Add some asserts in glw_image to track texture leakage
  • Upgrade duktape to v0.11.0-23-g4411a39
  • Get rid of an astray htsmsg_print()
  • Fix double tcp_close() in OpenSSL wrapper
  • OS X is more strict about what gets passed to connect()
  • Fix build error on mac
  • Fix build problems with clang
  • Keep broken toolchain builds
  • Another toolchain fix
  • Fix unused variable
  • ps3: New toolchain
  • Fix torrent URI scheme
  • torrent: Don't use redirects for torrent:movie:
  • ps3: Add support for fs_fsinfo()
  • torrent: Minor cleanup
  • media: Cancel on EVENT_EXIT
  • Don't handle ACTION_STOP in demuxer threads
  • Add a task helper
  • Move subtitle and audio track switching out from demux thread (This makes track switching almost instand if demux thread is blocked for long times)
  • async: Log callbacks that takes a long time
  • torrent: Handle corrupt data by retrying requests to different peers
  • torrent: Add bencode_serialize()
  • bittorrent: Add support for disk cache
  • torrent: Fix infinite loop problem
  • During shutdown, if shutdown failed after 5 seconds, force exit
  • Restructure networking code to be less #ifdef:y
  • bittorrent: Fix so it build on latest master
  • bittorrent: Make it possible to shutdown a torrent and cleanup all resources (in RAM)
  • asyncio: Fix various bugs
  • Improve bittorrent client (Split peer code to peer.c / Improve handling towards trackers)
  • Send have to peers even if they have it
  • bytestream: Fix incorrect return values
  • torrent: Send data
  • bittorrent: More work
  • fa: Add some IO stats during probing
  • fa: Add deadline fops
  • asyncio: Fix mem leak
  • Fix memory leak in fa_cmp, something only used for debugging purpose
  • media: Improve buffer stats
  • Add average rate helper
  • torrent: wip
  • asyncio: Fix NOSIGPIPE on osx + various timeout related stuff
  • htsmsg: Make it possible to read string as binary
  • bittorrent: wip

Showtime 4.7.145 Changelog:

  • bittorrent: Add directoy scanning to bittorrent
  • Add hex2binl - specify max chars to scan
  • fa_scanner: Assume .wav files are CONTENT_AUDIO
  • vda: Fix fallout from queue.h refactoring
  • prop: Fix fallout from atomic refactoring when PROP_DEBUG is defined
  • posix/threads: Fix missing include of sys/time.h
  • Fix atomic ops on Apple based systems
  • js: Don't take address of variable that goes out of scope
  • ziptail.c: Use HTS_MUTEX_DECL to initialize a mutex
  • compiler.h: Make sure we're included at most once
  • Replace off_t with int64_t
  • Remove unnecessary include of unistd.h
  • Remove ranges from switch/case statements
  • Various MSVC fixes
  • Remove unused htsbuf_dump_raw_stderr()
  • queue.h: Don't use typeof() in queue.h
  • win32: Wrap snprintf() and make __builtin_constant_p a dummy
  • win32: Fix atomic_dec
  • Use ##__VA_ARGS__ for variadic macros
  • isolang: Remove unused include
  • Portable designated initializer
  • prop: Use portable variadic macros
  • event: Don't have zero sized array in event_t: MSVC can't handle embedding event_t in other structs when it ends with a zero sized array
  • Convert 'inline' to '__inline'
  • win32: Build fixes
  • win32: Fix atomics
  • Rework atomic implementation: Use atomic_t instead of a naked int
  • Move GCC specific things into #ifdef:ery
  • win32: Some initial fixes to make a few files compile

More PlayStation 3 News...

zazoon's Avatar
#543 - zazoon - 27w ago
Sorry not testing builds for now. Only Bleeding Edge: showtime-gh-4.5.106.pkg is on showtime site.

Test version is still linking stable version: showtime-gh-4.4.pkg.

With regards

Sponsored Links

Sponsored Links
Sponsored Links

Sponsored Links