#pubnative-android-player
pubnative-android-player is an open source IAB VAST 2.0 compilant player for Android player based on Nexage's sourcekit-vast-player.
##Contents
- Android SDK 10+
- Grant INTERNET permission in your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
compile 'net.pubnative:player:1.0.8'
Clone the repository and import the :player
module into your project
- Parse your VAST string with
VASTParser
and get aVASTModel
new VASTParser(Context).setListener(new VASTParser.Listener() {
@Override
public void onVASTParserError(int error) {
Log.e("VASTParser", "onVASTParserError: " + error);
}
@Override
public void onVASTParserFinished(VASTModel model) {
// Use your model
}
}).execute(VAST);
- Add a VASTPlayer to your layout, please ensure that the player is having a size on the screen before loading, otherwise it won't load for not having a surface to reproduce the ad
<net.pubnative.player.VASTPlayer
android:id="@+id/pubnative_vast_player"
android:layout_width="match_parent"
android:layout_height="250dp"/>
- Add Listener to your player before loading
VASTPlayer player = (VASTPlayer) findViewByID(R.id.pubnative_vast_player);
player.setListener(this);
- Load the model in your player once it's parsed
player.load(model);
- Wait for
onVASTPlayerLoadFinish
to start playing
player.play();
There are no described dependencies
This code is distributed under the terms and conditions of the BSD-3 license
NB! If you fix a bug you discovered or have development ideas, feel free to make a pull request.