1. Home
  2. Android Player SDK (security & tech support ended)

Android Player SDK (security & tech support ended)


Native player SDK available

Support for our web based mobile SDK ended on January 1st, 2023. Technical issues will no longer be resolved nor will any security updates be released.

To implement the Blue Billywig player into your app: please visit our native player SDK documentation to get started or contact us at support@bluebillywig.com. We will gladly help you get started with our native mobile SDK.

1.0 | Introduction

Use our Android component to easily implement parts of our video management system in your Android apps. The component places a webview with the Blue Billywig webplayer in it and provides a bridge between Android and Javascript. Use the guide below to place our video player within your app.

When to use the Android SDK

We recommend using the Android SDK when controlling the player directly from an app. This makes it possible to receive events from the player as well as to control the player (play, start, seek, etc). Implementing the Android SDK is not required when the app is used to show a video without the need to control it from the app and/or using the player control bar to control the player. Additionally, when most of the page is used to show a webpage with an embedded video, this will make it hard, if not impossible, to place buttons to control the player.

2.0 | Setting up the project

To get started, download our Android Blue Billywig component. The component library download includes a documented example code. In the section below we will expand on how to use this component.

A Maven gradle import is available. This way you can easily stay up to date with our library. The latest version of the library can be found by visiting the Maven repository. To use: add the following to your project build.gradle file

dependencies {
implementation 'com.bluebillywig:BlueBillywigPlayerSDK:1.4.18'
}
Note:

As of version 1.4.18 the location is updated from com.github.bluebillywig to com.bluebillywig

Alternatively, start a new project and add bbcomponent.jar from the downloaded zip file to the lib directory. First, right-click on libs, select Import, select General and File System. Then browse to the directory containing the library and select the library from the build directory inside the zip file. One library included which is compatible with version 5 (Lollypop v21) and up.

Next, add a new BBComponent object. Use the constructor of the BBComponent with the correct publicationname and vhost. This will create a new BBComponent object which you can use to create a new player. Please see the example below:

BBComponent bbComponent = new BBComponent("demo", "demo.bbvms.com");

Create a BBPlayerSetup object to set the specific options for the player and specify a playout (read more about playouts). It is recommended to apply a 100% width and 100% height in the playout settings (read more about playout dimensions). This makes it possible to size the player by sizing the webview.

BBPlayerSetup playerSetup = new BBPlayerSetup();
playerSetup.setPlayout("androidapp");

BBPlayer bbPlayer = bbComponent.createPlayer(this,"2119201",playerSetup);
Note:

The getActivity() function can be used instead of this when using Fragments, this is used when placed directly in an Activity. Add the BBPlayer to the layout by using the addView function of a layout.

3.0 | Fullscreen support

To use fullscreen when clicking the fullscreen button, a FrameLayout needs to be defined in the activity_main.xml. For example:

<FrameLayout
        android:id="@+id/fullscreenFrameLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

This also needs to be added to the onCreate function in MainActivity.java:

FrameLayout fullscreenFrameLayout = (FrameLayout) findViewById(R.id.fullscreenFrameLayout);
playerSetup.setFullscreenFrameLayout(fullscreenFrameLayout);

4.0 | Ad support

To support ads, we’ve added a setAdUnit function which can be used to display an ad defined in the Online Video Platform:

playerSetup.setAdunit('<name of adunit>');

The adunit name corresponds to the adunit code and can be found in “Ad services” > “Ad units”. Due to recent industry compliance updates, we need permission from the user to show personalized ads. Only after the user has given consent, the adConsentFromUser() should be called on bbPlayer.

bbPlayer.adConsentFromUser();

After this call the player will start showing personalized ads. Catching ad errors can be done with:

webView.on("aderror", this, "onAdError");
webView.on("adnotfound", this, "onAdNotFound");

5.0 | Delegates

All events described in the player API can be bound to using the on method (see methods below).

// This will catch onPlay events and send them to the onPlay callback function defined below
bbPlayer.on("play",this,"onPlay");

public void onPlay(){
    Log.d("MainActivity","onPlay event caught");
}

6.0 | Methods

The following methods can be called on the BBPlayer object

Method nameDescription
playStart playback
pausePause playback
getCurrentTimeReturns a float of the current media offset time in seconds
fullscreenMake the player go to fullscreen mode
retractFullscreenRetract fullscreen mode
isPlayingReturns true when the media is currently playing and false when it is not
isFullscreenReturns true when the player is currently fullscreen and false when it is not
getDimensionsReturns a json object with the width and height
playerInViewCall when the player is in view
playerOutViewCall when the player is out of view
destroyCall to destroy the player after calling removeView() to cleanup
Method nameArgumentsDescription
loadClipclip ID (string)Load the specified clip (id) into the player.
seektimeInSeconds (float)Load the specified clip (id) into the player.
oneventName (string)callbackFunction (string)targetObject (object)With the on method, you can bind to any of the events that are listed in the player API events. This is useful for any event that is not in the delegate list.
callmethodName (string)arguments (json string)Call any other method on the player API methods that is not in the list above.

Some examples:

//Start playing the player:
bbPlayer.play();

// Load a new clip into the player:
bbPlayer.loadClip("2337181");

// Bind to the playing event (Execute the "onPlayerPlaying" method of the parent "this" when the player throws the "playing" event):
bbPlayer.on("playing",this,"onPlayerPlaying");
Note:

If you have questions about the Android Player SDK, please contact your account manager or support@bluebillywig.com.

Was this article helpful?

Contact Support
Can't find the answer you're looking for?
Contact Support