TiviApp-related code, utilities and repository to be used by third-party developers
This GitHub page contains all the information you need for creating and managing your own TiviApp Content Provider. Here you will find:
If you are still not fimiliar with the TiviApp application, please visit our website or just download it from Google Play.
A Content Provider is basically a third-party piece of code (sometimes called a “plugin” or “addon”) that can provide usefull content for TiviApp users. This content can be either:
There are three types of Providers that are currently supported by TiviApp:
A Provider can be also viewed as a small server that handles various requests from the TiviApp client. Therefore your code should be designed and developed according to the following basic principles:
onDestroy
event.The simpliest way of getting started is to clone this repository and start exploring the demo projects. The following sections will guide you through the neccessary steps for getting the “Hello World” projects up and running on your machine. So use your favorite Git client to clone this repository at: https://github.com/montezumba/TiviAppDev.git
and let’s get started!
This type of provider is the most powerfull option and is best suited for Android Developers who wish to add some non-trivial logic that should be executed on a native environment. For this, you will need to have some knowledge on developing Android applications and the following environment set up:
After clonning the repository (for example to: C:\TiviAppDev), just follow these steps:
Each Content Provider is hosted on a repository (server for example), which is described by a special JSON file. TiviApp has one such repository embedded within the main application - the Official TiviApp Repository. If your Provider is not hosted there, the user should explicitly add your repository by providing the path to the corresponding JSON. (see below)
This type of provider is suited for quick and simple content providers (usually ones that already have a website or an IPTV server running). To setup a Web Provider you will need some basic knowledge in web development, specifically in javascript. A typical Web Provider consists of the following two files:
In the “HelloWorldWeb” project we have prepared three demo files to illustrate each type and how they are connected with one another:
To add this provider to TiviApp, just follow these simple steps:
In this section we will provide an overview the basic concepts of Provider Development. We assume here that you already cloned this repo and you know how to build and run the corresponding demo projects. The basic sequence is very simple:
If we explore the demo project we can see the observe the following source files:
The AndroidManifest.xml configuration files should be configured as follows:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
android:name="HelloWorldApplication"
<service android:name="HelloWorldService" >
<intent-filter>
<action android:name="com.treynix.helloworld.ACTION_ADDON_REQUEST" />
<action android:name="com.treynix.tiviapp.action.ACTION_PROVIDER_REGISTER" />
<action android:name="com.treynix.tiviapp.action.ACTION_PROVIDER_KILL" />
</intent-filter>
<meta-data android:name="playlist_support" android:value="true"/>
<meta-data android:name="tvguide_support" android:value="true"/>
<meta-data android:name="video_support" android:value="true"/>
In the HelloWorldConfig.java you should provide the basic configuration to your provider, based on the following base-constructor arguments:
public HelloWorldConfig() {
super( "Hello World Provider",
5 * Constants.MINUTES,
5 * Constants.MINUTES,
10,
HelloWorldConfig.class.getPackage().getName(),
null
);
}
WARNING: Setting too high values is not recommended. TiviApp has its own timeout mechanism, which will deactivate non-responsive providers. Each provider should detect and handle its own timeouts and errors.
The HelloWorldMain.java handles the main server logic by implementing the following interface methods:
onInit : handles the initialization event. In this method you should implement all the “heavy” logic for preparing and setting the data required for handling future requests.
onStart : handles the actual requests. Each new request will trigger this callback, so use the Worker
utility to handle requests asynchroniously.
onCancel : handles the case when the TiviApp client requests to cancel a previously sent request. It is important to use this callback in order to avoud sending irrelevant or outdated data.
onDestroy : used to clean-up resources (when needed) and to wrap things up.
WARNING: All these methods are blocking. Remember: you are implementing a server and the best practice here is to avoid “heavy” logic. However, if you do need perform some blocking operations - use the Worker
utility to allow parallel execution.
Working with Web Providers is much more simple. TiviApp has its own, built-in Android Provider that takes care of all the abovementioned configrations. This built-in provider transmits all the requests to third-party “virtual” providers by calling their Web Provider File URL and passing the applicable parameters.
TiviApp provides a WebView API framework to handle incomming events and provide the required outputs. This API can be accessed within your web application by using the TiviProvider
javascript object.
To handle incomming requests, the Web Provider File should check and parse the following GET parameters:
req
- specifies the request id. This value should be mirrored back to the client as part of the response callback.proc
- the requested procedure.The response should be sent back to the client by calling the following API methods:
TiviProvider.sendPlaylist(req, playlist_url)
- this will send a single playlist URL back to the TiviApp client. You can send several playlist URLs per request.TiviProvider.sendTvGuide(req, tvguide_rul, validity_days)
- this will send a single EPG URL back to the TiviApp client. You can send several EPG URLs per request.TiviProvider.done()
- this mandatory method must be called to indicate that you finished handling the current request (otherwise you provider will be considered as not responding by the TiviApp client).TiviProvider.reportError()
- use this method to report any errors back to the TiviApp client. Please note that it is still required to call the done
method afterwards to finish that handling of the current request.For both Android and Web Providers you may define a repository file to provide additional meta-data about it. Providing a Repository File is mandatory for Web Providers, since they are used as an input URL for the user that wants to add them to TiviApp.
The Repository File should have the following structure:
{
"addons":
[
{
"name":"Hello World Web",
"service":"https://montezumba.github.io/TiviAppDev/HelloWorldWeb/hello_world.html",
"author":"Treynix",
"description":"A demo Web Provider for demonstrating basic provider capabilities",
"version":"1",
"versionName":"0.1",
"path":"virtual",
"supportedFeatures": [
"playlist_support"
]
}
]
}
name
- the displayable name of this providerservice
- for Android Providers that would be the package name, for Web Providers that should point to the Web Provider URL on your server.author
- the displayable name of the author/owner of this provider.description
- this text will be displayed in the Providers settings page to describe your provider.version
- the version id of this provider. Should be a simple numeric (integer) id. Greater ids will be considered as newer versions.versionName
- the displayable version name. This can be a textual value describing your version numbering convention.path
- for Android Providers that should point to the update path for this application (usually a Play Store URL), for Web Providers you should state: virtual
supportedFeatures
- an JSON array that enumerates all the supported requests for this Provider.