Skip to content

Commit

Permalink
Bumper Sample (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
KEAMCRF authored Jul 4, 2024
1 parent ce9df62 commit 2e55e88
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 0 deletions.
34 changes: 34 additions & 0 deletions brightcove-exoplayer/BumperSampleApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.brightcove.player.samples.exoplayer.bumper"
android:versionCode="1"
android:versionName="1.0" >

<uses-permission android:name="android.permission.INTERNET"/>

<!-- Required for Android TV -->
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:banner="@drawable/tv_banner"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name="com.brightcove.player.samples.exoplayer.bumper.MainActivity"
android:screenOrientation="unspecified"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.brightcove.player.samples.exoplayer.bumper;

import android.os.Bundle;
import android.util.Log;

import com.brightcove.player.bumper.BumperComponent;
import com.brightcove.player.edge.Catalog;
import com.brightcove.player.edge.VideoListener;
import com.brightcove.player.event.EventEmitter;
import com.brightcove.player.model.Video;
import com.brightcove.player.view.BrightcovePlayer;

import java.util.Map;

/**
* This app illustrates how to use the ExoPlayer and the BumperComponent with the Brightcove
* Native Player SDK for Android.
*/
public class MainActivity extends BrightcovePlayer {

private final String TAG = this.getClass().getSimpleName();
private BumperComponent bumperComponent;

private Boolean useSetBumperID = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
// When extending the BrightcovePlayer, we must assign the brightcoveVideoView before
// entering the superclass. This allows for some stock video player lifecycle
// management. Establish the video object and use it's event emitter to get important
// notifications and to control logging.
setContentView(R.layout.activity_main);
brightcoveVideoView = findViewById(R.id.brightcove_video_view);
super.onCreate(savedInstanceState);

// Get the event emitter from the SDK and create a catalog request to fetch a video from the
// Brightcove Edge service, given a video id, an account id and a policy key.
EventEmitter eventEmitter = brightcoveVideoView.getEventEmitter();

Catalog catalog = new Catalog.Builder(eventEmitter, getString(R.string.sdk_demo_account))
.setBaseURL(Catalog.DEFAULT_EDGE_BASE_URL)
.setPolicy(getString(R.string.sdk_demo_policy))
.build();

//Building the instance of the bumper component, providing the existing videoView and catalog.
bumperComponent = new BumperComponent.Builder(brightcoveVideoView, catalog).build();
//Initializing the bumper.
bumperComponent.init();

catalog.findVideoByID(getString(R.string.sdk_demo_videoId), new VideoListener() {
// Add the video found to the queue with add().
@Override
public void onVideo(Video video) {
// Showcasing both options to set the bumper id manually or obtaining it from the
// video object properties
if (useSetBumperID) {
//Manually Setting our own bumper ID
bumperComponent.setVideoBumperID(getString(R.string.sdk_demo_bumper_videoId));
} else {
//Obtaining the bumper id from the video custom fields
Map<String, Object> customFields =
(Map<String, Object>) video.getProperties().get(Video.Fields.CUSTOM_FIELDS);
if ((customFields != null && !customFields.isEmpty()) &&
(customFields.containsKey("bumper_id"))) {
bumperComponent.setVideoBumperID((String) customFields.get("bumper_id"));
}
}
Log.v(TAG, "onVideo: video = " + video);
//Adding the video
brightcoveVideoView.add(video);
//Autostart Playback
brightcoveVideoView.start();
}
});
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >

<com.brightcove.player.view.BrightcoveExoPlayerVideoView
android:id="@+id/brightcove_video_view"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_gravity="center_horizontal|top"/>

</merge>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Application name -->
<string name="app_name">Bumper Sample App</string>

<!-- A sample Brightcove Edge Account ID -->
<string name="sdk_demo_account">4800266849001</string>

<!-- A sample Brightcove Edge Policy Key -->
<string name="sdk_demo_policy">BCpkADawqM3n0ImwKortQqSZCgJMcyVbb8lJVwt0z16UD0a_h8MpEYcHyKbM8CGOPxBRp0nfSVdfokXBrUu3Sso7Nujv3dnLo0JxC_lNXCl88O7NJ0PR0z2AprnJ_Lwnq7nTcy1GBUrQPr5e</string>

<!-- A sample Brightcove Video ID -->
<string name="sdk_demo_videoId">1715882712036765088</string>

<!-- A sample Brightcove Bumper Video ID -->
<string name="sdk_demo_bumper_videoId">1752206670195252559</string>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ include ':brightcove-exoplayer:VideoListAdRulesIMASampleApp'
include ':brightcove-exoplayer:BasicIMAVASTSampleApp'
include ':brightcove-exoplayer:ThumbnailScrubberSampleApp'
include ':brightcove-exoplayer:AudioOnlySampleApp'
include ':brightcove-exoplayer:BumperSampleApp'

include ':brightcove-exoplayer-kotlin:AudioOnlySampleApp'

Expand Down

0 comments on commit 2e55e88

Please sign in to comment.