diff --git a/proprietary/samplePlayer/Android.mk b/proprietary/samplePlayer/Android.mk
index 3c7de0dc..e41a5259 100644
--- a/proprietary/samplePlayer/Android.mk
+++ b/proprietary/samplePlayer/Android.mk
@@ -9,7 +9,23 @@ LOCAL_DEX_PREOPT := false
LOCAL_PACKAGE_NAME := WidevineSamplePlayer
-LOCAL_JAVA_LIBRARIES := org.apache.http.legacy
+LOCAL_JAVA_LIBRARIES := \
+ org.apache.http.legacy \
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-v4 \
+ android-support-v7-appcompat \
+ android-support-design
+
+LOCAL_RESOURCE_DIR := \
+ $(addprefix $(LOCAL_PATH)/, res) \
+ frameworks/support/design/res \
+ frameworks/support/v7/appcompat/res \
+
+LOCAL_AAPT_FLAGS := \
+ --auto-add-overlay \
+ --extra-packages android.support.design \
+ --extra-packages android.support.v7.appcompat \
LOCAL_SDK_VERSION := current
diff --git a/proprietary/samplePlayer/AndroidManifest.xml b/proprietary/samplePlayer/AndroidManifest.xml
index 613d3b5c..c516a70e 100644
--- a/proprietary/samplePlayer/AndroidManifest.xml
+++ b/proprietary/samplePlayer/AndroidManifest.xml
@@ -1,12 +1,16 @@
+ package="com.widevine.demo">
+
-
-
+
+
+
@@ -15,6 +19,7 @@
+
@@ -22,30 +27,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/proprietary/samplePlayer/res/layout/empty.xml b/proprietary/samplePlayer/res/layout/empty.xml
index 4e4ebd29..11d2e4c1 100644
--- a/proprietary/samplePlayer/res/layout/empty.xml
+++ b/proprietary/samplePlayer/res/layout/empty.xml
@@ -3,5 +3,11 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
-
+
diff --git a/proprietary/samplePlayer/res/layout/main.xml b/proprietary/samplePlayer/res/layout/main.xml
index 1f015bcb..5ce0f1b9 100644
--- a/proprietary/samplePlayer/res/layout/main.xml
+++ b/proprietary/samplePlayer/res/layout/main.xml
@@ -1,21 +1,27 @@
-
-
+
+
+
-
-
-
-
+ android:layout_weight="1">
+
+
+
diff --git a/proprietary/samplePlayer/res/layout/settings.xml b/proprietary/samplePlayer/res/layout/settings.xml
index f9a12a26..1e9f460d 100644
--- a/proprietary/samplePlayer/res/layout/settings.xml
+++ b/proprietary/samplePlayer/res/layout/settings.xml
@@ -73,8 +73,8 @@
android:gravity="center"
>
diff --git a/proprietary/samplePlayer/res/values/strings.xml b/proprietary/samplePlayer/res/values/strings.xml
index df73a499..fb04e59c 100644
--- a/proprietary/samplePlayer/res/values/strings.xml
+++ b/proprietary/samplePlayer/res/values/strings.xml
@@ -13,10 +13,13 @@
Show Rights
Streaming
Downloads
+ Settings
Content Page
Device Id
Drm Server
Portal Name
- Update Button
+ Save Settings
+ Next Page >>
+ << Previous Page
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/AssetDescriptor.java b/proprietary/samplePlayer/src/com/widevine/demo/AssetDescriptor.java
index 1f16cb89..f7504c68 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/AssetDescriptor.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/AssetDescriptor.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/AssetActivity.java b/proprietary/samplePlayer/src/com/widevine/demo/AssetFragment.java
similarity index 71%
rename from proprietary/samplePlayer/src/com/widevine/demo/AssetActivity.java
rename to proprietary/samplePlayer/src/com/widevine/demo/AssetFragment.java
index abecf9f1..f2b26808 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/AssetActivity.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/AssetFragment.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
@@ -9,56 +9,63 @@ import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
-import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
-import android.view.Gravity;
-import android.view.View;
+import android.support.v4.app.Fragment;
import android.util.Log;
-
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-import android.widget.Button;
-public abstract class AssetActivity extends Activity {
+
+public abstract class AssetFragment extends Fragment {
public static final String TAG = "WVM Sample Player";
private int currentPage;
protected ArrayList pages;
- private Context context;
+ private View mView;
- /** Called when the activity is first created. */
+ /** Called when the fragment is first created. */
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public View onCreateView(LayoutInflater inflater,
+ ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- context = this;
+ mView = inflater.inflate(R.layout.empty, container, false);
- initialize();
+ currentPage = 0;
+ pages = new ArrayList();
+ return mView;
}
- protected void initialize() {
- currentPage = 0;
-
- pages = new ArrayList();
-
+ @Override
+ public void onActivityCreated(Bundle bundle) {
+ super.onActivityCreated(bundle);
if (setUpAssetPages()) {
- setContentView(createView(this));
- } else {
- setContentView(R.layout.empty);
+ createView();
}
}
protected abstract boolean setUpAssetPages();
- private View createView(Context ctxt) {
- ImageView empty = new ImageView(this);
- empty.setBackground(getResources().getDrawable(R.drawable.empty, context.getTheme()));
+ private void createView() {
+
+ ViewGroup viewGroup = (ViewGroup)mView;
+ viewGroup.removeAllViews();
+
+ LinearLayout mainLayout = new LinearLayout(getActivity());
+
+ ImageView empty = new ImageView(getActivity());
+ empty.setBackground(getResources().getDrawable(R.drawable.empty,
+ getActivity().getTheme()));
View[] clips = new View[6];
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -69,22 +76,22 @@ public abstract class AssetActivity extends Activity {
for (int i = 0; i < page.getPageCount(); i++) {
AssetItem assetItem = page.getPage(i);
- clips[i] = createViewItem(getBitmapFromAssetItem(assetItem), assetItem.getAssetPath(),
- assetItem.getTitle());
+ clips[i] = createViewItem(getBitmapFromAssetItem(assetItem),
+ assetItem.getAssetPath(), assetItem.getTitle());
}
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT, 1);
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
LinearLayout.LayoutParams paramsMain = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT, 1);
paramsMain.gravity = Gravity.CENTER;
- LinearLayout left = new LinearLayout(ctxt);
+ LinearLayout left = new LinearLayout(getActivity());
left.setOrientation(LinearLayout.VERTICAL);
if (clips[0] != null) {
left.addView(clips[0], params);
@@ -95,7 +102,7 @@ public abstract class AssetActivity extends Activity {
left.addView(createEmptyView(), params);
}
- LinearLayout middle = new LinearLayout(ctxt);
+ LinearLayout middle = new LinearLayout(getActivity());
middle.setOrientation(LinearLayout.VERTICAL);
if (clips[1] != null) {
middle.addView(clips[1], params);
@@ -106,7 +113,7 @@ public abstract class AssetActivity extends Activity {
middle.addView(createEmptyView(), params);
}
- LinearLayout right = new LinearLayout(ctxt);
+ LinearLayout right = new LinearLayout(getActivity());
right.setOrientation(LinearLayout.VERTICAL);
if (clips[2] != null) {
right.addView(clips[2], params);
@@ -119,7 +126,7 @@ public abstract class AssetActivity extends Activity {
}
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
- LinearLayout body = new LinearLayout(ctxt);
+ LinearLayout body = new LinearLayout(getActivity());
body.addView(left, paramsMain);
body.addView(middle, paramsMain);
@@ -129,18 +136,17 @@ public abstract class AssetActivity extends Activity {
View.OnClickListener nextButtonListener = new View.OnClickListener() {
public void onClick(View v) {
- currentPage++;
Log.d(TAG, "Click next page: " + currentPage);
- if (currentPage >= pages.size()) {
- currentPage = 0;
+ if (currentPage < pages.size() - 1) {
+ currentPage++;
+ createView();
}
- setContentView(createView(context));
}
};
- Button next = new Button(this);
- next.setText(">>");
- next.setTextSize(10);
+ Button next = new Button(getActivity());
+ next.setText(R.string.next_page);
+ next.setTextSize(14);
next.setOnClickListener(nextButtonListener);
// Previous button listener
@@ -148,53 +154,48 @@ public abstract class AssetActivity extends Activity {
public void onClick(View v) {
- currentPage--;
Log.d(TAG, "Click prev page: " + currentPage);
- if (currentPage < 0) {
- currentPage = pages.size() - 1;
+ if (currentPage > 0) {
+ currentPage--;
+ createView();
}
- setContentView(createView(context));
-
}
};
- Button prev = new Button(this);
- prev.setText("<<");
- prev.setTextSize(10);
+ Button prev = new Button(getActivity());
+ prev.setText(R.string.previous_page);
+ prev.setTextSize(14);
prev.setOnClickListener(prevButtonListener);
- LinearLayout buttons = new LinearLayout(this);
+ LinearLayout buttons = new LinearLayout(getActivity());
buttons.addView(prev, params);
buttons.addView(next, params);
- body.setBackground(this.getResources().getDrawable(R.drawable.background3,
- context.getTheme()));
+ body.setBackground(getActivity().getResources().getDrawable(R.drawable.background3,
+ getActivity().getTheme()));
- SwipeLinearLayout main = new SwipeLinearLayout(this);
- main.setNext(nextButtonListener);
- main.setPrev(prevButtonListener);
- main.setOrientation(LinearLayout.VERTICAL);
- main.addView(body, params);
+ mainLayout.setOrientation(LinearLayout.VERTICAL);
+ mainLayout.addView(body, params);
LinearLayout.LayoutParams paramButtons = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
paramButtons.gravity = Gravity.CENTER;
- main.addView(buttons, paramButtons);
- return main;
+ mainLayout.addView(buttons, paramButtons);
+ viewGroup.addView(mainLayout, paramsMain);
}
private View createEmptyView() {
- ImageView empty = new ImageView(this);
- empty.setBackground(getResources().getDrawable(R.drawable.empty, context.getTheme()));
+ ImageView empty = new ImageView(getActivity());
+ empty.setBackground(getResources().getDrawable(R.drawable.empty, getActivity().getTheme()));
- TextView emptyText = new TextView(this);
+ TextView emptyText = new TextView(getActivity());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT, 1);
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
- LinearLayout body = new LinearLayout(this);
+ LinearLayout body = new LinearLayout(getActivity());
body.setOrientation(LinearLayout.VERTICAL);
body.addView(empty, params);
@@ -208,30 +209,31 @@ public abstract class AssetActivity extends Activity {
final String assetPath = path;
- ClipImageView clip = new ClipImageView(this);
+ ClipImageView clip = new ClipImageView(getActivity());
clip.setImageBitmap(image);
+ clip.setBackgroundColor(0);
// Set the onClick listener for each image
clip.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.d(TAG, "Click Asset path: " + assetPath);
- Intent intent = new Intent(context, VideoPlayerView.class);
+ Intent intent = new Intent(getActivity(), VideoPlayerView.class);
intent.putExtra("com.widevine.demo.Path", assetPath);
- context.startActivity(intent);
+ getActivity().startActivity(intent);
}
});
- TextView text = new TextView(this);
+ TextView text = new TextView(getActivity());
text.setText((title == null) ? path : title);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT, 1);
params.gravity = Gravity.CENTER;
- LinearLayout body = new LinearLayout(this);
+ LinearLayout body = new LinearLayout(getActivity());
body.setOrientation(LinearLayout.VERTICAL);
body.addView(clip, params);
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/AssetItem.java b/proprietary/samplePlayer/src/com/widevine/demo/AssetItem.java
index bd8e512a..7aa269f3 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/AssetItem.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/AssetItem.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/AssetsPage.java b/proprietary/samplePlayer/src/com/widevine/demo/AssetsPage.java
index 9a7996c2..764c09e3 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/AssetsPage.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/AssetsPage.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/ClipImageView.java b/proprietary/samplePlayer/src/com/widevine/demo/ClipImageView.java
index dc2068f2..c86cab35 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/ClipImageView.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/ClipImageView.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/ConfigXMLParser.java b/proprietary/samplePlayer/src/com/widevine/demo/ConfigXMLParser.java
index 8d5c2d90..17612150 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/ConfigXMLParser.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/ConfigXMLParser.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/DownloadActivity.java b/proprietary/samplePlayer/src/com/widevine/demo/DownloadFragment.java
similarity index 62%
rename from proprietary/samplePlayer/src/com/widevine/demo/DownloadActivity.java
rename to proprietary/samplePlayer/src/com/widevine/demo/DownloadFragment.java
index 3551b6c4..d4f17318 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/DownloadActivity.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/DownloadFragment.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
@@ -7,8 +7,11 @@ package com.widevine.demo;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
+import android.content.Context;
+import android.widget.Toast;
-public class DownloadActivity extends AssetActivity {
+public class DownloadFragment extends AssetFragment {
+ private static String TAG = "DownloadActivity";
protected boolean setUpAssetPages() {
pages = new ArrayList();
@@ -32,6 +35,23 @@ public class DownloadActivity extends AssetActivity {
private File[] getDownloadedClips() {
File file = new File("/sdcard/Widevine");
+ String message = null;
+
+ if (!file.exists()) {
+ message = "Warning: /sdcard/Widevine does not exist, create it for downloads";
+ } else if (!file.isDirectory()) {
+ message = "Warning: /sdcard/Widevine is not a directory";
+ } else if (!file.canRead()) {
+ message = "Warning: unable to read /sdcard/Widevine, check settings->app->permissions->storage";
+ }
+
+ if (message != null) {
+ Context context = getActivity().getApplicationContext();
+ int duration = Toast.LENGTH_LONG;
+
+ Toast toast = Toast.makeText(context, message, duration);
+ toast.show();
+ }
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
@@ -47,7 +67,5 @@ public class DownloadActivity extends AssetActivity {
};
return file.listFiles(filter);
-
}
-
}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/FullScreenVideoView.java b/proprietary/samplePlayer/src/com/widevine/demo/FullScreenVideoView.java
index 1c00eeef..6840164e 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/FullScreenVideoView.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/FullScreenVideoView.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/HttpParser.java b/proprietary/samplePlayer/src/com/widevine/demo/HttpParser.java
index 74c88de7..a0521f7c 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/HttpParser.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/HttpParser.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java b/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java
index 992e59fc..0e2bab5d 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/SettingsActivity.java b/proprietary/samplePlayer/src/com/widevine/demo/SettingsFragment.java
similarity index 67%
rename from proprietary/samplePlayer/src/com/widevine/demo/SettingsActivity.java
rename to proprietary/samplePlayer/src/com/widevine/demo/SettingsFragment.java
index f4b7ef75..42d5959d 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/SettingsActivity.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/SettingsFragment.java
@@ -1,41 +1,38 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google Inc.
*/
package com.widevine.demo;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
+import android.support.v4.app.Fragment;
import android.os.Bundle;
-
+import android.util.Log;
import android.view.View;
+import android.view.LayoutInflater;
+import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
-import android.util.Log;
-import android.content.Context;
-
-public class SettingsActivity extends Activity {
+public class SettingsFragment extends Fragment {
// public static String CONTENT_PAGE = "/sdcard/Widevine/config.xml";
public static String CONTENT_PAGE = "http://storage.googleapis.com/wvmedia/html/oem.html";
- private Context context;
private Button updateButton;
private EditText drmServer, portalName, deviceId, contentPage;
public static final String TAG = "WVM Player Settings";
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public View onCreateView(LayoutInflater inflater,
+ ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- context = this;
+ View rootView = inflater.inflate(R.layout.settings, container, false);
- setContentView(R.layout.settings);
-
- updateButton = (Button) findViewById(R.id.update_button);
+ updateButton = (Button)rootView.findViewById(R.id.save_settings);
View.OnClickListener clickListener = new View.OnClickListener() {
@@ -44,9 +41,9 @@ public class SettingsActivity extends Activity {
WidevineDrm.Settings.DRM_SERVER_URI = drmServer.getText().toString();
WidevineDrm.Settings.DEVICE_ID = deviceId.getText().toString();
WidevineDrm.Settings.PORTAL_NAME = portalName.getText().toString();
- SettingsActivity.CONTENT_PAGE = contentPage.getText().toString();
+ SettingsFragment.CONTENT_PAGE = contentPage.getText().toString();
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setMessage("DRM Settings Updated").setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
@@ -61,18 +58,18 @@ public class SettingsActivity extends Activity {
updateButton.setOnClickListener(clickListener);
- drmServer = (EditText) findViewById(R.id.drm_server);
+ drmServer = (EditText)rootView.findViewById(R.id.drm_server);
drmServer.setText(WidevineDrm.Settings.DRM_SERVER_URI);
- deviceId = (EditText) findViewById(R.id.device_id);
+ deviceId = (EditText)rootView.findViewById(R.id.device_id);
deviceId.setText(WidevineDrm.Settings.DEVICE_ID);
- portalName = (EditText) findViewById(R.id.portal_id);
+ portalName = (EditText)rootView.findViewById(R.id.portal_id);
portalName.setText(WidevineDrm.Settings.PORTAL_NAME);
- contentPage = (EditText) findViewById(R.id.content_page);
- contentPage.setText(SettingsActivity.CONTENT_PAGE);
+ contentPage = (EditText)rootView.findViewById(R.id.content_page);
+ contentPage.setText(SettingsFragment.CONTENT_PAGE);
+ return rootView;
}
-
}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/StreamingActivity.java b/proprietary/samplePlayer/src/com/widevine/demo/StreamingFragment.java
similarity index 86%
rename from proprietary/samplePlayer/src/com/widevine/demo/StreamingActivity.java
rename to proprietary/samplePlayer/src/com/widevine/demo/StreamingFragment.java
index 5ba75235..995b5afe 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/StreamingActivity.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/StreamingFragment.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google Inc.
*/
package com.widevine.demo;
@@ -10,24 +10,13 @@ import java.util.ArrayList;
import android.os.Bundle;
-public class StreamingActivity extends AssetActivity {
+public class StreamingFragment extends AssetFragment {
private String contentPage;
@Override
public void onCreate(Bundle savedInstanceState) {
- contentPage = SettingsActivity.CONTENT_PAGE;
super.onCreate(savedInstanceState);
-
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- if (!contentPage.equals(SettingsActivity.CONTENT_PAGE)) {
- contentPage = SettingsActivity.CONTENT_PAGE;
- initialize();
- }
+ contentPage = SettingsFragment.CONTENT_PAGE;
}
protected boolean setUpAssetPages() {
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/SwipeLinearLayout.java b/proprietary/samplePlayer/src/com/widevine/demo/SwipeLinearLayout.java
deleted file mode 100644
index 08dfe90a..00000000
--- a/proprietary/samplePlayer/src/com/widevine/demo/SwipeLinearLayout.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * (c)Copyright 2011 Widevine Technologies, Inc
- */
-
-package com.widevine.demo;
-
-import android.content.Context;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.LinearLayout;
-
-public class SwipeLinearLayout extends LinearLayout {
- private View.OnClickListener prev;
- private View.OnClickListener next;
-
- float startX, startY, endX, endY;
-
- public SwipeLinearLayout(Context c) {
- super(c);
- }
-
- public void setNext(View.OnClickListener next) {
- this.next = next;
- }
-
- public void setPrev(View.OnClickListener prev) {
- this.prev = prev;
- }
-
- public boolean onTouchEvent(MotionEvent e) {
- if (e.getAction() == MotionEvent.ACTION_DOWN) {
- startX = e.getX();
- startY = e.getY();
- return true;
- } else if (e.getAction() == MotionEvent.ACTION_UP) {
- endX = e.getX();
- endY = e.getY();
-
- if (Math.abs(startY - endY) < 75) {
- if ((startX - endX) > 200.0) {
- // go forward
- if (next != null) {
- next.onClick(null);
- }
- } else if ((startX - endX) < -200.0) {
- // go back
- if (prev != null) {
- prev.onClick(null);
- }
- }
- startX = startY = endX = endY = 0;
- }
- return true;
- }
- return false;
- }
-
-}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/VideoPlayerView.java b/proprietary/samplePlayer/src/com/widevine/demo/VideoPlayerView.java
index d092a218..68ad800d 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/VideoPlayerView.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/VideoPlayerView.java
@@ -1,10 +1,10 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
-import android.app.Activity;
+import android.support.v7.app.AppCompatActivity;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -33,7 +33,7 @@ import android.util.Log;
import java.io.IOException;
-public class VideoPlayerView extends Activity {
+public class VideoPlayerView extends AppCompatActivity {
private final static String TAG = "VideoPlayerView";
private final static float BUTTON_FONT_SIZE = 10;
@@ -44,13 +44,11 @@ public class VideoPlayerView extends Activity {
private WidevineDrm drm;
private FullScreenVideoView videoView;
- private MediaCodecView mediaCodecView;
private String assetUri;
private TextView logs;
private ScrollView scrollView;
private Context context;
private ClipImageView bgImage;
- private Button mediaCodecModeButton;
private Button playButton;
private Button fullScreen;
private Handler hRefresh;
@@ -58,7 +56,6 @@ public class VideoPlayerView extends Activity {
private LinearLayout main;
private LinearLayout sidePanel;
private boolean enteringFullScreen;
- private boolean useMediaCodec;
private int width, height;
public void onCreate(Bundle savedInstanceState) {
@@ -69,7 +66,6 @@ public class VideoPlayerView extends Activity {
height = display.getHeight();
width = display.getWidth();
context = this;
- useMediaCodec = false;
contentView = createView();
if (drm.isProvisionedDevice()) {
setContentView(contentView);
@@ -87,11 +83,6 @@ public class VideoPlayerView extends Activity {
stopPlayback();
}
}
- if (mediaCodecView != null) {
- if (mediaCodecView.isPlaying()) {
- stopPlayback();
- }
- }
super.onStop();
}
@@ -153,16 +144,10 @@ public class VideoPlayerView extends Activity {
FrameLayout playerFrame = new FrameLayout(this);
- View view;
- if (useMediaCodec) {
- mediaCodecView = new MediaCodecView(this);
- view = mediaCodecView;
- } else {
- videoView = new FullScreenVideoView(this);
- view = videoView;
- }
+ videoView = new FullScreenVideoView(this);
- playerFrame.addView(view, new FrameLayout.LayoutParams(
+ videoView.setVisibility(View.INVISIBLE);
+ playerFrame.addView(videoView, new FrameLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.MATCH_PARENT));
@@ -174,7 +159,6 @@ public class VideoPlayerView extends Activity {
public void onClick(View v) {
Log.d(TAG, "Click play (start playback).");
startPlayback();
-
}
});
@@ -211,8 +195,8 @@ public class VideoPlayerView extends Activity {
FrameLayout.LayoutParams.WRAP_CONTENT));
fullScreen.setVisibility(View.INVISIBLE);
playerFrame.addView(bgImage, new FrameLayout.LayoutParams(
- FrameLayout.LayoutParams.WRAP_CONTENT,
- FrameLayout.LayoutParams.WRAP_CONTENT));
+ FrameLayout.LayoutParams.MATCH_PARENT,
+ FrameLayout.LayoutParams.MATCH_PARENT));
main = new LinearLayout(this);
main.addView(playerFrame, new LinearLayout.LayoutParams((int)(width * 0.65),
@@ -227,23 +211,14 @@ public class VideoPlayerView extends Activity {
private void startPlayback() {
logMessage("Playback start.");
playButton.setText(R.string.stop);
+
bgImage.setVisibility(View.GONE);
+ videoView.setVisibility(View.VISIBLE);
- if (useMediaCodec) {
- mediaCodecView.setDataSource(
- this,
- Uri.parse(assetUri),
- null /* headers */,
- true /* encrypted */);
+ videoView.setVideoPath(assetUri);
+ videoView.setMediaController(new MediaController(context));
- mediaCodecView.setMediaController(new MediaController(context));
- mediaCodecView.requestFocus();
- mediaCodecView.start();
- } else {
- videoView.setVideoPath(assetUri);
- videoView.setMediaController(new MediaController(context));
-
- videoView.setOnErrorListener(new OnErrorListener() {
+ videoView.setOnErrorListener(new OnErrorListener() {
public boolean onError(MediaPlayer mp, int what, int extra) {
String message = "Unknown error: " + what;
switch (what) {
@@ -261,18 +236,19 @@ public class VideoPlayerView extends Activity {
updateLogs();
bgImage.setVisibility(View.VISIBLE);
+ videoView.setVisibility(View.INVISIBLE);
return false;
}
});
- videoView.setOnCompletionListener(new OnCompletionListener() {
+ videoView.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
Log.d(TAG, "onCompletion.");
stopPlayback();
}
});
- videoView.setOnInfoListener(new OnInfoListener() {
+ videoView.setOnInfoListener(new OnInfoListener() {
public boolean onInfo(MediaPlayer mp, int what, int extra) {
String message = "Unknown info message";
@@ -315,68 +291,40 @@ public class VideoPlayerView extends Activity {
}
});
- videoView.requestFocus();
+ videoView.requestFocus();
- videoView.start();
+ videoView.start();
- if (videoView.getFullScreen()) {
- sidePanel.setVisibility(View.GONE);
- } else {
- sidePanel.setVisibility(View.VISIBLE);
- }
-
- fullScreen.setVisibility(View.VISIBLE);
- videoView.setFullScreenDimensions(contentView.getRight() - contentView.getLeft(),
- contentView.getBottom() - contentView.getTop());
+ if (videoView.getFullScreen()) {
+ sidePanel.setVisibility(View.GONE);
+ } else {
+ sidePanel.setVisibility(View.VISIBLE);
}
+
+ fullScreen.setVisibility(View.VISIBLE);
+ videoView.setFullScreenDimensions(contentView.getRight() - contentView.getLeft(),
+ contentView.getBottom() - contentView.getTop());
}
private void stopPlayback() {
logMessage("Stop Playback.");
playButton.setText(R.string.play);
bgImage.setVisibility(View.VISIBLE);
+ videoView.setVisibility(View.INVISIBLE);
- if (useMediaCodec) {
- mediaCodecView.reset();
- } else {
- videoView.stopPlayback();
+ videoView.stopPlayback();
- fullScreen.setVisibility(View.INVISIBLE);
- if (videoView.getFullScreen() && !enteringFullScreen) {
- videoView.setVisibility(View.INVISIBLE);
- videoView.setFullScreen(false);
- videoView.setVisibility(View.VISIBLE);
- sidePanel.setVisibility(View.VISIBLE);
- fullScreen.setText(FULLSCREEN);
- }
+ fullScreen.setVisibility(View.INVISIBLE);
+ if (videoView.getFullScreen() && !enteringFullScreen) {
+ videoView.setVisibility(View.INVISIBLE);
+ videoView.setFullScreen(false);
+ sidePanel.setVisibility(View.VISIBLE);
+ fullScreen.setText(FULLSCREEN);
}
enteringFullScreen = false;
}
private View createButtons() {
- mediaCodecModeButton = new Button(this);
- if (useMediaCodec) {
- mediaCodecModeButton.setText(R.string.normal_mode);
- } else {
- mediaCodecModeButton.setText(R.string.mediacodec_mode);
- }
- mediaCodecModeButton.setTextSize(BUTTON_FONT_SIZE);
-
- mediaCodecModeButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- onStop();
-
- useMediaCodec = (useMediaCodec) ? false : true;
- Log.d(TAG, "Click media codec mode. useMediaCodec = "+useMediaCodec);
- contentView = createView();
- if (drm.isProvisionedDevice()) {
- setContentView(contentView);
- } else {
- setContentView(R.layout.notprovisioned);
- }
- }
- });
-
playButton = new Button(this);
playButton.setText(R.string.play);
playButton.setTextSize(BUTTON_FONT_SIZE);
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/WidevineDrm.java b/proprietary/samplePlayer/src/com/widevine/demo/WidevineDrm.java
index 7efbdc29..044e5b62 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/WidevineDrm.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/WidevineDrm.java
@@ -1,5 +1,5 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/WidevineSamplePlayer.java b/proprietary/samplePlayer/src/com/widevine/demo/WidevineSamplePlayer.java
index c92a06cd..28edefb4 100644
--- a/proprietary/samplePlayer/src/com/widevine/demo/WidevineSamplePlayer.java
+++ b/proprietary/samplePlayer/src/com/widevine/demo/WidevineSamplePlayer.java
@@ -1,85 +1,95 @@
/*
- * (c)Copyright 2011 Widevine Technologies, Inc
+ * (c)Copyright 2011 Google, Inc
*/
package com.widevine.demo;
-import android.app.TabActivity;
-import android.os.Bundle;
-import android.widget.TabHost;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.support.design.widget.TabLayout;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
-public class WidevineSamplePlayer extends TabActivity {
+public class WidevineSamplePlayer extends AppCompatActivity {
public static final String PREFS_NAME = "DrmPrefs";
+ private static final String TAG = "WidevineSamplePlayer";
+
+ DemoPagerAdapter mPagerAdapter;
+ ViewPager mViewPager;
- /** Called when the activity is first created. */
- @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
- SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
- WidevineDrm.Settings.DRM_SERVER_URI = settings.getString("drmServer",
- WidevineDrm.Settings.DRM_SERVER_URI);
- WidevineDrm.Settings.DEVICE_ID = settings.getString("deviceId",
- WidevineDrm.Settings.DEVICE_ID);
- WidevineDrm.Settings.PORTAL_NAME = settings.getString("portalId",
- WidevineDrm.Settings.PORTAL_NAME);
- SettingsActivity.CONTENT_PAGE = settings.getString("contentPage",
- SettingsActivity.CONTENT_PAGE);
-
setContentView(R.layout.main);
- TabHost tab = getTabHost();
+ // ViewPager and its adapters use support library
+ // fragments, so use getSupportFragmentManager.
+ mPagerAdapter = new DemoPagerAdapter(getSupportFragmentManager(), this);
+ mViewPager = (ViewPager)findViewById(R.id.pager);
+ mViewPager.setAdapter(mPagerAdapter);
+ TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
+ tabs.setupWithViewPager(mViewPager);
+ }
- // Setup Streaming tab
- TabHost.TabSpec streamingTab = tab.newTabSpec("Streaming");
-
- streamingTab.setIndicator("Streaming");
-
- Intent streamingIntent = new Intent(this, StreamingActivity.class);
- streamingTab.setContent(streamingIntent);
-
- tab.addTab(streamingTab);
-
- // Setup Down load tab
- TabHost.TabSpec downloadTab = tab.newTabSpec("Downloads");
-
- downloadTab.setIndicator("Downloads");
-
- Intent downloadIntent = new Intent(this, DownloadActivity.class);
- downloadTab.setContent(downloadIntent);
-
- tab.addTab(downloadTab);
-
- // Setup Settings tab
- TabHost.TabSpec settingsTab = tab.newTabSpec("Settings");
-
- settingsTab.setIndicator("Settings");
-
- Intent settingsIntent = new Intent(this, SettingsActivity.class);
- settingsTab.setContent(settingsIntent);
-
- tab.addTab(settingsTab);
+}
+class DemoPagerAdapter extends FragmentPagerAdapter {
+ private Context context;
+ public DemoPagerAdapter(FragmentManager fm, Context c) {
+ super(fm);
+ context = c;
}
@Override
- protected void onStop() {
- super.onStop();
+ public Fragment getItem(int i) {
+ Fragment fragment = null;
+ switch (i) {
+ case 0: fragment = new StreamingFragment();
+ break;
+ case 1: fragment = new DownloadFragment();
+ break;
+ case 2: fragment = new SettingsFragment();
+ break;
+ }
+ return fragment;
+ }
- // We need an Editor object to make preference changes.
- // All objects are from android.context.Context
- SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
+ @Override
+ public int getCount() {
+ return 3;
+ }
- SharedPreferences.Editor editor = settings.edit();
- editor.putString("drmServer", WidevineDrm.Settings.DRM_SERVER_URI);
- editor.putString("deviceId", WidevineDrm.Settings.DEVICE_ID);
- editor.putString("portalId", WidevineDrm.Settings.PORTAL_NAME);
- editor.putString("contentPage", SettingsActivity.CONTENT_PAGE);
- // Commit the edits!
- editor.commit();
+ @Override
+ public CharSequence getPageTitle(int position) {
+ int tabNameIds[] = {R.string.streaming, R.string.downloads, R.string.settings};
+ return context.getResources().getText(tabNameIds[position]);
+ }
+}
+
+// Instances of this class are fragments representing a single
+// object in our collection.
+class DemoObjectFragment extends Fragment {
+ public static final String ARG_OBJECT = "object";
+
+ @Override
+ public View onCreateView(LayoutInflater inflater,
+ ViewGroup container, Bundle savedInstanceState) {
+ // The last two arguments ensure LayoutParams are inflated
+ // properly.
+ View rootView = inflater.inflate(R.layout.empty, container, false);
+ return rootView;
}
}