Merge "Rework WidevineSamplePlayer to use fragments" into nyc-dev
This commit is contained in:
@@ -9,7 +9,23 @@ LOCAL_DEX_PREOPT := false
|
|||||||
|
|
||||||
LOCAL_PACKAGE_NAME := WidevineSamplePlayer
|
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
|
LOCAL_SDK_VERSION := current
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.widevine.demo"
|
package="com.widevine.demo">
|
||||||
>
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
|
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="24" />
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.Holo.NoActionBar">
|
<application
|
||||||
|
android:icon="@drawable/icon"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/Theme.AppCompat.NoActionBar">
|
||||||
|
|
||||||
<activity android:name=".WidevineSamplePlayer"
|
<activity android:name=".WidevineSamplePlayer"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:screenOrientation="landscape">
|
android:screenOrientation="landscape">
|
||||||
@@ -15,6 +19,7 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".VideoPlayerView"
|
<activity android:name=".VideoPlayerView"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:screenOrientation="landscape">
|
android:screenOrientation="landscape">
|
||||||
@@ -22,30 +27,6 @@
|
|||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".StreamingActivity"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:screenOrientation="landscape">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".DownloadActivity"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:screenOrientation="landscape">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".SettingsActivity"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
android:screenOrientation="landscape">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -3,5 +3,11 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<TextView android:id="@+id/textView1" android:text="@string/no_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="24pt" android:background="@drawable/background3" android:gravity="center"></TextView>
|
<TextView android:id="@+id/textView1"
|
||||||
|
android:text="@string/no_content"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:textSize="24pt"
|
||||||
|
android:background="@drawable/background3"
|
||||||
|
android:gravity="center"></TextView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -1,21 +1,27 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@android:id/tabhost"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="4dip"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<LinearLayout
|
|
||||||
android:orientation="vertical"
|
<android.support.design.widget.TabLayout
|
||||||
|
android:id="@+id/tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:tabMaxWidth="0dp"
|
||||||
|
app:tabGravity="fill"
|
||||||
|
app:tabMode="fixed">
|
||||||
|
</android.support.design.widget.TabLayout>
|
||||||
|
|
||||||
|
<android.support.v4.view.ViewPager
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
>
|
android:layout_weight="1">
|
||||||
<TabWidget
|
</android.support.v4.view.ViewPager>
|
||||||
android:id="@android:id/tabs"
|
|
||||||
android:layout_width="fill_parent"
|
</LinearLayout>
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@android:id/tabcontent"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
|
||||||
</TabHost>
|
|
||||||
|
|||||||
@@ -73,8 +73,8 @@
|
|||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
android:text="@string/update_button"
|
android:text="@string/save_settings"
|
||||||
android:id="@+id/update_button"
|
android:id="@+id/save_settings"
|
||||||
/>
|
/>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|||||||
@@ -13,10 +13,13 @@
|
|||||||
<string name="show_rights">Show Rights</string>
|
<string name="show_rights">Show Rights</string>
|
||||||
<string name="streaming">Streaming</string>
|
<string name="streaming">Streaming</string>
|
||||||
<string name="downloads">Downloads</string>
|
<string name="downloads">Downloads</string>
|
||||||
|
<string name="settings">Settings</string>
|
||||||
|
|
||||||
<string name="content_page">Content Page</string>
|
<string name="content_page">Content Page</string>
|
||||||
<string name="device_id">Device Id</string>
|
<string name="device_id">Device Id</string>
|
||||||
<string name="drm_server">Drm Server</string>
|
<string name="drm_server">Drm Server</string>
|
||||||
<string name="portal_id">Portal Name</string>
|
<string name="portal_id">Portal Name</string>
|
||||||
<string name="update_button">Update Button</string>
|
<string name="save_settings">Save Settings</string>
|
||||||
|
<string name="next_page">Next Page >></string>
|
||||||
|
<string name="previous_page"><< Previous Page</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
@@ -9,56 +9,63 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Gravity;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.View;
|
|
||||||
import android.util.Log;
|
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.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
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";
|
public static final String TAG = "WVM Sample Player";
|
||||||
|
|
||||||
private int currentPage;
|
private int currentPage;
|
||||||
protected ArrayList<AssetsPage> pages;
|
protected ArrayList<AssetsPage> pages;
|
||||||
private Context context;
|
private View mView;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the fragment is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater,
|
||||||
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
context = this;
|
mView = inflater.inflate(R.layout.empty, container, false);
|
||||||
|
|
||||||
initialize();
|
currentPage = 0;
|
||||||
|
pages = new ArrayList<AssetsPage>();
|
||||||
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initialize() {
|
@Override
|
||||||
currentPage = 0;
|
public void onActivityCreated(Bundle bundle) {
|
||||||
|
super.onActivityCreated(bundle);
|
||||||
pages = new ArrayList<AssetsPage>();
|
|
||||||
|
|
||||||
if (setUpAssetPages()) {
|
if (setUpAssetPages()) {
|
||||||
setContentView(createView(this));
|
createView();
|
||||||
} else {
|
|
||||||
setContentView(R.layout.empty);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean setUpAssetPages();
|
protected abstract boolean setUpAssetPages();
|
||||||
|
|
||||||
private View createView(Context ctxt) {
|
private void createView() {
|
||||||
ImageView empty = new ImageView(this);
|
|
||||||
empty.setBackground(getResources().getDrawable(R.drawable.empty, context.getTheme()));
|
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];
|
View[] clips = new View[6];
|
||||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
@@ -69,22 +76,22 @@ public abstract class AssetActivity extends Activity {
|
|||||||
for (int i = 0; i < page.getPageCount(); i++) {
|
for (int i = 0; i < page.getPageCount(); i++) {
|
||||||
|
|
||||||
AssetItem assetItem = page.getPage(i);
|
AssetItem assetItem = page.getPage(i);
|
||||||
clips[i] = createViewItem(getBitmapFromAssetItem(assetItem), assetItem.getAssetPath(),
|
clips[i] = createViewItem(getBitmapFromAssetItem(assetItem),
|
||||||
assetItem.getTitle());
|
assetItem.getAssetPath(), assetItem.getTitle());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT, 1);
|
LinearLayout.LayoutParams.MATCH_PARENT, 1);
|
||||||
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
|
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
|
||||||
|
|
||||||
LinearLayout.LayoutParams paramsMain = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams paramsMain = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT, 1);
|
LinearLayout.LayoutParams.MATCH_PARENT, 1);
|
||||||
paramsMain.gravity = Gravity.CENTER;
|
paramsMain.gravity = Gravity.CENTER;
|
||||||
|
|
||||||
LinearLayout left = new LinearLayout(ctxt);
|
LinearLayout left = new LinearLayout(getActivity());
|
||||||
left.setOrientation(LinearLayout.VERTICAL);
|
left.setOrientation(LinearLayout.VERTICAL);
|
||||||
if (clips[0] != null) {
|
if (clips[0] != null) {
|
||||||
left.addView(clips[0], params);
|
left.addView(clips[0], params);
|
||||||
@@ -95,7 +102,7 @@ public abstract class AssetActivity extends Activity {
|
|||||||
left.addView(createEmptyView(), params);
|
left.addView(createEmptyView(), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearLayout middle = new LinearLayout(ctxt);
|
LinearLayout middle = new LinearLayout(getActivity());
|
||||||
middle.setOrientation(LinearLayout.VERTICAL);
|
middle.setOrientation(LinearLayout.VERTICAL);
|
||||||
if (clips[1] != null) {
|
if (clips[1] != null) {
|
||||||
middle.addView(clips[1], params);
|
middle.addView(clips[1], params);
|
||||||
@@ -106,7 +113,7 @@ public abstract class AssetActivity extends Activity {
|
|||||||
middle.addView(createEmptyView(), params);
|
middle.addView(createEmptyView(), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinearLayout right = new LinearLayout(ctxt);
|
LinearLayout right = new LinearLayout(getActivity());
|
||||||
right.setOrientation(LinearLayout.VERTICAL);
|
right.setOrientation(LinearLayout.VERTICAL);
|
||||||
if (clips[2] != null) {
|
if (clips[2] != null) {
|
||||||
right.addView(clips[2], params);
|
right.addView(clips[2], params);
|
||||||
@@ -119,7 +126,7 @@ public abstract class AssetActivity extends Activity {
|
|||||||
}
|
}
|
||||||
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
|
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
|
||||||
|
|
||||||
LinearLayout body = new LinearLayout(ctxt);
|
LinearLayout body = new LinearLayout(getActivity());
|
||||||
|
|
||||||
body.addView(left, paramsMain);
|
body.addView(left, paramsMain);
|
||||||
body.addView(middle, paramsMain);
|
body.addView(middle, paramsMain);
|
||||||
@@ -129,18 +136,17 @@ public abstract class AssetActivity extends Activity {
|
|||||||
View.OnClickListener nextButtonListener = new View.OnClickListener() {
|
View.OnClickListener nextButtonListener = new View.OnClickListener() {
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
currentPage++;
|
|
||||||
Log.d(TAG, "Click next page: " + currentPage);
|
Log.d(TAG, "Click next page: " + currentPage);
|
||||||
if (currentPage >= pages.size()) {
|
if (currentPage < pages.size() - 1) {
|
||||||
currentPage = 0;
|
currentPage++;
|
||||||
|
createView();
|
||||||
}
|
}
|
||||||
setContentView(createView(context));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Button next = new Button(this);
|
Button next = new Button(getActivity());
|
||||||
next.setText(">>");
|
next.setText(R.string.next_page);
|
||||||
next.setTextSize(10);
|
next.setTextSize(14);
|
||||||
next.setOnClickListener(nextButtonListener);
|
next.setOnClickListener(nextButtonListener);
|
||||||
|
|
||||||
// Previous button listener
|
// Previous button listener
|
||||||
@@ -148,53 +154,48 @@ public abstract class AssetActivity extends Activity {
|
|||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
currentPage--;
|
|
||||||
Log.d(TAG, "Click prev page: " + currentPage);
|
Log.d(TAG, "Click prev page: " + currentPage);
|
||||||
if (currentPage < 0) {
|
if (currentPage > 0) {
|
||||||
currentPage = pages.size() - 1;
|
currentPage--;
|
||||||
|
createView();
|
||||||
}
|
}
|
||||||
setContentView(createView(context));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Button prev = new Button(this);
|
Button prev = new Button(getActivity());
|
||||||
prev.setText("<<");
|
prev.setText(R.string.previous_page);
|
||||||
prev.setTextSize(10);
|
prev.setTextSize(14);
|
||||||
prev.setOnClickListener(prevButtonListener);
|
prev.setOnClickListener(prevButtonListener);
|
||||||
|
|
||||||
LinearLayout buttons = new LinearLayout(this);
|
LinearLayout buttons = new LinearLayout(getActivity());
|
||||||
buttons.addView(prev, params);
|
buttons.addView(prev, params);
|
||||||
buttons.addView(next, params);
|
buttons.addView(next, params);
|
||||||
|
|
||||||
body.setBackground(this.getResources().getDrawable(R.drawable.background3,
|
body.setBackground(getActivity().getResources().getDrawable(R.drawable.background3,
|
||||||
context.getTheme()));
|
getActivity().getTheme()));
|
||||||
|
|
||||||
SwipeLinearLayout main = new SwipeLinearLayout(this);
|
mainLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
main.setNext(nextButtonListener);
|
mainLayout.addView(body, params);
|
||||||
main.setPrev(prevButtonListener);
|
|
||||||
main.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
main.addView(body, params);
|
|
||||||
|
|
||||||
LinearLayout.LayoutParams paramButtons = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams paramButtons = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||||
paramButtons.gravity = Gravity.CENTER;
|
paramButtons.gravity = Gravity.CENTER;
|
||||||
|
|
||||||
main.addView(buttons, paramButtons);
|
mainLayout.addView(buttons, paramButtons);
|
||||||
return main;
|
viewGroup.addView(mainLayout, paramsMain);
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createEmptyView() {
|
private View createEmptyView() {
|
||||||
ImageView empty = new ImageView(this);
|
ImageView empty = new ImageView(getActivity());
|
||||||
empty.setBackground(getResources().getDrawable(R.drawable.empty, context.getTheme()));
|
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 params = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT, 1);
|
LinearLayout.LayoutParams.WRAP_CONTENT, 1);
|
||||||
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
|
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
|
||||||
LinearLayout body = new LinearLayout(this);
|
LinearLayout body = new LinearLayout(getActivity());
|
||||||
|
|
||||||
body.setOrientation(LinearLayout.VERTICAL);
|
body.setOrientation(LinearLayout.VERTICAL);
|
||||||
body.addView(empty, params);
|
body.addView(empty, params);
|
||||||
@@ -208,30 +209,31 @@ public abstract class AssetActivity extends Activity {
|
|||||||
|
|
||||||
final String assetPath = path;
|
final String assetPath = path;
|
||||||
|
|
||||||
ClipImageView clip = new ClipImageView(this);
|
ClipImageView clip = new ClipImageView(getActivity());
|
||||||
|
|
||||||
clip.setImageBitmap(image);
|
clip.setImageBitmap(image);
|
||||||
|
clip.setBackgroundColor(0);
|
||||||
|
|
||||||
// Set the onClick listener for each image
|
// Set the onClick listener for each image
|
||||||
clip.setOnClickListener(new View.OnClickListener() {
|
clip.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Log.d(TAG, "Click Asset path: " + assetPath);
|
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);
|
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);
|
text.setText((title == null) ? path : title);
|
||||||
|
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT, 1);
|
LinearLayout.LayoutParams.WRAP_CONTENT, 1);
|
||||||
params.gravity = Gravity.CENTER;
|
params.gravity = Gravity.CENTER;
|
||||||
LinearLayout body = new LinearLayout(this);
|
LinearLayout body = new LinearLayout(getActivity());
|
||||||
|
|
||||||
body.setOrientation(LinearLayout.VERTICAL);
|
body.setOrientation(LinearLayout.VERTICAL);
|
||||||
body.addView(clip, params);
|
body.addView(clip, params);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
@@ -7,8 +7,11 @@ package com.widevine.demo;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.util.ArrayList;
|
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() {
|
protected boolean setUpAssetPages() {
|
||||||
pages = new ArrayList<AssetsPage>();
|
pages = new ArrayList<AssetsPage>();
|
||||||
@@ -32,6 +35,23 @@ public class DownloadActivity extends AssetActivity {
|
|||||||
private File[] getDownloadedClips() {
|
private File[] getDownloadedClips() {
|
||||||
|
|
||||||
File file = new File("/sdcard/Widevine");
|
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() {
|
FilenameFilter filter = new FilenameFilter() {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
@@ -47,7 +67,5 @@ public class DownloadActivity extends AssetActivity {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return file.listFiles(filter);
|
return file.listFiles(filter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,41 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import android.content.Context;
|
public class SettingsFragment extends Fragment {
|
||||||
|
|
||||||
public class SettingsActivity extends Activity {
|
|
||||||
// public static String CONTENT_PAGE = "/sdcard/Widevine/config.xml";
|
// public static String CONTENT_PAGE = "/sdcard/Widevine/config.xml";
|
||||||
public static String CONTENT_PAGE = "http://storage.googleapis.com/wvmedia/html/oem.html";
|
public static String CONTENT_PAGE = "http://storage.googleapis.com/wvmedia/html/oem.html";
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private Button updateButton;
|
private Button updateButton;
|
||||||
private EditText drmServer, portalName, deviceId, contentPage;
|
private EditText drmServer, portalName, deviceId, contentPage;
|
||||||
|
|
||||||
public static final String TAG = "WVM Player Settings";
|
public static final String TAG = "WVM Player Settings";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater,
|
||||||
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
context = this;
|
View rootView = inflater.inflate(R.layout.settings, container, false);
|
||||||
|
|
||||||
setContentView(R.layout.settings);
|
updateButton = (Button)rootView.findViewById(R.id.save_settings);
|
||||||
|
|
||||||
updateButton = (Button) findViewById(R.id.update_button);
|
|
||||||
|
|
||||||
View.OnClickListener clickListener = new View.OnClickListener() {
|
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.DRM_SERVER_URI = drmServer.getText().toString();
|
||||||
WidevineDrm.Settings.DEVICE_ID = deviceId.getText().toString();
|
WidevineDrm.Settings.DEVICE_ID = deviceId.getText().toString();
|
||||||
WidevineDrm.Settings.PORTAL_NAME = portalName.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)
|
builder.setMessage("DRM Settings Updated").setCancelable(false)
|
||||||
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
@@ -61,18 +58,18 @@ public class SettingsActivity extends Activity {
|
|||||||
|
|
||||||
updateButton.setOnClickListener(clickListener);
|
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);
|
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);
|
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);
|
portalName.setText(WidevineDrm.Settings.PORTAL_NAME);
|
||||||
|
|
||||||
contentPage = (EditText) findViewById(R.id.content_page);
|
contentPage = (EditText)rootView.findViewById(R.id.content_page);
|
||||||
contentPage.setText(SettingsActivity.CONTENT_PAGE);
|
contentPage.setText(SettingsFragment.CONTENT_PAGE);
|
||||||
|
|
||||||
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
@@ -10,24 +10,13 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class StreamingActivity extends AssetActivity {
|
public class StreamingFragment extends AssetFragment {
|
||||||
private String contentPage;
|
private String contentPage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
contentPage = SettingsActivity.CONTENT_PAGE;
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
contentPage = SettingsFragment.CONTENT_PAGE;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
if (!contentPage.equals(SettingsActivity.CONTENT_PAGE)) {
|
|
||||||
contentPage = SettingsActivity.CONTENT_PAGE;
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean setUpAssetPages() {
|
protected boolean setUpAssetPages() {
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -33,7 +33,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class VideoPlayerView extends Activity {
|
public class VideoPlayerView extends AppCompatActivity {
|
||||||
private final static String TAG = "VideoPlayerView";
|
private final static String TAG = "VideoPlayerView";
|
||||||
|
|
||||||
private final static float BUTTON_FONT_SIZE = 10;
|
private final static float BUTTON_FONT_SIZE = 10;
|
||||||
@@ -44,13 +44,11 @@ public class VideoPlayerView extends Activity {
|
|||||||
|
|
||||||
private WidevineDrm drm;
|
private WidevineDrm drm;
|
||||||
private FullScreenVideoView videoView;
|
private FullScreenVideoView videoView;
|
||||||
private MediaCodecView mediaCodecView;
|
|
||||||
private String assetUri;
|
private String assetUri;
|
||||||
private TextView logs;
|
private TextView logs;
|
||||||
private ScrollView scrollView;
|
private ScrollView scrollView;
|
||||||
private Context context;
|
private Context context;
|
||||||
private ClipImageView bgImage;
|
private ClipImageView bgImage;
|
||||||
private Button mediaCodecModeButton;
|
|
||||||
private Button playButton;
|
private Button playButton;
|
||||||
private Button fullScreen;
|
private Button fullScreen;
|
||||||
private Handler hRefresh;
|
private Handler hRefresh;
|
||||||
@@ -58,7 +56,6 @@ public class VideoPlayerView extends Activity {
|
|||||||
private LinearLayout main;
|
private LinearLayout main;
|
||||||
private LinearLayout sidePanel;
|
private LinearLayout sidePanel;
|
||||||
private boolean enteringFullScreen;
|
private boolean enteringFullScreen;
|
||||||
private boolean useMediaCodec;
|
|
||||||
private int width, height;
|
private int width, height;
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -69,7 +66,6 @@ public class VideoPlayerView extends Activity {
|
|||||||
height = display.getHeight();
|
height = display.getHeight();
|
||||||
width = display.getWidth();
|
width = display.getWidth();
|
||||||
context = this;
|
context = this;
|
||||||
useMediaCodec = false;
|
|
||||||
contentView = createView();
|
contentView = createView();
|
||||||
if (drm.isProvisionedDevice()) {
|
if (drm.isProvisionedDevice()) {
|
||||||
setContentView(contentView);
|
setContentView(contentView);
|
||||||
@@ -87,11 +83,6 @@ public class VideoPlayerView extends Activity {
|
|||||||
stopPlayback();
|
stopPlayback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mediaCodecView != null) {
|
|
||||||
if (mediaCodecView.isPlaying()) {
|
|
||||||
stopPlayback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,16 +144,10 @@ public class VideoPlayerView extends Activity {
|
|||||||
|
|
||||||
FrameLayout playerFrame = new FrameLayout(this);
|
FrameLayout playerFrame = new FrameLayout(this);
|
||||||
|
|
||||||
View view;
|
videoView = new FullScreenVideoView(this);
|
||||||
if (useMediaCodec) {
|
|
||||||
mediaCodecView = new MediaCodecView(this);
|
|
||||||
view = mediaCodecView;
|
|
||||||
} else {
|
|
||||||
videoView = new FullScreenVideoView(this);
|
|
||||||
view = videoView;
|
|
||||||
}
|
|
||||||
|
|
||||||
playerFrame.addView(view, new FrameLayout.LayoutParams(
|
videoView.setVisibility(View.INVISIBLE);
|
||||||
|
playerFrame.addView(videoView, new FrameLayout.LayoutParams(
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
LinearLayout.LayoutParams.WRAP_CONTENT,
|
||||||
FrameLayout.LayoutParams.MATCH_PARENT));
|
FrameLayout.LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
@@ -174,7 +159,6 @@ public class VideoPlayerView extends Activity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Log.d(TAG, "Click play (start playback).");
|
Log.d(TAG, "Click play (start playback).");
|
||||||
startPlayback();
|
startPlayback();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -211,8 +195,8 @@ public class VideoPlayerView extends Activity {
|
|||||||
FrameLayout.LayoutParams.WRAP_CONTENT));
|
FrameLayout.LayoutParams.WRAP_CONTENT));
|
||||||
fullScreen.setVisibility(View.INVISIBLE);
|
fullScreen.setVisibility(View.INVISIBLE);
|
||||||
playerFrame.addView(bgImage, new FrameLayout.LayoutParams(
|
playerFrame.addView(bgImage, new FrameLayout.LayoutParams(
|
||||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||||
FrameLayout.LayoutParams.WRAP_CONTENT));
|
FrameLayout.LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
main = new LinearLayout(this);
|
main = new LinearLayout(this);
|
||||||
main.addView(playerFrame, new LinearLayout.LayoutParams((int)(width * 0.65),
|
main.addView(playerFrame, new LinearLayout.LayoutParams((int)(width * 0.65),
|
||||||
@@ -227,23 +211,14 @@ public class VideoPlayerView extends Activity {
|
|||||||
private void startPlayback() {
|
private void startPlayback() {
|
||||||
logMessage("Playback start.");
|
logMessage("Playback start.");
|
||||||
playButton.setText(R.string.stop);
|
playButton.setText(R.string.stop);
|
||||||
|
|
||||||
bgImage.setVisibility(View.GONE);
|
bgImage.setVisibility(View.GONE);
|
||||||
|
videoView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (useMediaCodec) {
|
videoView.setVideoPath(assetUri);
|
||||||
mediaCodecView.setDataSource(
|
videoView.setMediaController(new MediaController(context));
|
||||||
this,
|
|
||||||
Uri.parse(assetUri),
|
|
||||||
null /* headers */,
|
|
||||||
true /* encrypted */);
|
|
||||||
|
|
||||||
mediaCodecView.setMediaController(new MediaController(context));
|
videoView.setOnErrorListener(new OnErrorListener() {
|
||||||
mediaCodecView.requestFocus();
|
|
||||||
mediaCodecView.start();
|
|
||||||
} else {
|
|
||||||
videoView.setVideoPath(assetUri);
|
|
||||||
videoView.setMediaController(new MediaController(context));
|
|
||||||
|
|
||||||
videoView.setOnErrorListener(new OnErrorListener() {
|
|
||||||
public boolean onError(MediaPlayer mp, int what, int extra) {
|
public boolean onError(MediaPlayer mp, int what, int extra) {
|
||||||
String message = "Unknown error: " + what;
|
String message = "Unknown error: " + what;
|
||||||
switch (what) {
|
switch (what) {
|
||||||
@@ -261,18 +236,19 @@ public class VideoPlayerView extends Activity {
|
|||||||
|
|
||||||
updateLogs();
|
updateLogs();
|
||||||
bgImage.setVisibility(View.VISIBLE);
|
bgImage.setVisibility(View.VISIBLE);
|
||||||
|
videoView.setVisibility(View.INVISIBLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
videoView.setOnCompletionListener(new OnCompletionListener() {
|
videoView.setOnCompletionListener(new OnCompletionListener() {
|
||||||
public void onCompletion(MediaPlayer mp) {
|
public void onCompletion(MediaPlayer mp) {
|
||||||
Log.d(TAG, "onCompletion.");
|
Log.d(TAG, "onCompletion.");
|
||||||
stopPlayback();
|
stopPlayback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
videoView.setOnInfoListener(new OnInfoListener() {
|
videoView.setOnInfoListener(new OnInfoListener() {
|
||||||
public boolean onInfo(MediaPlayer mp, int what, int extra) {
|
public boolean onInfo(MediaPlayer mp, int what, int extra) {
|
||||||
|
|
||||||
String message = "Unknown info message";
|
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()) {
|
if (videoView.getFullScreen()) {
|
||||||
sidePanel.setVisibility(View.GONE);
|
sidePanel.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
sidePanel.setVisibility(View.VISIBLE);
|
sidePanel.setVisibility(View.VISIBLE);
|
||||||
}
|
|
||||||
|
|
||||||
fullScreen.setVisibility(View.VISIBLE);
|
|
||||||
videoView.setFullScreenDimensions(contentView.getRight() - contentView.getLeft(),
|
|
||||||
contentView.getBottom() - contentView.getTop());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fullScreen.setVisibility(View.VISIBLE);
|
||||||
|
videoView.setFullScreenDimensions(contentView.getRight() - contentView.getLeft(),
|
||||||
|
contentView.getBottom() - contentView.getTop());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopPlayback() {
|
private void stopPlayback() {
|
||||||
logMessage("Stop Playback.");
|
logMessage("Stop Playback.");
|
||||||
playButton.setText(R.string.play);
|
playButton.setText(R.string.play);
|
||||||
bgImage.setVisibility(View.VISIBLE);
|
bgImage.setVisibility(View.VISIBLE);
|
||||||
|
videoView.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
if (useMediaCodec) {
|
videoView.stopPlayback();
|
||||||
mediaCodecView.reset();
|
|
||||||
} else {
|
|
||||||
videoView.stopPlayback();
|
|
||||||
|
|
||||||
fullScreen.setVisibility(View.INVISIBLE);
|
fullScreen.setVisibility(View.INVISIBLE);
|
||||||
if (videoView.getFullScreen() && !enteringFullScreen) {
|
if (videoView.getFullScreen() && !enteringFullScreen) {
|
||||||
videoView.setVisibility(View.INVISIBLE);
|
videoView.setVisibility(View.INVISIBLE);
|
||||||
videoView.setFullScreen(false);
|
videoView.setFullScreen(false);
|
||||||
videoView.setVisibility(View.VISIBLE);
|
sidePanel.setVisibility(View.VISIBLE);
|
||||||
sidePanel.setVisibility(View.VISIBLE);
|
fullScreen.setText(FULLSCREEN);
|
||||||
fullScreen.setText(FULLSCREEN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
enteringFullScreen = false;
|
enteringFullScreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createButtons() {
|
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 = new Button(this);
|
||||||
playButton.setText(R.string.play);
|
playButton.setText(R.string.play);
|
||||||
playButton.setTextSize(BUTTON_FONT_SIZE);
|
playButton.setTextSize(BUTTON_FONT_SIZE);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|||||||
@@ -1,85 +1,95 @@
|
|||||||
/*
|
/*
|
||||||
* (c)Copyright 2011 Widevine Technologies, Inc
|
* (c)Copyright 2011 Google, Inc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.widevine.demo;
|
package com.widevine.demo;
|
||||||
|
|
||||||
import android.app.TabActivity;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.widget.TabHost;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
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";
|
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) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(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);
|
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
|
@Override
|
||||||
protected void onStop() {
|
public Fragment getItem(int i) {
|
||||||
super.onStop();
|
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.
|
@Override
|
||||||
// All objects are from android.context.Context
|
public int getCount() {
|
||||||
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences.Editor editor = settings.edit();
|
@Override
|
||||||
editor.putString("drmServer", WidevineDrm.Settings.DRM_SERVER_URI);
|
public CharSequence getPageTitle(int position) {
|
||||||
editor.putString("deviceId", WidevineDrm.Settings.DEVICE_ID);
|
int tabNameIds[] = {R.string.streaming, R.string.downloads, R.string.settings};
|
||||||
editor.putString("portalId", WidevineDrm.Settings.PORTAL_NAME);
|
return context.getResources().getText(tabNameIds[position]);
|
||||||
editor.putString("contentPage", SettingsActivity.CONTENT_PAGE);
|
}
|
||||||
// Commit the edits!
|
}
|
||||||
editor.commit();
|
|
||||||
|
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user