diff --git a/AdvancedPlaybackSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlayer.java b/AdvancedPlaybackSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlayer.java index 235439ef2..816b9bb71 100644 --- a/AdvancedPlaybackSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlayer.java +++ b/AdvancedPlaybackSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlayer.java @@ -1,17 +1,13 @@ package com.ooyala.sample.utils; -import java.lang.ref.WeakReference; -import java.util.Timer; -import java.util.TimerTask; - import android.content.Context; +import android.content.res.Configuration; import android.graphics.Color; import android.os.Handler; import android.os.Message; import android.view.Gravity; import android.view.ViewGroup; import android.widget.FrameLayout; -import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; @@ -23,6 +19,10 @@ import com.ooyala.android.player.exoplayer.PlayerBitmapListener; import com.ooyala.android.plugin.LifeCycleInterface; +import java.lang.ref.WeakReference; +import java.util.Timer; +import java.util.TimerTask; + public class SampleAdPlayer extends LinearLayout implements PlayerInterface, LifeCycleInterface { private final int DURATION = 5000; @@ -154,6 +154,11 @@ public void destroy() { } } + @Override + public void configurationChanged(Configuration newConfig) { + // TODO Auto-generated method stub + } + @Override public void reset() { // TODO Auto-generated method stub diff --git a/AdvancedPlaybackSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlugin.java b/AdvancedPlaybackSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlugin.java index 772c89f2c..608e0a7c1 100644 --- a/AdvancedPlaybackSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlugin.java +++ b/AdvancedPlaybackSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlugin.java @@ -5,6 +5,7 @@ import java.util.Set; import android.content.Context; +import android.content.res.Configuration; import com.ooyala.android.AdPodInfo; import com.ooyala.android.OoyalaPlayer; @@ -64,6 +65,11 @@ public void suspend() { public void suspend(boolean onlyRemoveView) { } + @Override + public void configurationChanged(Configuration configuration) { + + } + @Override public PlayerInterface getPlayerInterface() { return _adPlayer; diff --git a/ChromecastSampleApp/app/src/main/java/com/ooyala/sample/CastOptionsProvider.java b/ChromecastSampleApp/app/src/main/java/com/ooyala/sample/CastOptionsProvider.java index 2facb795f..abbf4d677 100644 --- a/ChromecastSampleApp/app/src/main/java/com/ooyala/sample/CastOptionsProvider.java +++ b/ChromecastSampleApp/app/src/main/java/com/ooyala/sample/CastOptionsProvider.java @@ -21,6 +21,7 @@ public class CastOptionsProvider implements OptionsProvider { @Override public CastOptions getCastOptions(Context context) { NotificationOptions notificationOptions = new NotificationOptions.Builder() + .setTargetActivityClassName(ChromecastPlayerActivity.class.getName()) .setPlayDrawableResId(R.drawable.ic_media_play_light) .setPauseDrawableResId(R.drawable.ic_media_pause_light) .build(); diff --git a/ChromecastSampleApp/app/src/main/java/com/ooyala/sample/ChromecastPlayerActivity.java b/ChromecastSampleApp/app/src/main/java/com/ooyala/sample/ChromecastPlayerActivity.java index 97708a355..50ca8707e 100644 --- a/ChromecastSampleApp/app/src/main/java/com/ooyala/sample/ChromecastPlayerActivity.java +++ b/ChromecastSampleApp/app/src/main/java/com/ooyala/sample/ChromecastPlayerActivity.java @@ -73,8 +73,7 @@ private void parseSharedPreferences() { SharedPreferences lastChoosenParams = getSharedPreferences("LastChoosenParams", MODE_PRIVATE); if (lastChoosenParams != null) { embedCode = lastChoosenParams.getString("embedcode", ""); - //If second embed code is null - put first embed code as second embed code to let use repeating after playing - secondEmbedCode = lastChoosenParams.getString("secondEmbedCode", embedCode); + secondEmbedCode = lastChoosenParams.getString("secondEmbedCode", null); pcode = lastChoosenParams.getString("pcode", ""); domain = lastChoosenParams.getString("domain", ""); } diff --git a/CompleteSampleApp/app/build.gradle b/CompleteSampleApp/app/build.gradle index c34c4421d..45e26c5fb 100644 --- a/CompleteSampleApp/app/build.gradle +++ b/CompleteSampleApp/app/build.gradle @@ -24,7 +24,7 @@ task copyTask(type: Copy) { from new File(vendorDir, 'Ooyala/OoyalaFreewheelSDK-Android/OoyalaFreewheelSDK.jar') from new File(vendorDir, 'Ooyala/OoyalaSkinSDK-Android/OoyalaSkinSDK.aar') from new File(vendorDir, 'Freewheel/Android_AdManagerDistribution/FWAdManager.jar') - from new File(vendorDir, 'Google/ima-android-v374.jar') + from new File(vendorDir, 'Google/ima-android-v385.jar') from new File(vendorDir, 'NPAW/YouboraLib-5.3.1.jar') from new File(vendorDir, 'NPAW/YouboraPluginOoyala-5.3.0.jar') from new File(vendorDir, 'AdobePass/android_accessenabler-1.7.3.jar') @@ -54,7 +54,7 @@ dependencies { implementation files('libs/OoyalaIMASDK.jar') implementation files('libs/OoyalaSDK.aar') implementation files('libs/OoyalaSkinSDK.aar') - implementation files('libs/ima-android-v374.jar') + implementation files('libs/ima-android-v385.jar') 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') diff --git a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlayer.java b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlayer.java index d2f920eee..4eccb40f9 100644 --- a/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlayer.java +++ b/CompleteSampleApp/app/src/main/java/com/ooyala/sample/utils/SampleAdPlayer.java @@ -5,6 +5,7 @@ import java.util.TimerTask; import android.content.Context; +import android.content.res.Configuration; import android.graphics.Color; import android.os.Handler; import android.os.Message; @@ -158,6 +159,11 @@ public void destroy() { } } + @Override + public void configurationChanged(Configuration newConfig) { + // TODO Auto-generated method stub + } + @Override public void reset() { // TODO Auto-generated method stub diff --git a/ContentProtectionSampleApp/app/build.gradle b/ContentProtectionSampleApp/app/build.gradle index 8191646c2..cd9f58120 100644 --- a/ContentProtectionSampleApp/app/build.gradle +++ b/ContentProtectionSampleApp/app/build.gradle @@ -30,7 +30,6 @@ task copyTask(type: Copy) { tasks.copyTask.execute() dependencies { - implementation 'com.google.code.gson:gson:2.2.2' implementation 'com.google.android.gms:play-services-ads:12.0.0' implementation 'com.android.support:support-v4:26.1.0' @@ -38,9 +37,8 @@ dependencies { implementation 'com.google.android.exoplayer:exoplayer:2.6.1' implementation files('libs/android_accessenabler-1.7.3.jar') implementation files('libs/OoyalaSDK.aar') - } repositories { google() -} +} \ No newline at end of file diff --git a/ContentProtectionSampleApp/app/src/main/AndroidManifest.xml b/ContentProtectionSampleApp/app/src/main/AndroidManifest.xml index 9867240ad..263fbdde4 100644 --- a/ContentProtectionSampleApp/app/src/main/AndroidManifest.xml +++ b/ContentProtectionSampleApp/app/src/main/AndroidManifest.xml @@ -16,17 +16,22 @@ android:theme="@style/Theme.AppCompat"> - + + + android:name="com.ooyala.sample.complete.MainActivity" > + + @@ -35,6 +40,10 @@ android:configChanges="orientation|keyboardHidden|screenSize" android:name=".players.OoyalaPlayerTokenPlayerActivity" > + + diff --git a/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/complete/MainActivity.java b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/complete/MainActivity.java new file mode 100644 index 000000000..5e17d7fc2 --- /dev/null +++ b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/complete/MainActivity.java @@ -0,0 +1,57 @@ +package com.ooyala.sample.complete; + +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.lists.ContentProtectionListActivity; + +import com.ooyala.sample.players.CustomActivity; + + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * This is the opening activity for the app. + * + * + */ +public class MainActivity extends Activity implements OnItemClickListener { + final String TAG = this.getClass().toString(); + + private static Map> activityMap; + ArrayAdapter mainListAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.list_activity_layout); + activityMap = new LinkedHashMap>(); + mainListAdapter = new ArrayAdapter(this, R.layout.list_activity_list_item); + activityMap.put(ContentProtectionListActivity.getName(), ContentProtectionListActivity.class); + activityMap.put(CustomActivity.getName(), CustomActivity.class); + for(String key : activityMap.keySet()) { + mainListAdapter.add(key); + } + mainListAdapter.notifyDataSetChanged(); + ListView mainListView = (ListView) findViewById(R.id.mainActivityListView); + mainListView.setAdapter(mainListAdapter); + mainListView.setOnItemClickListener(this); + } + + @Override + public void onItemClick(AdapterView l, View v, int pos, long id) { + Class selectedClass = activityMap.get(mainListAdapter.getItem(pos)); + Intent intent = new Intent(this, selectedClass); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + startActivity(intent); + return; + } +} 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 new file mode 100644 index 000000000..7598d7982 --- /dev/null +++ b/ContentProtectionSampleApp/app/src/main/java/com/ooyala/sample/players/CustomActivity.java @@ -0,0 +1,88 @@ +package com.ooyala.sample.players; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.Toast; +import com.ooyala.sample.R; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + + +public class CustomActivity extends Activity { + public static String getName() { + return "Asset Options"; + } + private EditText embedCodeEditText; + private EditText pCodeEditText; + private EditText apiKeyEditText; + private EditText secretEditText; + private EditText accountIdEditText; + private String embedCode; + private String pCode; + private String apiKey; + private String secret; + private String accountId; + private CheckBox autoPlayCheckBox; + private boolean autoPlay; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.embed_pcode_layout); + embedCodeEditText = findViewById(R.id.embed_edit_text); + pCodeEditText = findViewById(R.id.pcode_edit_text); + apiKeyEditText = findViewById(R.id.apikey_edit_text); + secretEditText = findViewById(R.id.secret_edit_text); + accountIdEditText = findViewById(R.id.accountid_edit_text); + autoPlayCheckBox = findViewById(R.id.auto_play_check_box); + initButtonListeners(); + } + + private void initButtonListeners() { + Button setAssetButton = findViewById(R.id.play_button); + setAssetButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + embedCode = embedCodeEditText.getText().toString(); + pCode = pCodeEditText.getText().toString(); + apiKey = apiKeyEditText.getText().toString(); + secret = secretEditText.getText().toString(); + accountId = accountIdEditText.getText().toString(); + autoPlay = autoPlayCheckBox.isChecked() ? true : false; + if (embedCode.isEmpty()) { + Toast.makeText(CustomActivity.this, "Embed code can't be empty!", Toast.LENGTH_LONG).show(); + return; + } + if (pCode.isEmpty()) { + Toast.makeText(CustomActivity.this, "PCode can't be empty!", Toast.LENGTH_LONG).show(); + return; + } + startPlayerActivity(); + } + }); + } + + + private void startPlayerActivity() { + //PlayerActivity map + //Launch the correct activity + Intent intent = new Intent(this, OoyalaPlayerTokenPlayerActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + intent.putExtra("embed_code", embedCode); + intent.putExtra("pcode", pCode); + intent.putExtra("domain", "http://www.ooyala.com"); + intent.putExtra("autoPlay", autoPlay); + intent.putExtra("apikey", apiKey); + intent.putExtra("secret", secret); + intent.putExtra("accountid", accountId); + startActivity(intent); + } +} \ No newline at end of file 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 73e8618e8..ee3f885d2 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 @@ -2,6 +2,8 @@ import android.app.Activity; import android.os.Bundle; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.util.Log; import com.ooyala.android.EmbedTokenGenerator; @@ -16,6 +18,9 @@ import com.ooyala.android.ui.OoyalaPlayerLayoutController; import com.ooyala.sample.R; import com.ooyala.sample.utils.EmbeddedSecureURLGenerator; +import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; +import static android.content.pm.PackageManager.PERMISSION_GRANTED; +import com.ooyala.android.util.SDCardLogcatOoyalaEventsLogger; import java.net.URL; import java.util.HashMap; @@ -40,33 +45,44 @@ */ public class OoyalaPlayerTokenPlayerActivity extends Activity implements Observer, EmbedTokenGenerator { final String TAG = this.getClass().toString(); - + private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1; String EMBED = null; String PCODE = null; String DOMAIN = null; - private final String ACCOUNT_ID = "accountID"; + Boolean AUTOPLAY = false; + 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 = "Use this for testing, don't keep your secret in the application"; - private final String SECRET = "Use this for testing, don't keep your secret in the application"; + private String APIKEY = ""; + private String SECRET = ""; protected OoyalaPlayerLayoutController playerLayoutController; protected OoyalaPlayer player; - + boolean writePermission = false; + SDCardLogcatOoyalaEventsLogger log = new SDCardLogcatOoyalaEventsLogger(); /** * Called when the activity is first created. */ @Override public void onCreate(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; + } 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"); + APIKEY =getIntent().getExtras().getString("apikey"); + SECRET = getIntent().getExtras().getString("secret"); + ACCOUNT_ID = getIntent().getExtras().getString("accountid"); + AUTOPLAY = getIntent().getExtras().getBoolean("autoPlay"); //Initialize the player OoyalaPlayerLayout playerLayout = (OoyalaPlayerLayout) findViewById(R.id.ooyalaPlayer); @@ -78,7 +94,9 @@ public void onCreate(Bundle savedInstanceState) { player.addObserver(this); if (player.setEmbedCode(EMBED)) { - player.play(); + if(AUTOPLAY) { + player.play(); + } } else { Log.e(TAG, "Asset Failure"); @@ -128,8 +146,13 @@ public void update(Observable arg0, Object argN) { } return; } - - Log.d(TAG, "Notification Received: " + arg1 + " - state: " + player.getState()); + 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/ContentProtectionSampleApp/app/src/main/res/layout/embed_pcode_layout.xml b/ContentProtectionSampleApp/app/src/main/res/layout/embed_pcode_layout.xml new file mode 100644 index 000000000..36cb29c6b --- /dev/null +++ b/ContentProtectionSampleApp/app/src/main/res/layout/embed_pcode_layout.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +