Get Started

The following sections (which appear in this document) will help you set up your development environment and use the TVPage Android Player API:

  • The instructions for Obtaining the Developer Key, explaining how to register your account in the TVPage console and to obtain an developer key, which you will need in order to use the API.
  • The Setup Instructions explain how to set up an API project using Android Studio.
  • The API Functions explain how to call TVPage APIs.
  • The JavaDoc Reference provides detailed definitions of the API's interfaces, classes, methods, and enums.
  • The Sample Application overview describes the sample applications included in the API download.

Android SDK: The SDK is currently being updated. The new version will be released in Q2 2019. This section will be populated with an updated URL once complete.

Android SDK Example Application: https://github.com/tvpage/sdk-android-example-app

Obtaining the Developer Key

You need to register your account to be able to use the TVPage Android Player API. The following steps explain how to register your account and obtaining the developer key.

  1. Access your account from https://app.tvpage.com.
  2. After successful login or register, go to TVPage developers page.
  3. In the top bar, you can see ACCOUNT ID. This is your developer key.
  4. You can access API Documentation here.

Setup Instructions

To always build from the latest commit with all updates, add the JitPack repository:

repositories {    maven { url "https://jitpack.io" }}

And the dependency in app’s build.gradle file :

compile '<dependency-url-need-to-be-added-here>'

Create application class in your project and add below code to initialise TVPage Player :

TvPageInstance.getInstance(this).setApiKey("<your-developer-key-here>");

To use TvPagePlayer in XML use below code snippet. Provide height to the player view in dp : 

<com.tvpage.lib.view.TvPagePlayer

   android:id="@+id/tvPagePlayer"

   android:layout_width="match_parent"

   android:layout_height="" />

In java file, initialise TvPagePlayer with TvPageBuilder functions as below :
//initialize view

TvPagePlayer tvPagePlayer = (TvPagePlayer) findViewById(R.id.tvPagePlayer);

//JSONOBject for custom controls settings

JSONObject jsonControlsToPass = new JSONObject();

//JSONOBject for seekbar progress color

JSONObject seekbarObject = new JSONObject();seekbarObject.put("progressColor", "#FFFFFF");

//JSONOBject for enable/disable analytics

JSONObject analyticsObject = new JSONObject();
analytics.put("tvpa", "true");

//set ”active” to enable/disable video controls 

jsonControlsToPass.put("active", "true");
jsonControlsToPass.put("seekbar", seekbarObject);
jsonControlsToPass.put("analytics", analyticsObject);

//set builder

TvPageBuilder tvPageBuilder = new TvPageBuilder(tvPagePlayer).

       setOnVideoViewReady(new TvPageInterfaces.OnVideoViewReady() {

           @Override

           public void OnVideoViewReady(boolean isVideoLoaded) {

               //TvPagePlayer ready callback

           }

       }).

       setOnVideoViewError(new TvPageInterfaces.OnVideoViewError() {

           @Override

           public void OnVideoViewError(String error) {

               //TvPagePlayer error callback

           }

       }).

       setOnMediaError(new TvPageInterfaces.OnMediaError() {

           @Override

           public void OnMediaError(String error) {

               //TvPagePlayer media error callback

           }

       })

       .setOnMediaReady(new TvPageInterfaces.OnMediaReady() {

           @Override

           public void OnMediaReady(boolean isMediaReady) {

               //TvPagePlayer video ready callback

           }

       }).setOnMediaComplete(new TvPageInterfaces.OnMediaComplete() {

           @Override

           public void OnMediaComplete(boolean isMediaCompleted) {

               //TvPagePlayer video completed callback

           }

       }).setOnVideoEnded(new TvPageInterfaces.OnVideoEnded() {

           @Override

           public void OnVideoEnded(boolean isVideoEnded) {

               //TvPagePlayer video end callback

           }

       }).setOnVideoPlaying(new TvPageInterfaces.OnVideoPlaying() {

           @Override

           public void OnVideoPlaying(boolean isVideoPlaying) {

               //TvPagePlayer video playing callback

           }

       }).setOnVideoPaused(new TvPageInterfaces.OnVideoPaused() {

           @Override

           public void OnVideoPaused(boolean isVideoPaused) {

               //TvPagePlayer video paused callback

           }

       }).setOnVideoBuffering(new TvPageInterfaces.OnVideoBuffering() {

           @Override

           public void OnVideoBuffering(boolean isVideoBuffering) {

               //TvPagePlayer video buffering callback

           }

       }).setOnMediaPlayBackQualityChanged(new TvPageInterfaces.OnMediaPlayBackQualityChanged() {

           @Override

           public void OnMediaPlayBackQualityChanged(String selectedQuality) {

               //TvPagePlayer video quality changed callback

           }

       }).setOnSeek(new TvPageInterfaces.OnSeek() {

           @Override

           public void OnSeek(String currentVideoTime) {

               //TvPagePlayer seek callback

           }

       }).setOnVideoLoad(new TvPageInterfaces.OnVideoLoad() {

           @Override

           public void OnVideoLoad(boolean isVideoLoaded) {

               //TvPagePlayer video loaded

           }

       }).setOnVideoCued(new TvPageInterfaces.OnVideoCued() {

           @Override

           public void OnVideoCued(boolean isVideoLoaded) {

               //TvPagePlayer video cued

           }

       }).setOnReady(new TvPageInterfaces.OnReady() {

           @Override

           public void OnPlayerReady() {

               //TvPagePlayer ready call back

           }

       }).setOnStateChanged(new TvPageInterfaces.OnStateChanged() {

           @Override

           public void OnStateChanged() {

               //TvPagePlayer state changed callback

           }

       })

       .setOnError(new TvPageInterfaces.OnError() {

           @Override

           public void OnError() {

               //TvPagePlayer error callback

           }

       })

       .controls(jsonControlsToPass)

       .size(0, 0).initialise();

