diff --git a/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/lists/ContentProtectionListActivity.java b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/lists/ContentProtectionListActivity.java index 1deb804bb..f8682f4d8 100644 --- a/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/lists/ContentProtectionListActivity.java +++ b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/lists/ContentProtectionListActivity.java @@ -61,6 +61,7 @@ public void onItemClick(AdapterView l, View v, int pos, long id) { Intent intent = new Intent(this, selectedClass); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.putExtra("embed_code", selection.getEmbedCode()); + intent.putExtra("className", this.getClass().getSimpleName()); intent.putExtra("selection_name", selectionAdapter.getItem(pos)); intent.putExtra("pcode", selection.getPcode()); intent.putExtra("domain", selection.getDomain()); diff --git a/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/CustomActivity.java b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/CustomActivity.java index 7598d7982..ff12f9322 100644 --- a/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/CustomActivity.java +++ b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/CustomActivity.java @@ -77,6 +77,7 @@ private void startPlayerActivity() { Intent intent = new Intent(this, OoyalaPlayerTokenPlayerActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.putExtra("embed_code", embedCode); + intent.putExtra("className",this.getClass().getSimpleName()); intent.putExtra("pcode", pCode); intent.putExtra("domain", "http://www.ooyala.com"); intent.putExtra("autoPlay", autoPlay); diff --git a/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/OoyalaPlayerTokenPlayerActivity.java b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/OoyalaPlayerTokenPlayerActivity.java index 0065c00b3..15ecc4cce 100644 --- a/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/OoyalaPlayerTokenPlayerActivity.java +++ b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/OoyalaPlayerTokenPlayerActivity.java @@ -72,14 +72,14 @@ public void onCreate(Bundle 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; + writePermission = true; } setTitle(getIntent().getExtras().getString("selection_name")); setContentView(R.layout.player_simple_layout); EMBED = getIntent().getExtras().getString("embed_code"); PCODE = getIntent().getExtras().getString("pcode"); DOMAIN = getIntent().getExtras().getString("domain"); - if(getIntent().getExtras().getClass().getSimpleName().equalsIgnoreCase("CustomActivity")) { + if(getIntent().getExtras().getString("className").contains("CustomActivity")) { APIKEY = getIntent().getExtras().getString("apikey"); SECRET = getIntent().getExtras().getString("secret"); ACCOUNT_ID = getIntent().getExtras().getString("accountid"); diff --git a/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/lists/GeoBlockingListActivity.java b/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/lists/GeoBlockingListActivity.java index d2102d9b3..f9d7d1a13 100644 --- a/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/lists/GeoBlockingListActivity.java +++ b/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/lists/GeoBlockingListActivity.java @@ -58,6 +58,7 @@ public void onItemClick(AdapterView l, View v, int pos, long id) { Intent intent = new Intent(this, selectedClass); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.putExtra("embed_code", selection.getEmbedCode()); + intent.putExtra("className",this.getClass().getSimpleName()); intent.putExtra("selection_name", selectionAdapter.getItem(pos)); intent.putExtra("pcode", selection.getPcode()); intent.putExtra("domain", selection.getDomain()); diff --git a/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/AbstractHookActivity.java b/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/AbstractHookActivity.java index 36c9513ca..b2702b36e 100644 --- a/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/AbstractHookActivity.java +++ b/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/AbstractHookActivity.java @@ -37,6 +37,9 @@ public abstract class AbstractHookActivity extends Activity implements Observer, protected String embedCode; protected String pcode; protected String domain; + protected String apiKey; + protected String secret; + protected String accountId; protected String selectedFormat; protected String hevcMode; protected boolean isStaging; @@ -68,6 +71,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { pcode = extras.getString("pcode"); domain = extras.getString("domain"); autoPlay = extras.getBoolean("autoPlay",false); + apiKey = extras.getString("apiKey"); + secret = extras.getString("secret"); + accountId = extras.getString("accountId"); selectedFormat = extras.getString("selectedFormat","default"); hevcMode = extras.getString("hevc_mode","NoPreference"); isStaging = extras.getBoolean("is_staging",false); diff --git a/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/AddAssetActivity.java b/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/AddAssetActivity.java index 5fbc500b5..fc7dace7a 100644 --- a/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/AddAssetActivity.java +++ b/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/AddAssetActivity.java @@ -31,10 +31,16 @@ public static String getName() { } private EditText embedCodeEditText; private EditText pCodeEditText; + private EditText apiKeyEditText; + private EditText secretEditText; + private EditText accountIdEditText; private Spinner playerSpinner; private Spinner formatSpinner; private String embedCode; private String pCode; + private String secret; + private String apiKey; + private String accountId; private String playerActivity; private CheckBox autoPlayCheckBox; private String selectedFormat; @@ -48,6 +54,9 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.embed_pcode_layout); addItemsOnSpinner(); embedCodeEditText = (EditText) findViewById(R.id.embed_edit_text); + apiKeyEditText = (EditText) findViewById(R.id.apikey_edit_text); + secretEditText = (EditText) findViewById(R.id.secret_edit_text); + accountIdEditText = (EditText) findViewById(R.id.accountId_edit_text); pCodeEditText = (EditText) findViewById(R.id.pcode_edit_text); autoPlayCheckBox = (CheckBox) findViewById(R.id.auto_play_check_box); envStgCheckBox = (CheckBox) findViewById(R.id.set_env_stg); @@ -61,6 +70,9 @@ private void initButtonListeners() { public void onClick(View v) { embedCode = embedCodeEditText.getText().toString(); pCode = pCodeEditText.getText().toString(); + secret = secretEditText.getText().toString(); + apiKey = apiKeyEditText.getText().toString(); + accountId = accountIdEditText.getText().toString(); playerActivity = String.valueOf(playerSpinner.getSelectedItem()); selectedFormat = String.valueOf(formatSpinner.getSelectedItem()); if (embedCode.isEmpty()) { @@ -81,6 +93,7 @@ private void addItemsOnSpinner() { list.add("OoyalaDefault"); list.add("GoogleIMA"); list.add("Freewheel"); + list.add("Geoblocking"); ArrayAdapter dataAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, list); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); @@ -117,14 +130,18 @@ private void startPlayerActivity() { pActivity.put("OoyalaDefault",OoyalaSkinPlayerActivity.class); pActivity.put("GoogleIMA",PreconfiguredIMAPlayerActivity.class); pActivity.put("Freewheel",PreconfiguredFreewheelPlayerActivity.class); - + pActivity.put("Geoblocking",GeoBlockingActivity.class); //Launch the correct activity Intent intent = new Intent(this, pActivity.get(playerActivity)); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.putExtra("embed_code", embedCode); intent.putExtra("pcode", pCode); + intent.putExtra("className",this.getClass().getSimpleName()); intent.putExtra("domain", "http://www.ooyala.com"); intent.putExtra("autoPlay", autoPlayCheckBox.isChecked() ? true : false); + intent.putExtra("secret", secret); + intent.putExtra("apiKey", apiKey); + intent.putExtra("accountId", accountId); intent.putExtra("selectedFormat", selectedFormat); intent.putExtra("hevc_mode", String.valueOf(hevcSpinner.getSelectedItem())); intent.putExtra("is_staging", envStgCheckBox.isChecked() ? true : false); diff --git a/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/GeoBlockingActivity.java b/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/GeoBlockingActivity.java index d8c726672..73b818f6a 100644 --- a/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/GeoBlockingActivity.java +++ b/OoyalaSkinSampleApp/app/src/main/java/com/ooyala/sample/players/GeoBlockingActivity.java @@ -15,6 +15,7 @@ import com.ooyala.android.skin.OoyalaSkinLayoutController; import com.ooyala.android.skin.configuration.SkinOptions; import com.ooyala.sample.R; +import com.ooyala.sample.utils.CustomPlayerInfo; import org.json.JSONObject; @@ -23,14 +24,14 @@ import java.util.List; public class GeoBlockingActivity extends AbstractHookActivity implements EmbedTokenGenerator { - private final String ACCOUNT_ID = ""; + private String ACCOUNT_ID = ""; /* * The API Key and Secret should not be saved inside your applciation (even in git!). * However, for debugging you can use them to locally generate Ooyala Player Tokens. */ - private final String APIKEY = ""; - private final String SECRET = ""; + private String APIKEY = ""; + private String SECRET = ""; @Override public void onCreate(Bundle savedInstanceState) { @@ -46,9 +47,31 @@ void completePlayerSetup(boolean asked) { skinLayout = (OoyalaSkinLayout) findViewById(R.id.ooyalaSkin); // Create the OoyalaPlayer, with some built-in UI disabled PlayerDomain playerDomain = new PlayerDomain(domain); - Options options = new Options.Builder().setShowNativeLearnMoreButton(false).setShowPromoImage(false).setUseExoPlayer(true).build(); + Options.Builder optionsBuilder = new Options.Builder().setShowNativeLearnMoreButton(false).setShowPromoImage(false).setUseExoPlayer(true); + if(!selectedFormat.equalsIgnoreCase("default")) { + optionsBuilder.setPlayerInfo(new CustomPlayerInfo(selectedFormat)).build(); + } + Options options = optionsBuilder.build(); + + //Uncomment next line if you work on STAGING + //OoyalaPlayer.setEnvironment(Environment.EnvironmentType.STAGING); + + if(getIntent().getExtras().getString("className").contains("AddAssetActivity")) { + ACCOUNT_ID = accountId; + APIKEY = apiKey; + SECRET = secret; + } + //Uncomment next line if you work on STAGING //OoyalaPlayer.setEnvironment(Environment.EnvironmentType.STAGING); + + if(isStaging) { + Log.i(TAG, "Environment Set to Staging:"); + OoyalaPlayer.setEnvironment(Environment.EnvironmentType.STAGING, Environment.PROTOCOL_HTTPS); + } else { + Log.i(TAG, "Environment Set to Production:"); + OoyalaPlayer.setEnvironment(Environment.EnvironmentType.PRODUCTION, Environment.PROTOCOL_HTTPS); + } player = new OoyalaPlayer(pcode, playerDomain,this, options); //Create the SkinOptions, and setup React @@ -60,6 +83,9 @@ void completePlayerSetup(boolean asked) { player.addObserver(this); if (player.setEmbedCode(embedCode)) { + if(autoPlay) { + player.play(); + } } else { Log.e(TAG, "Asset Failure"); } diff --git a/OoyalaSkinSampleApp/app/src/main/res/layout/embed_pcode_layout.xml b/OoyalaSkinSampleApp/app/src/main/res/layout/embed_pcode_layout.xml index 7c43edd23..85c85eb7d 100644 --- a/OoyalaSkinSampleApp/app/src/main/res/layout/embed_pcode_layout.xml +++ b/OoyalaSkinSampleApp/app/src/main/res/layout/embed_pcode_layout.xml @@ -13,14 +13,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_margin="20dp" + android:layout_margin="@dimen/activity_layout_margin" android:text="@string/embed"/> @@ -36,14 +36,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_margin="20dp" + android:layout_margin="@dimen/activity_layout_margin" android:text="@string/pcode"/> @@ -58,7 +58,73 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:layout_margin="20dp" + android:layout_margin="@dimen/activity_layout_margin" + android:text="@string/apikey"/> + + + + + + + + + + + + + + + + + + + + + + + + 16dp 16dp + 20dp + 2 diff --git a/OoyalaSkinSampleApp/app/src/main/res/values/strings.xml b/OoyalaSkinSampleApp/app/src/main/res/values/strings.xml index 48375a19d..c98c268b5 100644 --- a/OoyalaSkinSampleApp/app/src/main/res/values/strings.xml +++ b/OoyalaSkinSampleApp/app/src/main/res/values/strings.xml @@ -5,6 +5,9 @@ Open pcode: embed: + apikey: + secret: + account Id: Select Player: AutoPlay Take a screenshot