diff --git a/Test_DualPlayback/Android.mk b/Test_DualPlayback/Android.mk
new file mode 100644
index 0000000..d8b7ba3
--- /dev/null
+++ b/Test_DualPlayback/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := Test_DualPlayback
+
+include $(BUILD_PACKAGE)
+
+# Use the folloing include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/Test_DualPlayback/AndroidManifest.xml b/Test_DualPlayback/AndroidManifest.xml
new file mode 100755
index 0000000..ee7915e
--- /dev/null
+++ b/Test_DualPlayback/AndroidManifest.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Test_DualPlayback/res/drawable-hdpi/ic_launcher.png b/Test_DualPlayback/res/drawable-hdpi/ic_launcher.png
new file mode 100755
index 0000000..0e79b18
Binary files /dev/null and b/Test_DualPlayback/res/drawable-hdpi/ic_launcher.png differ
diff --git a/Test_DualPlayback/res/drawable-ldpi/ic_launcher.png b/Test_DualPlayback/res/drawable-ldpi/ic_launcher.png
new file mode 100755
index 0000000..ebfac7d
Binary files /dev/null and b/Test_DualPlayback/res/drawable-ldpi/ic_launcher.png differ
diff --git a/Test_DualPlayback/res/drawable-mdpi/ic_launcher.png b/Test_DualPlayback/res/drawable-mdpi/ic_launcher.png
new file mode 100755
index 0000000..1183441
Binary files /dev/null and b/Test_DualPlayback/res/drawable-mdpi/ic_launcher.png differ
diff --git a/Test_DualPlayback/res/drawable-xhdpi/ic_launcher.png b/Test_DualPlayback/res/drawable-xhdpi/ic_launcher.png
new file mode 100755
index 0000000..c8ab2a1
Binary files /dev/null and b/Test_DualPlayback/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/Test_DualPlayback/res/layout/activity_main.xml b/Test_DualPlayback/res/layout/activity_main.xml
new file mode 100755
index 0000000..789e56e
--- /dev/null
+++ b/Test_DualPlayback/res/layout/activity_main.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Test_DualPlayback/res/layout/presentation_with_media_router_activity.xml b/Test_DualPlayback/res/layout/presentation_with_media_router_activity.xml
new file mode 100755
index 0000000..d657720
--- /dev/null
+++ b/Test_DualPlayback/res/layout/presentation_with_media_router_activity.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Test_DualPlayback/res/layout/presentation_with_media_router_content.xml b/Test_DualPlayback/res/layout/presentation_with_media_router_content.xml
new file mode 100755
index 0000000..732060e
--- /dev/null
+++ b/Test_DualPlayback/res/layout/presentation_with_media_router_content.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
diff --git a/Test_DualPlayback/res/menu/activity_main.xml b/Test_DualPlayback/res/menu/activity_main.xml
new file mode 100755
index 0000000..77f358b
--- /dev/null
+++ b/Test_DualPlayback/res/menu/activity_main.xml
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/Test_DualPlayback/res/menu/activity_second.xml b/Test_DualPlayback/res/menu/activity_second.xml
new file mode 100755
index 0000000..77f358b
--- /dev/null
+++ b/Test_DualPlayback/res/menu/activity_second.xml
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/Test_DualPlayback/res/values-v11/styles.xml b/Test_DualPlayback/res/values-v11/styles.xml
new file mode 100755
index 0000000..541752f
--- /dev/null
+++ b/Test_DualPlayback/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Test_DualPlayback/res/values-v14/styles.xml b/Test_DualPlayback/res/values-v14/styles.xml
new file mode 100755
index 0000000..f20e015
--- /dev/null
+++ b/Test_DualPlayback/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Test_DualPlayback/res/values/strings.xml b/Test_DualPlayback/res/values/strings.xml
new file mode 100755
index 0000000..4a7f8b8
--- /dev/null
+++ b/Test_DualPlayback/res/values/strings.xml
@@ -0,0 +1,9 @@
+
+
+
+ Test_DualPlayback
+ Hello world!
+ Settings
+ SecondActivity
+
+
\ No newline at end of file
diff --git a/Test_DualPlayback/res/values/styles.xml b/Test_DualPlayback/res/values/styles.xml
new file mode 100755
index 0000000..4a10ca4
--- /dev/null
+++ b/Test_DualPlayback/res/values/styles.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Test_DualPlayback/src/com/freescale/test_dualplayback/MainActivity.java b/Test_DualPlayback/src/com/freescale/test_dualplayback/MainActivity.java
new file mode 100755
index 0000000..66a327d
--- /dev/null
+++ b/Test_DualPlayback/src/com/freescale/test_dualplayback/MainActivity.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2007 The Android Open Source Project
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package com.freescale.test_dualplayback;
+
+import java.io.File;
+
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.List;
+
+import android.os.Bundle;
+
+
+import android.app.Activity;
+import android.content.Intent;
+import android.util.Log;
+import android.view.Menu;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+public class MainActivity extends Activity implements OnClickListener
+ {
+ private Button button;
+ private String[] FileNameInDir = null;
+ private List VideoFileList = null;
+ private Spinner s0;
+ private Spinner s1;
+ private TextView textview0;
+ private TextView textview1;
+ private String videoFile0 = "";
+ private String videoFile1 = "";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ textview0 = (TextView)findViewById(R.id.textview0);
+ textview1 = (TextView)findViewById(R.id.textview1);
+ textview0.setText("video displayed on HDMI");
+ textview1.setText("video displayed on LCD");
+
+ File fileDir;
+ int fileIndex = 0;
+ fileDir = new File("/storage/emulated/legacy/");
+ FilenameFilter filter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".mp4")||name.endsWith(".m4v")||name.endsWith(".avi");
+ }
+ };
+ FileNameInDir = fileDir.list(filter);
+ VideoFileList = new ArrayList();
+ for(fileIndex = 0;fileIndex < FileNameInDir.length;fileIndex++){
+ VideoFileList.add("/storage/emulated/legacy" + "/" + FileNameInDir[fileIndex]);
+ }
+ ArrayAdapter adapter0 = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, VideoFileList);
+ ArrayAdapter adapter1 = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, VideoFileList);
+ s0 = (Spinner)findViewById(R.id.spinner0);
+ adapter0.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ s0.setAdapter(adapter0);
+ s1 = (Spinner) findViewById(R.id.spinner1);
+ adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ s1.setAdapter(adapter1);
+ button = (Button)findViewById(R.id.firstActivityButton);
+ button.setText("Play the video");
+ button.setOnClickListener(MainActivity.this);
+
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.activity_main, menu);
+ return true;
+ }
+
+
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ Intent intent = new Intent(this,SecondActivity.class);
+ int selectIndex;
+ selectIndex = s0.getSelectedItemPosition();
+ videoFile0 = "/storage/emulated/legacy" + "/" + FileNameInDir[selectIndex];
+ selectIndex = s1.getSelectedItemPosition();
+ videoFile1 = "/storage/emulated/legacy" + "/" + FileNameInDir[selectIndex];
+ intent.putExtra("videofile0",videoFile0);
+ intent.putExtra("videofile1", videoFile1);
+ startActivity(intent);
+
+ }
+
+}
diff --git a/Test_DualPlayback/src/com/freescale/test_dualplayback/SecondActivity.java b/Test_DualPlayback/src/com/freescale/test_dualplayback/SecondActivity.java
new file mode 100755
index 0000000..56bf061
--- /dev/null
+++ b/Test_DualPlayback/src/com/freescale/test_dualplayback/SecondActivity.java
@@ -0,0 +1,298 @@
+/*
+ * Copyright 2007 The Android Open Source Project
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.freescale.test_dualplayback;
+
+import android.os.Bundle;
+
+import android.app.Activity;
+import android.view.Menu;
+
+import java.io.File;
+
+
+import android.net.Uri;
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+
+import android.app.MediaRouteActionProvider;
+import android.app.Presentation;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.res.Resources;
+import android.media.MediaPlayer;
+import android.media.MediaRouter;
+import android.media.MediaPlayer.OnCompletionListener;
+import android.media.MediaPlayer.OnErrorListener;
+import android.media.MediaPlayer.OnPreparedListener;
+import android.media.MediaRouter.RouteInfo;
+import android.util.Log;
+import android.view.Display;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.TextView;
+import android.widget.VideoView;
+
+public class SecondActivity extends Activity {
+ private final String TAG = "PresentationWithMediaRouterActivity";
+
+ private MediaRouter mMediaRouter;
+ private DemoPresentation mPresentation;
+ private VideoView mvideoview1;
+ private VideoView mvideoview2;
+ private boolean mPaused;
+ private static Uri mUri1;
+ private static Uri mUri2;
+ private String VideoFile = "";
+ private String VideoFile1 = "";
+ /**
+ * Initialization of the Activity after it is first created. Must at least
+ * call {@link android.app.Activity#setContentView setContentView()} to
+ * describe what is to be displayed in the screen.
+ */
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ // Be sure to call the super class.
+ super.onCreate(savedInstanceState);
+ Bundle bundle = this.getIntent().getExtras();
+ VideoFile = bundle.getString("videofile0");
+ VideoFile1 = bundle.getString("videofile1");
+ // Get the media router service.
+ mMediaRouter = (MediaRouter)getSystemService(Context.MEDIA_ROUTER_SERVICE);
+
+ // See assets/res/any/layout/presentation_with_media_router_activity.xml for this
+ // view layout definition, which is being set here as
+ // the content of our screen.
+ setContentView(R.layout.presentation_with_media_router_activity);
+
+ // Set up the surface view for visual interest.
+ mvideoview1 = (VideoView)findViewById(R.id.videoview1);
+ // mSurfaceView.setRenderer(new CubeRenderer(false));
+ // VideoFile = "/storage/emulated/legacy/"+"Mpeg4_SP1_1920x1080_30fps_9346kbps_MP3_48KHz_64kbps_2ch.mp4";
+ // VideoFile1 = "/storage/emulated/legacy/"+"H264_HP41_1920x1088_30fps_55.8Mbps_shields_ter.mp4";
+ mUri1 = Uri.fromFile(new File(VideoFile1));
+ mvideoview2 = (VideoView)findViewById(R.id.videoview2);
+ mUri2 = Uri.fromFile(new File(VideoFile));
+ mvideoview2.setVideoURI(mUri2);
+ mvideoview2.requestFocus();
+ mvideoview2.start();
+ mvideoview2.setOnErrorListener(new MediaPlayer.OnErrorListener(){
+ public boolean onError(MediaPlayer mp, int what, int extra){
+ VideoFile = "/storage/emulated/legacy/"+"Mpeg4_SP1_1920x1080_30fps_9346kbps_MP3_48KHz_64kbps_2ch.mp4";
+ mUri2 = Uri.fromFile(new File(VideoFile));
+ mvideoview2.setVideoURI(mUri2);
+ mvideoview2.start();
+ return true;
+ }
+ } );
+ mvideoview2.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
+ @Override
+public void onCompletion(MediaPlayer mp) {
+ VideoFile = "/storage/emulated/legacy/"+"Mpeg4_SP1_1920x1080_30fps_9346kbps_MP3_48KHz_64kbps_2ch.mp4";
+ mvideoview2.start();
+ }
+ });
+ Log.i(TAG,"onCreate set video0");
+
+ }
+
+ @Override
+ protected void onResume() {
+ // Be sure to call the super class.
+ super.onResume();
+
+ // Listen for changes to media routes.
+ mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO, mMediaRouterCallback);
+
+ // Update the presentation based on the currently selected route.
+ mPaused = false;
+ updatePresentation();
+ }
+
+ @Override
+ protected void onPause() {
+ // Be sure to call the super class.
+ super.onPause();
+
+ // Stop listening for changes to media routes.
+ mMediaRouter.removeCallback(mMediaRouterCallback);
+
+ // Pause rendering.
+ mPaused = true;
+ updateContents();
+ }
+
+ @Override
+ protected void onStop() {
+ // Be sure to call the super class.
+ super.onStop();
+
+ // Dismiss the presentation when the activity is not visible.
+ if (mPresentation != null) {
+ Log.i(TAG, "Dismissing presentation because the activity is no longer visible.");
+ mPresentation.dismiss();
+ mPresentation = null;
+ }
+ }
+ private void updatePresentation() {
+ // Get the current route and its presentation display.
+ MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(
+ MediaRouter.ROUTE_TYPE_LIVE_VIDEO);
+ Display presentationDisplay = route != null ? route.getPresentationDisplay() : null;
+
+ // Dismiss the current presentation if the display has changed.
+ if (mPresentation != null && mPresentation.getDisplay() != presentationDisplay) {
+ Log.i(TAG, "Dismissing presentation because the current route no longer "
+ + "has a presentation display.");
+ mPresentation.dismiss();
+ mPresentation = null;
+ }
+
+ // Show a new presentation if needed.
+ if (mPresentation == null && presentationDisplay != null) {
+ Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
+ mPresentation = new DemoPresentation(this, presentationDisplay);
+ mPresentation.setOnDismissListener(mOnDismissListener);
+ try {
+ mPresentation.show();
+ } catch (WindowManager.InvalidDisplayException ex) {
+ Log.w(TAG, "Couldn't show presentation! Display was removed in "
+ + "the meantime.", ex);
+ mPresentation = null;
+ }
+ }
+
+ // Update the contents playing in this activity.
+ updateContents();
+ }
+
+ private void updateContents() {
+ // Show either the content in the main activity or the content in the presentation
+ // along with some descriptive text about what is happening.
+ if (mPresentation != null) {
+ mvideoview1.setVisibility(View.INVISIBLE);
+ mvideoview1.pause();
+ if (mPaused) {
+ mPresentation.getSurfaceView().pause();
+ } else {
+ mPresentation.getSurfaceView().resume();
+ }
+ } else {
+ mvideoview1.setVisibility(View.VISIBLE);
+ if (mPaused) {
+ mvideoview1.pause();
+ } else {
+ mvideoview1.resume();
+ }
+ }
+ }
+
+ private final MediaRouter.SimpleCallback mMediaRouterCallback =
+ new MediaRouter.SimpleCallback() {
+ @Override
+ public void onRouteSelected(MediaRouter router, int type, RouteInfo info) {
+ Log.d(TAG, "onRouteSelected: type=" + type + ", info=" + info);
+ updatePresentation();
+ }
+
+ @Override
+ public void onRouteUnselected(MediaRouter router, int type, RouteInfo info) {
+ Log.d(TAG, "onRouteUnselected: type=" + type + ", info=" + info);
+ updatePresentation();
+ }
+
+ @Override
+ public void onRoutePresentationDisplayChanged(MediaRouter router, RouteInfo info) {
+ Log.d(TAG, "onRoutePresentationDisplayChanged: info=" + info);
+ updatePresentation();
+ }
+ };
+
+ /**
+ * Listens for when presentations are dismissed.
+ */
+ private final DialogInterface.OnDismissListener mOnDismissListener =
+ new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ if (dialog == mPresentation) {
+ Log.i(TAG, "Presentation was dismissed.");
+ mPresentation = null;
+ updateContents();
+ }
+ }
+ };
+
+ /**
+ * The presentation to show on the secondary display.
+ *
+ * Note that this display may have different metrics from the display on which
+ * the main activity is showing so we must be careful to use the presentation's
+ * own {@link Context} whenever we load resources.
+ *
+ */
+ private final class DemoPresentation extends Presentation {
+ private VideoView mvideoview1;
+
+ public DemoPresentation(Context context, Display display) {
+ super(context, display);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ // Be sure to call the super class.
+ super.onCreate(savedInstanceState);
+
+ // Get the resources for the context of the presentation.
+ // Notice that we are getting the resources from the context of the presentation.
+ Resources r = getContext().getResources();
+
+ // Inflate the layout.
+ setContentView(R.layout.presentation_with_media_router_content);
+
+ // Set up the surface view for visual interest.
+ mvideoview1 = (VideoView)findViewById(R.id.videoview1);
+ mvideoview1.setVideoURI(mUri1);
+ mvideoview1.requestFocus();
+ mvideoview1.start();
+ mvideoview1.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){
+@Override
+ public void onCompletion(MediaPlayer mp) {
+ mvideoview1.start();
+ }
+ });
+ mvideoview1.setOnErrorListener(new MediaPlayer.OnErrorListener(){
+ @Override
+ public boolean onError(MediaPlayer mp, int what, int extra){
+ mUri1 = Uri.fromFile(new File(VideoFile1));
+ mvideoview1.setVideoURI(mUri1);
+ mvideoview1.start();
+ return true;
+ }
+ });
+ }
+
+ public VideoView getSurfaceView() {
+ return mvideoview1;
+ }
+ }
+}
+
+