//call loadVideo function to load and play video

tvPagePlayer.loadVideo(“”, string_reponse_from_video_api);

API Functions

In the java file, you can call the API functions as per below :

Get a Channel’s Videos

tvPagePlayer.tvPageChannelsVideosExtractor(channel_id,page_number,number_of_result, string_to_search, new OnTvPageResponseApiListener() {

           @Override

           public void onSuccess(TvPageResponseModel tvPageResponseModel) {

              //success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();

           }

           @Override

           public void onFailure(Throwable throwable) {

//failure callback

             throwable.printStackTrace();

           }

       });

Get a Video’s Products

tvPagePlayer.tvPageGetVideoProductExtractor(video_id, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get all Videos

tvPagePlayer.tvPageGetVideoExtractor(String login_user_id, page_number, number_of_result, orderByDate, orderDESCorASC, stringToSearch,status, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get a Video’s Channel

tvPagePlayer.tvPageGetVideoChannleExtractor(video_id, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get Single Video Details

tvPagePlayer.tvPageGetSingleVideoExtractor(video_id, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get Video’s Page Transcriptor

tvPagePlayer.tvPageTranscriptVideoExtractor(video_id, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get a Video using a Search Keyword

tvPagePlayer.tvPageVideoSearchExtractor(search_keyword, new OnTvPageResponseApiListener(){

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get a Video using referenceId

tvPagePlayer.tvPageVideoReferenceIdExtractor(reference_id_comma_seprated, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success reponse

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get all Product List

tvPagePlayer.tvPageProductExtractor(new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get Single Product Detail

tvPagePlayer.tvPageProductSingleExtractor(product_id, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get a Product’s Video Recommendations

tvPagePlayer.tvPageProductRecommendNetworkExtractor(product_id,

new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get a Product’s Video List

tvPagePlayer.tvPageProductVideosExtractor(product_id, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get a Channel List

tvPagePlayer.tvPageChannelsExtractor(new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Get Channel Information

tvPagePlayer.tvPageChannelsInfoExtractor(channel_id, new OnTvPageResponseApiListener() {

   @Override

   public void onSuccess(TvPageResponseModel tvPageResponseModel) {

//success response

JSONArray jsonArray = tvPageResponseModel.getJsonArray();      

   }

   @Override

   public void onFailure(Throwable throwable) {

//failure callback

       throwable.printStackTrace();

   }

});

Product Impression Analytics API

tvPagePlayer.analyticsProductImpressionApi(Integer.parseInt(channel_id),

       Integer.parseInt(video_id), Integer.parseInt(product_id));

Product Click Analytics API

tvPagePlayer.analyticsProductClickApi(Integer.parseInt(channel_id),
Integer.parseInt(video_id), Integer.parseInt(product_id));

JavaDoc Reference

This contains all the interfaces and classes of the TVPage Android Player API.

TVPagePlayer

Public final class TvPagePlayer extends RelativeLayout

A view for displaying TVPage videos.

Public Constructors :

TvPagePlayer(Context context)

Create a YouTubePlayerView.

`TvPagePlayer(Context context, AttributeSet attrs)

Create a YouTubePlayerView.

TvPagePlayer(Context context, AttributeSet attrs)

Create a YouTubePlayerView.

TvPagePlayer(Context context, AttributeSet attrs, int defStyle, int defStyleRes)

Create a YouTubePlayerView.

Inherited Methods :

> From class android.view.ViewGroup

> From class android.view.View

> From class java.lang.Object

> From interface android.view.ViewParent

> From interface android.view.ViewManager

> From interface android.graphics.drawable.Drawable.Callback

> From interface android.view.KeyEvent.Callback

> From interface android.view.accessibility.AccessibilityEventSource

Public Methods :

Load video

public void loadVideo(String murlToPlay, String jsonObjectResult)

Cue video

public void cueVideo(String murlToPlay, String jsonObjectResult)

Play video

public void play()

Pause video

public void pause()

Stop video

public void stop()

Set video volume

public void volume(int volume)

Set volume to mute

public void mute()

Set volume to unmute

public void unmute()

Check if volume is muted

public boolean isMuted()

Seek video to particular seconds

public void seek(int seconds)

Set player background poster from string url or local path

public void setPoster(String imageurl)

Resize view width and height in pixels

public void resize(int width, int height)

Get volume level of player

public int getVolume()

Get String state of player [VIDEO_UNSTARTED, VIDEO_ENDED, VIDEO_PLAYED, VIDEO_PAUSED, VIDEO_BUFFERING, VIDEO_CUED]

public String getState()

Get current time in second from player

public long getCurrentTime()

Get video duration in seconds

public long getDuration()

Get quality from player

public int getQuality()

Set available quality in player

public void setQuality(int level)

Get available video quality levels list

public ArrayList<String> getQualityLevels()

Get height of player view

public int getHeightOfView()

Get width of player view

public int getWidthOfView()

Disable the controls of video player

public void disableControls()

Enable the controls of video player

public void enableControls()

Hide the controls of video player

public void hideControls()

Show the controls of video player

public void showControls()
Did this answer your question?