Skip to content

Commit de9279f

Browse files
committed
Initial commit
0 parents  commit de9279f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2006
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.gradle
2+
/local.properties
3+
/.idea
4+
.DS_Store
5+
/build
6+
*.iml

build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:0.12.2'
9+
10+
// NOTE: Do not place your application dependencies here; they belong
11+
// in the individual module build.gradle files
12+
}
13+
}
14+
15+
allprojects {
16+
repositories {
17+
jcenter()
18+
}
19+
}

example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

example/build.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 19
5+
buildToolsVersion "19.1.0"
6+
7+
defaultConfig {
8+
applicationId "net.ypresto.androidtranscoder.example"
9+
minSdkVersion 18
10+
targetSdkVersion 19
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
runProguard false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile project(':lib')
24+
compile fileTree(dir: 'libs', include: ['*.jar'])
25+
}

example/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/yuya.tanaka/devel/android-sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package net.ypresto.androidtranscoder;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

example/src/main/AndroidManifest.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="net.ypresto.androidtranscoder.example" >
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@drawable/ic_launcher"
8+
android:label="@string/app_name"
9+
android:theme="@style/AppTheme" >
10+
<activity
11+
android:name=".TranscoderActivity"
12+
android:label="@string/app_name" >
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package net.ypresto.androidtranscoder.example;
2+
3+
import android.app.Activity;
4+
import android.content.ContentResolver;
5+
import android.content.Intent;
6+
import android.net.Uri;
7+
import android.os.Bundle;
8+
import android.os.ParcelFileDescriptor;
9+
import android.util.Log;
10+
import android.view.Menu;
11+
import android.view.MenuItem;
12+
import android.view.View;
13+
import android.widget.Toast;
14+
15+
import net.ypresto.androidtranscoder.MediaTranscoder;
16+
17+
import java.io.File;
18+
import java.io.FileDescriptor;
19+
import java.io.FileNotFoundException;
20+
import java.io.IOException;
21+
22+
23+
public class TranscoderActivity extends Activity {
24+
private static final int REQUEST_CODE_PICK = 1;
25+
26+
@Override
27+
protected void onCreate(Bundle savedInstanceState) {
28+
super.onCreate(savedInstanceState);
29+
setContentView(R.layout.activity_transcoder);
30+
findViewById(R.id.select_video_button).setOnClickListener(new View.OnClickListener() {
31+
@Override
32+
public void onClick(View v) {
33+
startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).setType("video/*"), REQUEST_CODE_PICK);
34+
}
35+
});
36+
}
37+
38+
@Override
39+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
40+
switch (requestCode) {
41+
case REQUEST_CODE_PICK: {
42+
final File file;
43+
if (resultCode == RESULT_OK) {
44+
try {
45+
file = File.createTempFile("transcode_test_", ".mp4", getExternalCacheDir());
46+
} catch (IOException e) {
47+
Toast.makeText(this, "Failed to create temporary file.", Toast.LENGTH_LONG).show();
48+
return;
49+
}
50+
ContentResolver resolver = getContentResolver();
51+
final ParcelFileDescriptor parcelFileDescriptor;
52+
try {
53+
parcelFileDescriptor = resolver.openFileDescriptor(data.getData(), "r");
54+
} catch (FileNotFoundException e) {
55+
Log.w("Could not open '" + data.getDataString() + "'", e);
56+
Toast.makeText(TranscoderActivity.this, "File not found.", Toast.LENGTH_LONG).show();
57+
return;
58+
}
59+
final FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
60+
MediaTranscoder.getInstance().transcodeVideo(fileDescriptor, file.getAbsolutePath(), new MediaTranscoder.Listener() {
61+
@Override
62+
public void onTranscodeCompleted() {
63+
startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.fromFile(file), "video/mp4"));
64+
try {
65+
parcelFileDescriptor.close();
66+
} catch (IOException e) {
67+
Log.w("Error while closing", e);
68+
}
69+
}
70+
71+
@Override
72+
public void onTranscodeFailed(Exception exception) {
73+
Toast.makeText(TranscoderActivity.this, "Transcoder error occurred.", Toast.LENGTH_LONG).show();
74+
try {
75+
parcelFileDescriptor.close();
76+
} catch (IOException e) {
77+
Log.w("Error while closing", e);
78+
}
79+
}
80+
});
81+
}
82+
break;
83+
}
84+
default:
85+
super.onActivityResult(requestCode, resultCode, data);
86+
}
87+
}
88+
89+
@Override
90+
public boolean onCreateOptionsMenu(Menu menu) {
91+
// Inflate the menu; this adds items to the action bar if it is present.
92+
getMenuInflater().inflate(R.menu.transcoder, menu);
93+
return true;
94+
}
95+
96+
@Override
97+
public boolean onOptionsItemSelected(MenuItem item) {
98+
// Handle action bar item clicks here. The action bar will
99+
// automatically handle clicks on the Home/Up button, so long
100+
// as you specify a parent activity in AndroidManifest.xml.
101+
int id = item.getItemId();
102+
if (id == R.id.action_settings) {
103+
return true;
104+
}
105+
return super.onOptionsItemSelected(item);
106+
}
107+
}
Loading
Loading
Loading
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical"
6+
android:paddingBottom="@dimen/activity_vertical_margin"
7+
android:paddingLeft="@dimen/activity_horizontal_margin"
8+
android:paddingRight="@dimen/activity_horizontal_margin"
9+
android:paddingTop="@dimen/activity_vertical_margin"
10+
tools:context=".TranscoderActivity">
11+
12+
<TextView
13+
android:layout_width="wrap_content"
14+
android:layout_height="wrap_content"
15+
android:layout_gravity="center_horizontal"
16+
android:text="@string/hello_world" />
17+
18+
<Button
19+
android:id="@+id/select_video_button"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"
22+
android:layout_gravity="center_horizontal"
23+
android:text="Select Video File" />
24+
25+
</LinearLayout>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
tools:context=".TranscoderActivity" >
4+
<item android:id="@+id/action_settings"
5+
android:title="@string/action_settings"
6+
android:orderInCategory="100"
7+
android:showAsAction="never" />
8+
</menu>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources>
2+
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
3+
(such as screen margins) for screens with more than 820dp of available width. This
4+
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
5+
<dimen name="activity_horizontal_margin">64dp</dimen>
6+
</resources>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
<!-- Default screen margins, per the Android Design guidelines. -->
3+
<dimen name="activity_horizontal_margin">16dp</dimen>
4+
<dimen name="activity_vertical_margin">16dp</dimen>
5+
</resources>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="app_name">AndroidTranscoder</string>
5+
<string name="hello_world">Hello world!</string>
6+
<string name="action_settings">Settings</string>
7+
8+
</resources>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
</style>
7+
8+
</resources>

gradle.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Project-wide Gradle settings.
2+
3+
# IDE (e.g. Android Studio) users:
4+
# Settings specified in this file will override any Gradle settings
5+
# configured through the IDE.
6+
7+
# For more details on how to configure your build environment visit
8+
# http://www.gradle.org/docs/current/userguide/build_environment.html
9+
10+
# Specifies the JVM arguments used for the daemon process.
11+
# The setting is particularly useful for tweaking memory settings.
12+
# Default value: -Xmx10248m -XX:MaxPermSize=256m
13+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14+
15+
# When configured, Gradle will run in incubating parallel mode.
16+
# This option should only be used with decoupled projects. More details, visit
17+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18+
# org.gradle.parallel=true

gradle/wrapper/gradle-wrapper.jar

48.7 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Apr 10 15:27:10 PDT 2013
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip

0 commit comments

Comments
 (0)