) parser.parse();
+
+ for (int i = 0; i < descrs.size(); i++) {
+ AssetDescriptor asset = descrs.get(i);
+ String imagePath = asset.getThumbnail();
+ if (!imagePath.contains("http")) {
+ imagePath = rootUrl + imagePath;
+ }
+ assets.add(new AssetItem(asset.getUri(), asset.getThumbnail(), asset.getTitle()));
+ }
+ }
+
+ private void parseHtml(String htmlText) {
+ int start = 0;
+ int end = 0;
+
+ while (true) {
+ String assetPath = null;
+ String title = null;
+ String imagePath = null;
+ start = htmlText.indexOf(":", start);
+ if (start == -1) {
+ break;
+ } else {
+ end = htmlText.indexOf("\"", start);
+ assetPath = "http" + htmlText.substring(start, end);
+ start = end + 1;
+ start = htmlText.indexOf("\"", start) + 1;
+ end = htmlText.indexOf("\"", start);
+ imagePath = htmlText.substring(start, end);
+ if (!imagePath.contains("http")) {
+ imagePath = rootUrl + imagePath;
+ }
+ start = htmlText.indexOf("", start) + "
".length();
+ end = htmlText.indexOf("
", start);
+ title = htmlText.substring(start, end);
+ start = end + 1;
+ assets.add(new AssetItem(assetPath, imagePath, title));
+ }
+ }
+ }
+
+ public ArrayList getAssets() {
+ return this.assets;
+ }
+}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java b/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java
new file mode 100644
index 00000000..992e59fc
--- /dev/null
+++ b/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java
@@ -0,0 +1,56 @@
+/*
+ * (c)Copyright 2011 Widevine Technologies, Inc
+ */
+
+package com.widevine.demo;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+
+public class ImageHandler extends Thread {
+
+ private boolean scale;
+ private String imageUrl;
+ private Bitmap clipImage = null;
+
+ public ImageHandler(String imageUrl) {
+ this.imageUrl = imageUrl;
+ this.clipImage = null;
+ }
+
+ public void setScale(boolean scale) {
+ this.scale = scale;
+ }
+
+ public void run() {
+
+ try {
+
+ DefaultHttpClient httpClient = new DefaultHttpClient();
+ HttpGet request = new HttpGet(imageUrl);
+ HttpResponse response = httpClient.execute(request);
+
+ this.clipImage = BitmapFactory.decodeStream(response.getEntity().getContent());
+ if (scale) {
+ this.clipImage = Bitmap.createScaledBitmap(this.clipImage, 150, 200, false);
+ }
+ } catch (MalformedURLException e) {
+ this.clipImage = null;
+ } catch (IOException e) {
+ this.clipImage = null;
+ }
+
+ }
+
+ public Bitmap getBitmap() {
+ return this.clipImage;
+ }
+
+}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/SettingsActivity.java b/proprietary/samplePlayer/src/com/widevine/demo/SettingsActivity.java
new file mode 100644
index 00000000..48a1aeb6
--- /dev/null
+++ b/proprietary/samplePlayer/src/com/widevine/demo/SettingsActivity.java
@@ -0,0 +1,73 @@
+/*
+ * (c)Copyright 2011 Widevine Technologies, Inc
+ */
+
+package com.widevine.demo;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+import android.content.Context;
+
+public class SettingsActivity extends Activity {
+ // public static String CONTENT_PAGE = "/sdcard/Widevine/config.xml";
+ public static String CONTENT_PAGE = "http://seawwws001.shibboleth.tv/android/oem.html";
+
+ private Context context;
+ private Button updateButton;
+ private EditText drmServer, portalName, deviceId, contentPage;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ context = this;
+
+ setContentView(R.layout.settings);
+
+ updateButton = (Button) findViewById(R.id.update_button);
+
+ View.OnClickListener clickListener = new View.OnClickListener() {
+
+ public void onClick(View v) {
+ 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();
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setMessage("DRM Settings Updated").setCancelable(false)
+ .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+ }
+ };
+
+ updateButton.setOnClickListener(clickListener);
+
+ drmServer = (EditText) findViewById(R.id.drm_server);
+ drmServer.setText(WidevineDrm.Settings.DRM_SERVER_URI);
+
+ deviceId = (EditText) findViewById(R.id.device_id);
+ deviceId.setText(WidevineDrm.Settings.DEVICE_ID);
+
+ portalName = (EditText) findViewById(R.id.portal_id);
+ portalName.setText(WidevineDrm.Settings.PORTAL_NAME);
+
+ contentPage = (EditText) findViewById(R.id.content_page);
+ contentPage.setText(SettingsActivity.CONTENT_PAGE);
+
+ }
+
+}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/StreamingActivity.java b/proprietary/samplePlayer/src/com/widevine/demo/StreamingActivity.java
new file mode 100644
index 00000000..72289de9
--- /dev/null
+++ b/proprietary/samplePlayer/src/com/widevine/demo/StreamingActivity.java
@@ -0,0 +1,97 @@
+/*
+ * (c)Copyright 2011 Widevine Technologies, Inc
+ */
+
+package com.widevine.demo;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+
+import android.os.Bundle;
+
+public class StreamingActivity extends AssetActivity {
+ 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();
+ }
+ }
+
+ protected boolean setUpAssetPages() {
+ pages = new ArrayList();
+
+ if (contentPage.contains(".htm")) {
+ ArrayList assets = getStreamingClipsHttp();
+
+ if (assets == null || assets.size() == 0)
+ return false;
+
+ for (int i = 0; i < assets.size();) {
+ AssetsPage page = new AssetsPage();
+ for (int j = 0; j < AssetsPage.MAX_ITEMS && i < assets.size(); j++, i++) {
+ page.addPage(assets.get(i).getAssetPath(), assets.get(i).getImagePath(), assets
+ .get(i).getTitle());
+ }
+ pages.add(page);
+ }
+ } else {
+ ArrayList assets = getStreamingClipsXml();
+
+ if (assets == null || assets.size() == 0)
+ return false;
+
+ for (int i = 0; i < assets.size();) {
+ AssetsPage page = new AssetsPage();
+ for (int j = 0; j < AssetsPage.MAX_ITEMS && i < assets.size(); j++, i++) {
+ page.addPage(assets.get(i).getUri(), assets.get(i).getThumbnail(), assets
+ .get(i).getTitle());
+ }
+ pages.add(page);
+ }
+ }
+
+ return true;
+ }
+
+ private ArrayList getStreamingClipsXml() {
+
+ try {
+ File file = new File(contentPage);
+ if (file.exists()) {
+ ConfigXMLParser parser = new ConfigXMLParser(file.toURL());
+
+ ArrayList assets = (ArrayList) parser.parse();
+ return assets;
+ } else {
+ return new ArrayList();
+ }
+ } catch (MalformedURLException e) {
+ return new ArrayList();
+ }
+
+ }
+
+ private ArrayList getStreamingClipsHttp() {
+ HttpParser parser = new HttpParser(contentPage);
+ parser.start();
+ try {
+ parser.join();
+ } catch (InterruptedException e) {
+ }
+ return parser.getAssets();
+ }
+
+}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/SwipeLinearLayout.java b/proprietary/samplePlayer/src/com/widevine/demo/SwipeLinearLayout.java
new file mode 100644
index 00000000..08dfe90a
--- /dev/null
+++ b/proprietary/samplePlayer/src/com/widevine/demo/SwipeLinearLayout.java
@@ -0,0 +1,58 @@
+/*
+ * (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
new file mode 100644
index 00000000..4f891e44
--- /dev/null
+++ b/proprietary/samplePlayer/src/com/widevine/demo/VideoPlayerView.java
@@ -0,0 +1,329 @@
+/*
+ * (c)Copyright 2011 Widevine Technologies, Inc
+ */
+
+package com.widevine.demo;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.MediaController;
+import android.widget.ScrollView;
+import android.widget.TextView;
+import android.widget.Button;
+import android.view.Gravity;
+import android.view.View;
+import android.content.Context;
+
+import android.media.MediaPlayer;
+import android.media.MediaPlayer.OnErrorListener;
+import android.media.MediaPlayer.OnCompletionListener;
+
+public class VideoPlayerView extends Activity {
+ private final static String EXIT_FULLSCREEN = "Exit Full Screen";
+ private final static String FULLSCREEN = "Enter Full Screen";
+ private final static String PLAY = "Play";
+ private final static int REFRESH = 1;
+
+ private WidevineDrm drm;
+ private FullScreenVideoView videoView;
+ private String assetUri;
+ private TextView logs;
+ private ScrollView scrollView;
+ private Context context;
+ private ClipImageView bgImage;
+ private Button playButton;
+ private Button fullScreen;
+ private Handler hRefresh;
+ private View contentView;
+ private LinearLayout main;
+ private LinearLayout sidePanel;
+ private boolean enteringFullScreen;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ context = this;
+ contentView = createView();
+ setContentView(contentView);
+ }
+
+ @Override
+ protected void onStop() {
+ if (videoView != null) {
+ if (videoView.isPlaying()) {
+ stopPlayback();
+ }
+ }
+ super.onStop();
+ }
+
+ private View createView() {
+ enteringFullScreen = false;
+ assetUri = this.getIntent().getStringExtra("com.widevine.demo.Path");
+
+ drm = new WidevineDrm(this);
+ drm.logBuffer.append("Asset Uri: " + assetUri + "\n");
+ drm.logBuffer.append("Drm Server: " + WidevineDrm.Settings.DRM_SERVER_URI + "\n");
+ drm.logBuffer.append("Device Id: " + WidevineDrm.Settings.DEVICE_ID + "\n");
+ drm.logBuffer.append("Portal Name: " + WidevineDrm.Settings.PORTAL_NAME + "\n");
+
+ // Set log update listener
+ WidevineDrm.WidevineDrmLogEventListener drmLogListener =
+ new WidevineDrm.WidevineDrmLogEventListener() {
+
+ public void logUpdated() {
+ updateLogs();
+
+ }
+ };
+
+ videoView = new FullScreenVideoView(this);
+
+ logs = new TextView(this);
+ drm.setLogListener(drmLogListener);
+
+ scrollView = new ScrollView(this);
+ scrollView.addView(logs);
+
+ // Set message handler for log events
+ hRefresh = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case REFRESH:
+ /* Refresh UI */
+ logs.setText(drm.logBuffer.toString());
+ scrollView.fullScroll(ScrollView.FOCUS_DOWN);
+ break;
+ }
+ }
+ };
+
+ updateLogs();
+
+ sidePanel = new LinearLayout(this);
+ sidePanel.setOrientation(LinearLayout.VERTICAL);
+ sidePanel.addView(scrollView, new LinearLayout.LayoutParams(300, 450));
+
+ LinearLayout.LayoutParams paramsSidePanel = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT);
+ paramsSidePanel.gravity = Gravity.CENTER;
+ sidePanel.addView(createButtons(), paramsSidePanel);
+
+ FrameLayout playerFrame = new FrameLayout(this);
+ playerFrame.addView(videoView, new FrameLayout.LayoutParams(
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ FrameLayout.LayoutParams.MATCH_PARENT));
+
+ bgImage = new ClipImageView(this);
+ bgImage.setBackgroundDrawable(getResources().getDrawable(R.drawable.play_shield));
+
+ bgImage.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ startPlayback();
+
+ }
+ });
+
+ fullScreen = new Button(this);
+ fullScreen.setText(FULLSCREEN);
+
+ fullScreen.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ int currentPosition = videoView.getCurrentPosition();
+ videoView.setVisibility(View.INVISIBLE);
+ if (fullScreen.getText().equals(FULLSCREEN)) {
+
+ videoView.setFullScreen(true);
+ fullScreen.setText(EXIT_FULLSCREEN);
+ enteringFullScreen = true;
+ } else {
+ videoView.setFullScreen(false);
+ fullScreen.setText(FULLSCREEN);
+ }
+ videoView.setVisibility(View.VISIBLE);
+
+ stopPlayback();
+ startPlayback();
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ videoView.seekTo(currentPosition);
+ }
+ });
+ playerFrame.addView(fullScreen, new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.WRAP_CONTENT,
+ FrameLayout.LayoutParams.WRAP_CONTENT));
+ fullScreen.setVisibility(View.INVISIBLE);
+ playerFrame.addView(bgImage, new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.WRAP_CONTENT,
+ FrameLayout.LayoutParams.WRAP_CONTENT));
+
+ main = new LinearLayout(this);
+ main.addView(playerFrame, new LinearLayout.LayoutParams(900,
+ LinearLayout.LayoutParams.FILL_PARENT, 1));
+ main.addView(sidePanel, new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.FILL_PARENT, 3));
+
+ return main;
+ }
+
+ private void startPlayback() {
+ playButton.setText(R.string.stop);
+
+ bgImage.setVisibility(View.GONE);
+
+ videoView.setVideoPath(assetUri);
+ videoView.setMediaController(new MediaController(context));
+
+ videoView.setOnErrorListener(new OnErrorListener() {
+ public boolean onError(MediaPlayer mp, int what, int extra) {
+ String message = "Unknown error";
+ switch (what) {
+ case MediaPlayer.MEDIA_ERROR_UNKNOWN:
+ message = "Unable to play media";
+ break;
+ case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
+ message = "Server failed";
+ break;
+ case MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK:
+ message = "Invalid media";
+ break;
+ }
+ drm.logBuffer.append(message + "\n");
+ updateLogs();
+ bgImage.setVisibility(View.VISIBLE);
+ return false;
+ }
+ });
+ videoView.setOnCompletionListener(new OnCompletionListener() {
+ public void onCompletion(MediaPlayer mp) {
+ stopPlayback();
+ }
+ });
+ videoView.requestFocus();
+
+ 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());
+ }
+
+ private void stopPlayback() {
+ playButton.setText(R.string.play);
+ videoView.stopPlayback();
+ fullScreen.setVisibility(View.INVISIBLE);
+ bgImage.setVisibility(View.VISIBLE);
+
+ if (videoView.getFullScreen() && !enteringFullScreen) {
+ videoView.setVisibility(View.INVISIBLE);
+ videoView.setFullScreen(false);
+ videoView.setVisibility(View.VISIBLE);
+ sidePanel.setVisibility(View.VISIBLE);
+ fullScreen.setText(FULLSCREEN);
+ }
+ enteringFullScreen = false;
+
+ }
+
+ private View createButtons() {
+ playButton = new Button(this);
+ playButton.setText(R.string.play);
+
+ playButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Button b = (Button) v;
+ if (b.getText().equals(PLAY)) {
+ startPlayback();
+ } else {
+ stopPlayback();
+ }
+ }
+ });
+
+ Button rightsButton = new Button(this);
+ rightsButton.setText(R.string.acquire_rights);
+
+ rightsButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ drm.acquireRights(assetUri);
+ updateLogs();
+ }
+ });
+
+ Button removeButton = new Button(this);
+ removeButton.setText(R.string.remove_rights);
+
+ removeButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ drm.removeRights(assetUri);
+ updateLogs();
+ }
+ });
+
+ Button checkButton = new Button(this);
+ checkButton.setText(R.string.show_rights);
+
+ checkButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ drm.showRights(assetUri);
+ updateLogs();
+ }
+ });
+
+ Button checkConstraints = new Button(this);
+ checkConstraints.setText(R.string.constraints);
+
+ checkConstraints.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ drm.getConstraints(assetUri);
+ updateLogs();
+
+ }
+ });
+
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.FILL_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT, 1);
+ params.setMargins(0, 0, 0, 5);
+ LinearLayout buttonsLeft = new LinearLayout(this);
+
+ buttonsLeft.setOrientation(LinearLayout.VERTICAL);
+ buttonsLeft.addView(playButton, params);
+ buttonsLeft.addView(rightsButton, params);
+ buttonsLeft.addView(checkConstraints, params);
+
+ LinearLayout buttonsRight = new LinearLayout(this);
+ buttonsRight.setOrientation(LinearLayout.VERTICAL);
+ buttonsRight.addView(checkButton, params);
+ buttonsRight.addView(removeButton, params);
+
+ LinearLayout.LayoutParams paramsSides = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.FILL_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT, 1);
+ paramsSides.gravity = Gravity.BOTTOM;
+
+ LinearLayout buttons = new LinearLayout(this);
+ buttons.addView(buttonsLeft, paramsSides);
+ buttons.addView(buttonsRight, paramsSides);
+
+ return buttons;
+ }
+
+ private void updateLogs() {
+ hRefresh.sendEmptyMessage(REFRESH);
+ }
+}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/WidevineDrm.java b/proprietary/samplePlayer/src/com/widevine/demo/WidevineDrm.java
new file mode 100644
index 00000000..a9940769
--- /dev/null
+++ b/proprietary/samplePlayer/src/com/widevine/demo/WidevineDrm.java
@@ -0,0 +1,252 @@
+/*
+ * (c)Copyright 2011 Widevine Technologies, Inc
+ */
+
+package com.widevine.demo;
+
+import java.util.EventListener;
+//import java.util.HashMap;
+import java.util.Set;
+
+import android.content.ContentValues;
+import android.content.Context;
+
+import android.drm.DrmErrorEvent;
+import android.drm.DrmEvent;
+import android.drm.DrmInfoEvent;
+import android.drm.DrmInfoRequest;
+import android.drm.DrmManagerClient;
+import android.drm.DrmStore;
+
+public class WidevineDrm {
+
+ interface WidevineDrmLogEventListener extends EventListener {
+ public void logUpdated();
+ }
+
+ private WidevineDrmLogEventListener logEventListener;
+
+ public StringBuffer logBuffer = new StringBuffer();
+
+ /**
+ * Drm Manager Configuration Methods
+ */
+
+ public static class Settings {
+ public static String WIDEVINE_MIME_TYPE = "video/wvm";
+ public static String DRM_SERVER_URI = "https://wstfcps005.shibboleth.tv/widevine/cypherpc/cgi-bin/GetEMMs.cgi";
+ public static String DEVICE_ID = "device12345"; // use a unique device ID
+ public static String PORTAL_NAME = "OEM";
+
+ // test with a sizeable block of user data...
+ public static String USER_DATA = "01234567890123456789012345678901234567890123456789"
+ + "01234567890123456789012345678901234567890123456789"
+ + "01234567890123456789012345678901234567890123456789"
+ + "01234567890123456789012345678901234567890123456789"
+ + "01234567890123456789012345678901234567890123456789"
+ + "01234567890123456789012345678901234567890123456789";
+ };
+
+ private DrmManagerClient mDrmManager;
+
+ // private Context mContext;
+
+ public WidevineDrm(Context context) {
+
+ // mContext = context;
+ mDrmManager = new DrmManagerClient(context);
+
+ mDrmManager.setOnInfoListener(new DrmManagerClient.OnInfoListener() {
+ // @Override
+ public void onInfo(DrmManagerClient client, DrmInfoEvent event) {
+ if (event.getType() == DrmInfoEvent.TYPE_RIGHTS_INSTALLED) {
+ logMessage("Rights installed\n");
+ }
+ }
+ });
+
+ mDrmManager.setOnEventListener(new DrmManagerClient.OnEventListener() {
+
+ public void onEvent(DrmManagerClient client, DrmEvent event) {
+ switch (event.getType()) {
+ case DrmEvent.TYPE_DRM_INFO_PROCESSED:
+ logMessage("Info Processed\n");
+ break;
+ }
+ }
+ });
+
+ mDrmManager.setOnErrorListener(new DrmManagerClient.OnErrorListener() {
+ public void onError(DrmManagerClient client, DrmErrorEvent event) {
+ switch (event.getType()) {
+ case DrmErrorEvent.TYPE_ALL_RIGHTS_REMOVED:
+ logMessage("Remove All Rights failed\n");
+ break;
+ case DrmErrorEvent.TYPE_DRM_INFO_PROCESSED:
+ logMessage("Info Processed failed\n");
+ break;
+ case DrmErrorEvent.TYPE_NO_INTERNET_CONNECTION:
+ logMessage("No Internet Connection\n");
+ break;
+ case DrmErrorEvent.TYPE_NOT_SUPPORTED:
+ logMessage("Not Supported\n");
+ break;
+ case DrmErrorEvent.TYPE_OUT_OF_MEMORY:
+ logMessage("Out of Memory\n");
+ break;
+ case DrmErrorEvent.TYPE_PROCESS_DRM_INFO_FAILED:
+ logMessage("Process DRM Info failed\n");
+ break;
+ case DrmErrorEvent.TYPE_REMOVE_ALL_RIGHTS_FAILED:
+ logMessage("Remove all rights\n");
+ break;
+ case DrmErrorEvent.TYPE_RIGHTS_NOT_INSTALLED:
+ logMessage("Rights not installed\n");
+ break;
+ case DrmErrorEvent.TYPE_RIGHTS_RENEWAL_NOT_ALLOWED:
+ logMessage("Rights renewal not allowed\n");
+ break;
+ }
+
+ }
+ });
+ }
+
+ public DrmInfoRequest getDrmInfoRequest(String assetUri) {
+ DrmInfoRequest rightsAcquisitionInfo;
+ rightsAcquisitionInfo = new DrmInfoRequest(DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO,
+ Settings.WIDEVINE_MIME_TYPE);
+
+ rightsAcquisitionInfo.put("WVDRMServerKey", Settings.DRM_SERVER_URI);
+ rightsAcquisitionInfo.put("WVAssetURIKey", assetUri);
+ rightsAcquisitionInfo.put("WVDeviceIDKey", Settings.DEVICE_ID);
+ rightsAcquisitionInfo.put("WVPortalKey", Settings.PORTAL_NAME);
+ rightsAcquisitionInfo.put("WVCAUserDataKey", Settings.USER_DATA);
+ return rightsAcquisitionInfo;
+ }
+
+ public int acquireRights(String assetUri) {
+
+ int rights = mDrmManager.acquireRights(getDrmInfoRequest(assetUri));
+ logMessage("acquireRights = " + rights + "\n");
+
+ return rights;
+ }
+
+ public int checkRightsStatus(String assetUri) {
+
+ // Need to use acquireDrmInfo prior to calling checkRightsStatus
+ mDrmManager.acquireDrmInfo(getDrmInfoRequest(assetUri));
+ int status = mDrmManager.checkRightsStatus(assetUri);
+ logMessage("checkRightsStatus = " + status + "\n");
+
+ return status;
+ }
+
+ public void getConstraints(String assetUri) {
+
+ // Need to use acquireDrmInfo prior to calling checkRightsStatus
+ mDrmManager.acquireDrmInfo(getDrmInfoRequest(assetUri));
+ ContentValues values = mDrmManager.getConstraints(assetUri, DrmStore.Action.PLAY);
+ logContentValues(values, "No Contraints");
+ }
+
+ public void showRights(String assetUri) {
+ logMessage("showRights\n");
+
+ // Need to use acquireDrmInfo prior to calling getConstraints
+ mDrmManager.acquireDrmInfo(getDrmInfoRequest(assetUri));
+
+ ContentValues values = mDrmManager.getConstraints(assetUri, DrmStore.Action.PLAY);
+ logContentValues(values, "No Rights");
+
+ }
+
+ private void logContentValues(ContentValues values, String defaultMessage) {
+ if (values != null) {
+
+ Set keys = values.keySet();
+ for (String key : keys) {
+ if (key.toLowerCase().contains("time")) {
+ logMessage(key + " = " + SecondsToDHMS(values.getAsLong(key)) + "\n");
+ } else if (key.toLowerCase().contains("licensetype")) {
+ logMessage(key + " = " + licenseType(values.getAsInteger(key)) + "\n");
+ } else if (key.toLowerCase().contains("licensedresolution")) {
+ logMessage(key + " = " + licenseResolution(values.getAsInteger(key)) + "\n");
+ } else {
+ logMessage(key + " = " + values.get(key) + "\n");
+ }
+ }
+ } else {
+ logMessage(defaultMessage + "\n");
+ }
+ }
+
+ private static final long seconds_per_minute = 60;
+ private static final long seconds_per_hour = 60 * seconds_per_minute;
+ private static final long seconds_per_day = 24 * seconds_per_hour;
+
+ private String SecondsToDHMS(long seconds) {
+ int days = (int) (seconds / seconds_per_day);
+ seconds -= days * seconds_per_day;
+ int hours = (int) (seconds / seconds_per_hour);
+ seconds -= hours * seconds_per_hour;
+ int minutes = (int) (seconds / seconds_per_minute);
+ seconds -= minutes * seconds_per_minute;
+ return Integer.toString(days) + "d " + Integer.toString(hours) + "h "
+ + Integer.toString(minutes) + "m " + Long.toString(seconds)
+ + "s";
+ }
+
+ private String licenseType(int code) {
+ switch (code) {
+ case 1:
+ return "Streaming";
+ case 2:
+ return "Offline";
+ case 3:
+ return "Both";
+ default:
+ return "Unknown";
+ }
+ }
+
+ private String licenseResolution(int code) {
+ switch (code) {
+ case 1:
+ return "SD only";
+ case 2:
+ return "HD or SD content";
+ default:
+ return "Unknown";
+ }
+ }
+
+ public int removeRights(String assetUri) {
+
+ // Need to use acquireDrmInfo prior to calling removeRights
+ mDrmManager.acquireDrmInfo(getDrmInfoRequest(assetUri));
+ int removeStatus = mDrmManager.removeRights(assetUri);
+ logMessage("removeRights = " + removeStatus + "\n");
+
+ return removeStatus;
+ }
+
+ public int removeAllRights() {
+ int removeAllStatus = mDrmManager.removeAllRights();
+ logMessage("removeAllRights = " + removeAllStatus + "\n");
+ return removeAllStatus;
+ }
+
+ public void setLogListener(WidevineDrmLogEventListener logEventListener) {
+ this.logEventListener = logEventListener;
+ }
+
+ private void logMessage(String message) {
+ logBuffer.append(message);
+
+ if (logEventListener != null) {
+ logEventListener.logUpdated();
+ }
+ }
+}
diff --git a/proprietary/samplePlayer/src/com/widevine/demo/WidevineSamplePlayer.java b/proprietary/samplePlayer/src/com/widevine/demo/WidevineSamplePlayer.java
new file mode 100644
index 00000000..ec47ebd8
--- /dev/null
+++ b/proprietary/samplePlayer/src/com/widevine/demo/WidevineSamplePlayer.java
@@ -0,0 +1,86 @@
+/*
+ * (c)Copyright 2011 Widevine Technologies, Inc
+ */
+
+package com.widevine.demo;
+
+import android.app.TabActivity;
+import android.os.Bundle;
+import android.widget.TabHost;
+import android.content.Intent;
+import android.content.SharedPreferences;
+
+public class WidevineSamplePlayer extends TabActivity {
+
+ public static final String PREFS_NAME = "DrmPrefs";
+
+ /** 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();
+
+ // 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);
+
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+
+ // We need an Editor object to make preference changes.
+ // All objects are from android.context.Context
+ SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
+
+ 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();
+ }
+
+}
diff --git a/test/WidevineDemo DRM framework.apk b/test/WidevineDemo DRM framework.apk
deleted file mode 100644
index 0af066eb..00000000
Binary files a/test/WidevineDemo DRM framework.apk and /dev/null differ