Skip to content

Commit

Permalink
Player 4691 (#387)
Browse files Browse the repository at this point in the history
* added condition to check if apikey and secret are passed from customActivity

* implemented review comments

* implemented review comments

* changes to pass class name in intent
  • Loading branch information
sndy35 authored and SergeyBicarte committed Nov 9, 2018
1 parent 1828241 commit 411b10e
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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()) {
Expand All @@ -81,6 +93,7 @@ private void addItemsOnSpinner() {
list.add("OoyalaDefault");
list.add("GoogleIMA");
list.add("Freewheel");
list.add("Geoblocking");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand All @@ -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
Expand All @@ -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");
}
Expand Down
80 changes: 73 additions & 7 deletions OoyalaSkinSampleApp/app/src/main/res/layout/embed_pcode_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>

<EditText
android:id="@+id/embed_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_weight="@dimen/activity_layout_weight"
android:inputType="text"
android:selectAllOnFocus="false"
android:singleLine="false" />
Expand All @@ -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"/>

<EditText
android:id="@+id/pcode_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_weight="@dimen/activity_layout_weight"
android:hint="c0cTkxOqALQviQIGAHWY5hP0q9gU"
android:inputType="text" />

Expand All @@ -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"/>

<EditText
android:id="@+id/apikey_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="@dimen/activity_layout_weight"
android:hint="BjcWYyOu1KK2DiKOkF41Z2k0X57l.0I-V4"
android:inputType="text" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/activity_layout_margin"
android:text="@string/secret"/>

<EditText
android:id="@+id/secret_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="@dimen/activity_layout_weight"
android:hint="1ysC3V-g8m9V3QoGJwRa_fXcfi_G2ZV778m17pux"
android:inputType="text" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/activity_layout_margin"
android:text="@string/accountid"/>

<EditText
android:id="@+id/accountId_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="@dimen/activity_layout_weight"
android:hint="dulari_qa"
android:inputType="text" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/activity_layout_margin"
android:text="@string/select_player"/>

<Spinner
Expand All @@ -77,7 +143,7 @@
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/selectFormat"/>

<Spinner
Expand All @@ -97,7 +163,7 @@
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/select_hevc_mode"/>

<Spinner
Expand Down
3 changes: 3 additions & 0 deletions OoyalaSkinSampleApp/app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="activity_layout_margin">20dp</dimen>
<dimen name="activity_layout_weight">2</dimen>

</resources>
3 changes: 3 additions & 0 deletions OoyalaSkinSampleApp/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<string name="open">Open</string>
<string name="pcode">pcode:</string>
<string name="embed">embed:</string>
<string name="apikey">apikey:</string>
<string name="secret">secret:</string>
<string name="accountid">account Id:</string>
<string name="select_player">Select Player:</string>
<string name="auto_play">AutoPlay</string>
<string name="take_screenshot">Take a screenshot</string>
Expand Down

0 comments on commit 411b10e

Please sign in to comment.