Introduced in NextPVR v2.3.6, the 'touch' web service is an experimental feature to allow 'remoting' of the NextPVR user interface using a standard HTTP connection.

This page is to explain a little about how it works and is aimed mainly at those who want to create their own clients for smartphones, tablets and other remote devices.

The details here are fairly basic at the moment but if you understand how to work with HTML, Javascript and jQuery you shouldn't have a problem. I understood little about this stuff a few weeks ago and somehow 'volunteered' myself to rework Sub's initial version (learning a great deal along the way). :D

Using the service

Access to the service is through NextPVR's built-in web service using a URL in the following format...

Files

The relevant files are found in the NextPVR 'data' folder under \web\touch

The following files can be left as they are:
client.html - General purpose 'main' entry point for all types of browser clent
jquery-1.7.1.min.js - The official distribution of the minified jQuery v 1.7.1 file
jquery.wipetouch-1.1.0-mod.js - Modified version of the WipeTouch Javascript plugin
Files most likely to be modified:
nextpvr.touch.wipetouch.js - Helper functions for client.html to interface with the jQuery WipeTouch plugin
nextpvr.touch.common.js - Common functions for all client browser types
nextpvr.touch.generic.js - Functions used by generic browsers (see Client Types below)
nextpvr.touch.android.js - The same functions as above but which act in an Android specific way (see Client Types below)

How it works

The 'touch' client is served by an instance of NextPVR.exe in the same way as MVPs / NMTs are served. The key part is an HTML <img /> element which is updated at each key-press, mouse-click or touch-screen action. The first image is retrieved in client.html as follows...

<div id="BasicDemo" >
<img id="nscreen" />
</div>
<script type="text/javascript">setImageSource()</script>

The setImageSource() function is part of nextpvr.touch.common.js which in turn calls the relevant function in the 'client type' javascript file.

The code for subsequent image updates can be found in the different Javascript 'client type' files and also the nextpvr.touch.wipetouch.js file.

Touch-screen fundamentals

The service uses a jQuery plugin called WipeTouch. The NextPVR \web\touch distribution includes a version which I modified to provide customisable click / double-click functionality (nextpvr.wipetouch-1.1.0-mod.js).

To change the click / double-click parameters, modify the nextpvr.touch.wipetouch.js plugin with the parameters used to initialise the WipeTouch plugin (values in milliseconds)...

$("#BasicDemo").wipetouch( {
...
maxClickDuration: 400,
minDblClickDuration: 1000,
maxDblClickDuration: 2250,
...
});

Playing media and watching Live TV

After each 'click' or 'double-click' or Enter key-press, the Javascript needs to use the following URL to see if there is any further action to take with respect to streaming media or playing Live TV...

The response string will either be empty (CR/LF only) or will provide a URL stub to append to the server/port as an HTTP GET request in order to stream. The responses are commented in the 'client type' Javascript files and will be one of the following.

/transcode...

or

/stream...

These will also need to be appended to the server/port URL and passed to a media player. The 'transcode' is for Live TV and 'stream' is for Music, Recordings and Videos.

Client types

In order to separate platform specific behaviour, I opted to create individual Javascript files with a naming convention as follows...

nextpvr.touch.<client-type>.js

Each of these platform specific files should implement the same functions (even if they do nothing).

At the time of the release of NextPVR v2.3.6, files are included for 'generic' and 'android' platforms.

In order to support other platforms, the current mechanism is to examine the User-agent part of the first HTTP request to try to identify a unique string.

The 'generic' version should work with standard PC browsers for demonstration purposes although streaming and Live TV will NOT work.

For an Android app to use for testing, search the Android Market for ntouch nextpvr. Please note it is experimental and provided for demo purposes only. To play audio/video you will need suitable 3rd party apps installed on your device. I'll be providing source code as an example for any other Android developers to use freely ASAP.

Skin

As the clients may be 'small screen', there is an option in the NextPVR config.xml file to provide a separate skin to allow customising the UI.

<WebClientSkin>Touch</WebClientSkin>

I've made a copy of the default skin with a few modifications for small screens. Download:Touch.zip

Page last modified on October 09, 2016, at 05:50 PM