From 63ee1ed61b84e4aff8df28b6ccd52bde4674ae0f Mon Sep 17 00:00:00 2001 From: Ramana Date: Tue, 30 Oct 2018 15:57:58 +0530 Subject: [PATCH 1/2] New activities to integrate npaw with fw/ima --- CompleteSampleApp/app/build.gradle | 2 + .../app/src/main/AndroidManifest.xml | 14 +++ .../ooyala/sample/complete/MainActivity.java | 4 + .../lists/NPAWFreewheelListActivity.java | 79 ++++++++++++ .../sample/lists/NPAWIMAListActivity.java | 86 +++++++++++++ .../players/NPAWFWAbstractHookActivity.java | 102 ++++++++++++++++ .../players/NPAWIMAAbstractHookActivity.java | 114 ++++++++++++++++++ ...WPreconfiguredFreewheelPlayerActivity.java | 64 ++++++++++ .../NPAWPreconfiguredIMAPlayerActivity.java | 70 +++++++++++ .../utils/youbora/YouboraConfigManager.java | 8 +- .../layout/list_activity_layout_npaw_fw.xml | 27 +++++ .../layout/list_activity_layout_npaw_ima.xml | 19 +++ .../player_simple_frame_layout_npaw_fw.xml | 19 +++ .../player_simple_frame_layout_npaw_ima.xml | 18 +++ 14 files changed, 624 insertions(+), 2 deletions(-) create mode 100644 CompleteSampleApp/app/src/main/java/com/ooyala/sample/lists/NPAWFreewheelListActivity.java create mode 100644 CompleteSampleApp/app/src/main/java/com/ooyala/sample/lists/NPAWIMAListActivity.java create mode 100644 CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWFWAbstractHookActivity.java create mode 100644 CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWIMAAbstractHookActivity.java create mode 100644 CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWPreconfiguredFreewheelPlayerActivity.java create mode 100644 CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWPreconfiguredIMAPlayerActivity.java create mode 100644 CompleteSampleApp/app/src/main/res/layout/list_activity_layout_npaw_fw.xml create mode 100644 CompleteSampleApp/app/src/main/res/layout/list_activity_layout_npaw_ima.xml create mode 100644 CompleteSampleApp/app/src/main/res/layout/player_simple_frame_layout_npaw_fw.xml create mode 100644 CompleteSampleApp/app/src/main/res/layout/player_simple_frame_layout_npaw_ima.xml diff --git a/CompleteSampleApp/app/build.gradle b/CompleteSampleApp/app/build.gradle index 1caa33814..9dc08b547 100644 --- a/CompleteSampleApp/app/build.gradle +++ b/CompleteSampleApp/app/build.gradle @@ -58,4 +58,6 @@ dependencies { implementation files('libs/android_accessenabler-1.7.3.jar') implementation files('libs/YouboraLib-5.3.1.jar') implementation files('libs/YouboraPluginOoyala-5.3.0.jar') + compile files('libs/YouboraLib-5.3.1.jar') + compile files('libs/YouboraPluginOoyala-5.3.0.jar') } diff --git a/CompleteSampleApp/app/src/main/AndroidManifest.xml b/CompleteSampleApp/app/src/main/AndroidManifest.xml index cb94ae701..aab1c0851 100644 --- a/CompleteSampleApp/app/src/main/AndroidManifest.xml +++ b/CompleteSampleApp/app/src/main/AndroidManifest.xml @@ -177,6 +177,20 @@ + + + + + + + + selectionMap; + ArrayAdapter selectionAdapter; + + /** + * Called when the activity is first created. + */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setTitle(getName()); + + selectionMap = new LinkedHashMap(); + //Populate the embed map + selectionMap.put("Freewheel Preroll", new PlayerSelectionOption("Q5MXg2bzq0UAXXMjLIFWio_6U0Jcfk6v", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", NPAWPreconfiguredFreewheelPlayerActivity.class) ); + selectionMap.put("Freewheel Midroll", new PlayerSelectionOption("NwcGg4bzrwxc6rqAZbYij4pWivBsX57a", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", NPAWPreconfiguredFreewheelPlayerActivity.class) ); + selectionMap.put("Freewheel Postroll", new PlayerSelectionOption("NmcGg4bzqbeqXO_x9Rfj5IX6gwmRRrse", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", NPAWPreconfiguredFreewheelPlayerActivity.class) ); + selectionMap.put("Freewheel PreMidPost", new PlayerSelectionOption("NqcGg4bzoOmMiV35ZttQDtBX1oNQBnT-", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", NPAWPreconfiguredFreewheelPlayerActivity.class) ); + selectionMap.put("Freewheel Overlay", new PlayerSelectionOption("NucGg4bzrVrilZrMdlSA9tyg6Vty46DN", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", NPAWPreconfiguredFreewheelPlayerActivity.class) ); + selectionMap.put("Freewheel Multi Midroll", new PlayerSelectionOption("htdnB3cDpMzXVL7fecaIWdv9rTd125As", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", NPAWPreconfiguredFreewheelPlayerActivity.class) ); + selectionMap.put("Freewheel PreMidPost Overlay", new PlayerSelectionOption("NscGg4bzpO9s5rUMyW-AAfoeEA7CX6hP", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", NPAWPreconfiguredFreewheelPlayerActivity.class) ); + + selectionMap.put("Freewheel Application-Configured", new PlayerSelectionOption("Q5MXg2bzq0UAXXMjLIFWio_6U0Jcfk6v", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", CustomConfiguredFreewheelPlayerActivity.class) ); + selectionMap.put("CuePoints and AdsControl Options", new PlayerSelectionOption("NqcGg4bzoOmMiV35ZttQDtBX1oNQBnT-", "V0NDYyOuL4a4eLle69su0dP_7vs1", "http://www.ooyala.com", OptionsFreewheelPlayerActivity.class)); + + setContentView(R.layout.list_activity_layout_npaw_fw); + + //Create the adapter for the ListView + selectionAdapter = new ArrayAdapter(this, R.layout.list_activity_list_item); + for(String key : selectionMap.keySet()) { + selectionAdapter.add(key); + } + selectionAdapter.notifyDataSetChanged(); + + //Load the data into the ListView + ListView selectionListView = (ListView) findViewById(R.id.mainActivityListView); + selectionListView.setAdapter(selectionAdapter); + selectionListView.setOnItemClickListener(this); + } + + @Override + public void onItemClick(AdapterView l, View v, int pos, long id) { + PlayerSelectionOption selection = selectionMap.get(selectionAdapter.getItem(pos)); + Class selectedClass = selection.getActivity(); + + //Launch the correct activity with the embed code as an extra + Intent intent = new Intent(this, selectedClass); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + intent.putExtra("embed_code", selection.getEmbedCode()); + intent.putExtra("pcode", selection.getPcode()); + intent.putExtra("domain", selection.getDomain()); + startActivity(intent); + return; + } +} \ No newline at end of file diff --git a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/lists/NPAWIMAListActivity.java b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/lists/NPAWIMAListActivity.java new file mode 100644 index 000000000..9842db02e --- /dev/null +++ b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/lists/NPAWIMAListActivity.java @@ -0,0 +1,86 @@ +package com.ooyala.sample.lists; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.ListView; + +import com.ooyala.sample.R; +import com.ooyala.sample.players.CustomConfiguredIMAPlayerActivity; +import com.ooyala.sample.players.NPAWPreconfiguredIMAPlayerActivity; +import com.ooyala.sample.players.PreconfiguredIMAPlayerActivity; +import com.ooyala.sample.utils.PlayerSelectionOption; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class NPAWIMAListActivity extends Activity implements OnItemClickListener { + public final static String getName() { + return "NPAW Google IMA Integration"; + } + + private static Map selectionMap; + ArrayAdapter selectionAdapter; + + /** + * Called when the activity is first created. + */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setTitle(getName()); + + selectionMap = new LinkedHashMap(); + //Populate the embed map + //TODO: Change the IMA Ad-Rules Preroll embed code, the current one is malformed +// selectionMap.put("IMA Ad-Rules Preroll", new PlayerSelectionOption("EzZ29lcTq49IswgZYkMknnU4Ukb9PQMH", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", PreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Ad-Rules Midroll", new PlayerSelectionOption("VlaG9lcTqeUU18adfd1DVeQ8YekP3H4l", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Ad-Rules Postroll", new PlayerSelectionOption("BnaG9lcTqLXQNyod7ON8Yv3eDas2Oog6", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Podded Preroll", new PlayerSelectionOption("1wNjE3cDox0G3hQIWxTjsZ8MPUDLSkDY", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Podded Midroll", new PlayerSelectionOption("1yNjE3cDodUEfUfp2WNzHkCZCMb47MUP", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Podded Postroll", new PlayerSelectionOption("1sNjE3cDoN3ZewFm1238ce730J4BMrEJ", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Podded Pre-Mid-Post", new PlayerSelectionOption("ZrOTE3cDoXo2sLOWzQPxjS__M-Qk32Co", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Skippable", new PlayerSelectionOption("FhbGRjbzq8tfaoA3dhfxc2Qs0-RURJfO", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Pre, Mid and Post Skippable", new PlayerSelectionOption("10NjE3cDpj8nUzYiV1PnFsjC6nEvPQAE", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Application-Configured", new PlayerSelectionOption("Y1ZHB1ZDqfhCPjYYRbCEOz0GR8IsVRm1", "c0cTkxOqALQviQIGAHWY5hP0q9gU", "http://www.ooyala.com", CustomConfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Non Ad-Rules Preroll", new PlayerSelectionOption("FlbGRjbzptyEbStMiMLcyNQE6l6TMgwq", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Non Ad-Rules Midroll", new PlayerSelectionOption("xrbGRjbzoBJUwtSLOHrcceTvMBe5pZdN", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Non Ad-Rules Postroll", new PlayerSelectionOption("FjbGRjbzp0DV_5-NtXBVo5Rgp3Sj0R5C", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Non Ad-Rules Quad Midroll", new PlayerSelectionOption("J3bHFpNTE6E2o2Fx_kZMyusc6m8SENCe", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("IMA Non Ad-Rules Pre-Mid-Mid-Post", new PlayerSelectionOption("g0d3BpNTE6GTTPK7o4ZyIcGqc878DqJ6", "R2NDYyOhSRhYj0UrUVgcdWlFVP-H", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + selectionMap.put("No Ads", new PlayerSelectionOption("JiOTdrdzqAujYa5qvnOxszbrTEuU5HMt", "c0cTkxOqALQviQIGAHWY5hP0q9gU", "http://www.ooyala.com", NPAWPreconfiguredIMAPlayerActivity.class) ); + + setContentView(com.ooyala.sample.R.layout.list_activity_layout_npaw_ima); + + //Create the adapter for the ListView + selectionAdapter = new ArrayAdapter(this, R.layout.list_activity_list_item); + for(String key : selectionMap.keySet()) { + selectionAdapter.add(key); + } + selectionAdapter.notifyDataSetChanged(); + + //Load the data into the ListView + ListView selectionListView = (ListView) findViewById(R.id.mainActivityListView); + selectionListView.setAdapter(selectionAdapter); + selectionListView.setOnItemClickListener(this); + } + + @Override + public void onItemClick(AdapterView l, View v, int pos, long id) { + PlayerSelectionOption selection = selectionMap.get(selectionAdapter.getItem(pos)); + Class selectedClass = selection.getActivity(); + + //Launch the correct activity with the embed code as an extra + Intent intent = new Intent(this, selectedClass); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + intent.putExtra("embed_code", selection.getEmbedCode()); + intent.putExtra("pcode", selection.getPcode()); + intent.putExtra("domain", selection.getDomain()); + startActivity(intent); + return; + } +} diff --git a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWFWAbstractHookActivity.java b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWFWAbstractHookActivity.java new file mode 100644 index 000000000..cfd111a91 --- /dev/null +++ b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWFWAbstractHookActivity.java @@ -0,0 +1,102 @@ +package com.ooyala.sample.players; + +import android.app.Activity; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.util.Log; + +import com.ooyala.android.OoyalaNotification; +import com.ooyala.android.OoyalaPlayer; +import com.ooyala.android.util.SDCardLogcatOoyalaEventsLogger; + +import java.util.Observable; +import java.util.Observer; + +import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; +import static android.content.pm.PackageManager.PERMISSION_GRANTED; + +/** + * This class asks permission for WRITE_EXTERNAL_STORAGE. We need it for automation hooks + * as we need to write into the SD card and automation will parse this file. + */ +public abstract class NPAWFWAbstractHookActivity extends Activity implements Observer { + private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1; + String TAG = this.getClass().toString(); + + SDCardLogcatOoyalaEventsLogger log = new SDCardLogcatOoyalaEventsLogger(); + + String embedCode; + String pcode; + String domain; + + OoyalaPlayer player; + + boolean writePermission = false; + boolean asked = false; + + // complete player setup after we asked for permission to write into external storage + abstract void completePlayerSetup(final boolean asked); + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if (ContextCompat.checkSelfPermission(this, WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); + } else { + writePermission= true; + asked = true; + } + + embedCode = getIntent().getExtras().getString("embed_code"); + pcode = getIntent().getExtras().getString("pcode"); + domain = getIntent().getExtras().getString("domain"); + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + if (requestCode == PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE) { + asked = true; + if (grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED) { + writePermission = true; + } + completePlayerSetup(asked); + } + } + + @Override + protected void onPause() { + super.onPause(); + if (null != player) { + player.suspend(); + } + } + + @Override + protected void onResume() { + super.onResume(); + if (null != player) { + player.resume(); + } + } + + @Override + public void update(Observable o, Object arg) { + final String arg1 = OoyalaNotification.getNameOrUnknown(arg); + if (arg1.equals(OoyalaPlayer.TIME_CHANGED_NOTIFICATION_NAME)) { + return; + } + + String text = "Notification Received: " + arg1 + " - state: " + player.getState(); + Log.d(TAG, text); + + if (writePermission) { + Log.d(TAG, "Writing log to SD card"); + // Automation Hook: Write the event text along with event count to log file in sdcard if the log file exists + log.writeToSdcardLog(text); + } + } +} diff --git a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWIMAAbstractHookActivity.java b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWIMAAbstractHookActivity.java new file mode 100644 index 000000000..cd4b28a3b --- /dev/null +++ b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWIMAAbstractHookActivity.java @@ -0,0 +1,114 @@ +package com.ooyala.sample.players; + +import android.app.Activity; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.util.Log; + +import com.ooyala.android.OoyalaNotification; +import com.ooyala.android.OoyalaPlayer; +import com.ooyala.android.ui.OptimizedOoyalaPlayerLayoutController; +import com.ooyala.android.util.SDCardLogcatOoyalaEventsLogger; + +import java.util.Observable; +import java.util.Observer; + +import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; +import static android.content.pm.PackageManager.PERMISSION_GRANTED; + +/** + * This class asks permission for WRITE_EXTERNAL_STORAGE. We need it for automation hooks + * as we need to write into the SD card and automation will parse this file. + */ +public abstract class NPAWIMAAbstractHookActivity extends Activity implements Observer { + private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1; + String TAG = this.getClass().toString(); + + private SDCardLogcatOoyalaEventsLogger log = new SDCardLogcatOoyalaEventsLogger(); + protected OptimizedOoyalaPlayerLayoutController playerLayoutController; + protected String embedCode; + protected String pcode; + protected String domain; + + OoyalaPlayer player; + + boolean writePermission = false; + boolean asked = false; + + // complete player setup after we asked for permission to write into external storage + abstract void completePlayerSetup(final boolean asked); + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if (ContextCompat.checkSelfPermission(this, WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); + } else { + writePermission= true; + asked = true; + } + + embedCode = getIntent().getExtras().getString("embed_code"); + pcode = getIntent().getExtras().getString("pcode"); + domain = getIntent().getExtras().getString("domain"); + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + if (requestCode == PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE) { + asked = true; + if (grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED) { + writePermission = true; + } + completePlayerSetup(asked); + } + } + + @Override + protected void onPause() { + super.onPause(); + if (null != player) { + player.suspend(); + } + } + + @Override + protected void onResume() { + super.onResume(); + if (null != player) { + player.resume(); + } + } + + @Override + protected void onDestroy() { + super.onDestroy(); + if (null != player) { + player.release(); + player = null; + } + } + + @Override + public void update(Observable o, Object arg) { + final String arg1 = OoyalaNotification.getNameOrUnknown(arg); + if (arg1.equals(OoyalaPlayer.TIME_CHANGED_NOTIFICATION_NAME)) { + return; + } + + if (null != player) { + String text = "Notification Received: " + arg1 + " - state: " + player.getState(); + Log.d(TAG, text); + + if (writePermission) { + Log.d(TAG, "Writing log to SD card"); + // Automation Hook: Write the event text along with event count to log file in sdcard if the log file exists + log.writeToSdcardLog(text); + } + } + } +} \ No newline at end of file diff --git a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWPreconfiguredFreewheelPlayerActivity.java b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWPreconfiguredFreewheelPlayerActivity.java new file mode 100644 index 000000000..22622e27d --- /dev/null +++ b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWPreconfiguredFreewheelPlayerActivity.java @@ -0,0 +1,64 @@ +package com.ooyala.sample.players; + +import android.os.Bundle; + +import com.npaw.youbora.plugins.PluginOoyala; +import com.npaw.youbora.youboralib.utils.YBLog; +import com.ooyala.android.OoyalaPlayer; +import com.ooyala.android.OoyalaPlayerLayout; +import com.ooyala.android.PlayerDomain; +import com.ooyala.android.configuration.Options; +import com.ooyala.android.freewheelsdk.OoyalaFreewheelManager; +import com.ooyala.android.ui.OptimizedOoyalaPlayerLayoutController; +import com.ooyala.sample.R; +import com.ooyala.sample.utils.youbora.YouboraConfigManager; + +import java.util.Map; + +/** + * This activity illustrates how to use Freewheel when all configuration is stored in Ooyala Servers + * + * In order for Freewheel to work this simply, you need the following parameters set in your Third Party Module Parameters + * - fw_android_ad_server + * - fw_android_player_profile + * + * And an Freewheel Ad Spot configured in Backlot with at least the following: + * - Network ID + * - Video Asset Network ID + * - Site Section ID + * + */ +public class NPAWPreconfiguredFreewheelPlayerActivity extends NPAWFWAbstractHookActivity { + + protected OptimizedOoyalaPlayerLayoutController playerLayoutController; + private PluginOoyala youboraPluginOoyala; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.player_simple_frame_layout_npaw_fw); + completePlayerSetup(asked); + } + + @Override + void completePlayerSetup(final boolean asked) { + if (asked) { + Options options = new Options.Builder().setUseExoPlayer(true).build(); + player = new OoyalaPlayer(pcode, new PlayerDomain(domain), options); + player.addObserver(this); + + OoyalaPlayerLayout playerLayout = (OoyalaPlayerLayout) findViewById(R.id.ooyalaPlayer); + playerLayoutController = new OptimizedOoyalaPlayerLayoutController(playerLayout, player); + + @SuppressWarnings("unused") + OoyalaFreewheelManager fwManager = new OoyalaFreewheelManager(this, playerLayoutController); + + player.setEmbedCode(embedCode); + YBLog.setDebugLevel(YBLog.YBLogLevelHTTPRequests); + Map youboraOptions = YouboraConfigManager.getYouboraConfig(getApplicationContext()); + youboraPluginOoyala = new PluginOoyala(youboraOptions); + youboraPluginOoyala.startMonitoring(player); + } + } +} diff --git a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWPreconfiguredIMAPlayerActivity.java b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWPreconfiguredIMAPlayerActivity.java new file mode 100644 index 000000000..aeca77bc6 --- /dev/null +++ b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/players/NPAWPreconfiguredIMAPlayerActivity.java @@ -0,0 +1,70 @@ +package com.ooyala.sample.players; + + +import android.os.Bundle; + +import com.npaw.youbora.plugins.PluginOoyala; +import com.npaw.youbora.youboralib.utils.YBLog; +import com.ooyala.android.OoyalaPlayer; +import com.ooyala.android.OoyalaPlayerLayout; +import com.ooyala.android.PlayerDomain; +import com.ooyala.android.configuration.Options; +import com.ooyala.android.imasdk.OoyalaIMAManager; +import com.ooyala.android.ui.OptimizedOoyalaPlayerLayoutController; +import com.ooyala.sample.R; +import com.ooyala.sample.utils.youbora.YouboraConfigManager; + +import java.util.Map; + +/** + * This activity illustrates how to use Freewheel when all configuration is stored in Ooyala Servers + * + * In order for Freewheel to work this simply, you need the following parameters set in your Third Party Module Parameters + * - ima_android_ad_server + * - ima_android_player_profile + * + * And an IMA Ad Spot configured in Backlot with at least the following: + * - Network ID + * - Video Asset Network ID + * - Site Section ID + * + */ +public class NPAWPreconfiguredIMAPlayerActivity extends NPAWIMAAbstractHookActivity { + + private PluginOoyala youboraPluginOoyala; + + /** + * Called when the activity is first created. + */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.player_simple_frame_layout_npaw_ima); + completePlayerSetup(asked); + } + + @Override + void completePlayerSetup(final boolean asked) { + if (asked) { + Options options = new Options.Builder().setUseExoPlayer(true).build(); + player = new OoyalaPlayer(pcode, new PlayerDomain(domain), options); + player.addObserver(this); + + OoyalaPlayerLayout playerLayout = (OoyalaPlayerLayout) findViewById(R.id.ooyalaPlayer); + + playerLayoutController = new OptimizedOoyalaPlayerLayoutController(playerLayout, player); + + player.setEmbedCode(embedCode); + + @SuppressWarnings("unused") + OoyalaIMAManager imaManager = new OoyalaIMAManager(player); + + YBLog.setDebugLevel(YBLog.YBLogLevelHTTPRequests); + Map youboraOptions = YouboraConfigManager.getYouboraConfig(getApplicationContext()); + youboraPluginOoyala = new PluginOoyala(youboraOptions); + youboraPluginOoyala.startMonitoring(player); + + player.setEmbedCode(embedCode); + } + } +} diff --git a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/youbora/YouboraConfigManager.java b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/youbora/YouboraConfigManager.java index ba2dda84d..e1680276d 100755 --- a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/youbora/YouboraConfigManager.java +++ b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/youbora/YouboraConfigManager.java @@ -37,9 +37,13 @@ public class YouboraConfigManager { youboraConfig.put("httpSecure", false); youboraConfig.put("enableNiceBuffer", true); youboraConfig.put("enableNiceSeek", true); - youboraConfig.put("accountCode", "nicetest"); + //Comment as per NPAW-FW instructions + //youboraConfig.put("accountCode", "nicetest"); + youboraConfig.put("accountCode", "ooyalaqa"); youboraConfig.put("service", "nqs.nice264.com"); - youboraConfig.put("username", ""); + //Comment as per NPAW-FW instructions + //youboraConfig.put("username", ""); + youboraConfig.put("username", "qa_android_ooyala"); youboraConfig.put("transactionCode", ""); youboraConfig.put("isBalanced", "0"); youboraConfig.put("isResumed", "0"); diff --git a/CompleteSampleApp/app/src/main/res/layout/list_activity_layout_npaw_fw.xml b/CompleteSampleApp/app/src/main/res/layout/list_activity_layout_npaw_fw.xml new file mode 100644 index 000000000..12a129f2a --- /dev/null +++ b/CompleteSampleApp/app/src/main/res/layout/list_activity_layout_npaw_fw.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/CompleteSampleApp/app/src/main/res/layout/list_activity_layout_npaw_ima.xml b/CompleteSampleApp/app/src/main/res/layout/list_activity_layout_npaw_ima.xml new file mode 100644 index 000000000..732293781 --- /dev/null +++ b/CompleteSampleApp/app/src/main/res/layout/list_activity_layout_npaw_ima.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/CompleteSampleApp/app/src/main/res/layout/player_simple_frame_layout_npaw_fw.xml b/CompleteSampleApp/app/src/main/res/layout/player_simple_frame_layout_npaw_fw.xml new file mode 100644 index 000000000..a0f95a3d8 --- /dev/null +++ b/CompleteSampleApp/app/src/main/res/layout/player_simple_frame_layout_npaw_fw.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/CompleteSampleApp/app/src/main/res/layout/player_simple_frame_layout_npaw_ima.xml b/CompleteSampleApp/app/src/main/res/layout/player_simple_frame_layout_npaw_ima.xml new file mode 100644 index 000000000..f81f381eb --- /dev/null +++ b/CompleteSampleApp/app/src/main/res/layout/player_simple_frame_layout_npaw_ima.xml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file From 2bc04e796570e78be3f711d4ac3589eceea478b0 Mon Sep 17 00:00:00 2001 From: Ramana Date: Tue, 30 Oct 2018 16:04:06 +0530 Subject: [PATCH 2/2] refactor code --- .../com/ooyala/sample/utils/youbora/YouboraConfigManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/youbora/YouboraConfigManager.java b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/youbora/YouboraConfigManager.java index e1680276d..86651e9b7 100755 --- a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/youbora/YouboraConfigManager.java +++ b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/youbora/YouboraConfigManager.java @@ -37,11 +37,9 @@ public class YouboraConfigManager { youboraConfig.put("httpSecure", false); youboraConfig.put("enableNiceBuffer", true); youboraConfig.put("enableNiceSeek", true); - //Comment as per NPAW-FW instructions //youboraConfig.put("accountCode", "nicetest"); youboraConfig.put("accountCode", "ooyalaqa"); youboraConfig.put("service", "nqs.nice264.com"); - //Comment as per NPAW-FW instructions //youboraConfig.put("username", ""); youboraConfig.put("username", "qa_android_ooyala"); youboraConfig.put("transactionCode", "");