Skip to content

Commit

Permalink
ENGR00252971 Test_DualPlayback : add a dual video playback app
Browse files Browse the repository at this point in the history
add a dual video playback app

Signed-off-by: Huang Chenyi  <[email protected]>
  • Loading branch information
Huang Chenyi committed Mar 8, 2013
1 parent 86431b8 commit 49a5243
Show file tree
Hide file tree
Showing 17 changed files with 626 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Test_DualPlayback/Android.mk
Original file line number Diff line number Diff line change
@@ -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))
31 changes: 31 additions & 0 deletions Test_DualPlayback/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.freescale.test_dualplayback"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.freescale.test_dualplayback.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.freescale.test_dualplayback.SecondActivity"
android:label="@string/title_activity_second" >
</activity>
</application>

</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions Test_DualPlayback/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textview0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Spinner
android:id="@+id/spinner0"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:drawSelectorOnTop="true"
/>
<TextView
android:id="@+id/textview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Spinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:drawSelectorOnTop="true"
/>
<Button
android:id="@+id/firstActivityButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />



</LinearLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
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.
-->

<!-- See corresponding Java code PresentationWithMediaRouterActivity.java. -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">






<!-- Some content for visual interest in the case where no presentation is showing. -->
<VideoView android:id="@+id/videoview1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0" />
<VideoView android:id="@+id/videoview2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="10" />


</LinearLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project
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.
-->

<!-- The content that we show on secondary displays.
See corresponding Java code PresentationWithMediaRouterActivity.java. -->

<VideoView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/videoview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
9 changes: 9 additions & 0 deletions Test_DualPlayback/res/menu/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
android:id="@+id/menu_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/menu_settings"/>

</menu>
9 changes: 9 additions & 0 deletions Test_DualPlayback/res/menu/activity_second.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
android:id="@+id/menu_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/menu_settings"/>

</menu>
11 changes: 11 additions & 0 deletions Test_DualPlayback/res/values-v11/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<resources>

<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>

</resources>
12 changes: 12 additions & 0 deletions Test_DualPlayback/res/values-v14/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<resources>

<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>

</resources>
9 changes: 9 additions & 0 deletions Test_DualPlayback/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Test_DualPlayback</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_second">SecondActivity</string>

</resources>
20 changes: 20 additions & 0 deletions Test_DualPlayback/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>
Original file line number Diff line number Diff line change
@@ -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<String> 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<String>();
for(fileIndex = 0;fileIndex < FileNameInDir.length;fileIndex++){
VideoFileList.add("/storage/emulated/legacy" + "/" + FileNameInDir[fileIndex]);
}
ArrayAdapter<String> adapter0 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, VideoFileList);
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(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);

}

}
Loading

0 comments on commit 49a5243

Please sign in to comment.