1.0 | Introduction
With our Android component we try to make implementing parts of our video management system in your Android apps as easy as possible. The component places a webview with our webplayer in it and provides a bridge between Android and javascript. Please refer to the guide below on how to place our video player within your app. Should you have any questions after reading this guide, please contact our Support Team: support@bluebillywig.com
2.0 | Setting up the project
To get started, download our Android Blue Billywig component. In the component library download there is a documented example code included. In the section below we will expand about how to use this component.
We have a maven gradle import, to use this add the following to your project build.gradle file (Note: check the Maven repository for the latest version).
dependencies { implementation 'com.github.bluebillywig:BlueBillywigPlayerSDK:1.4.17' }
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.
Alternatively, start a new project and add bbcomponent.jar from the zip file above 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. There is one library included which is compatible with version 4.4 (kitkat v19) and up.
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. Also specify a playoutname which you created earlier in the VMS. It is advised that you use a playout with 100% width and height. This way you can size the player by sizing the webview.
BBPlayerSetup playerSetup = new BBPlayerSetup(); playerSetup.setPlayout("androidapp"); BBPlayer bbPlayer = bbComponent.createPlayer(this,"2119201",playerSetup);
3.0 | Fullscreen support
To use fullscreen when pressing the fullscreen button, there needs to be a FrameLayout 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 personalised 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 personalised 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 name | Description |
play | Start playback |
pause | Pause playback |
getCurrentTime | Returns a float of the current media offset time in seconds |
fullscreen | Make the player go to fullscreen mode |
retractFullscreen | Retract fullscreen mode |
isPlaying | Returns true when the media is currently playing and false when it is not |
isFullscreen | Returns true when the player is currently fullscreen and false when it is not |
getDimensions | Returns a json object with the width and height |
playerInView | Call when the player is in view |
playerOutView | Call when the player is out of view |
Method name | Arguments | Description |
loadClip | clip ID (string) | Load the specified clip (id) into the player. |
seek | timeInSeconds (float) | Load the specified clip (id) into the player. |
on | eventName (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. |
call | methodName (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");