Skip to content

Commit d2d1f17

Browse files
committed
0.0.1
0 parents  commit d2d1f17

34 files changed

+786
-0
lines changed

.gitignore

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

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[![Release](https://jitpack.io/v/adrielcafe/AndroidAudioConverter.svg)](https://jitpack.io/#adrielcafe/AndroidAudioConverter)
2+
3+
# AndroidAudioConverter
4+
5+
> Convert audio files inside your Android app easily. This is a wrapper of [FFmpeg-Android-Java](https://github.com/WritingMinds/ffmpeg-android-java) lib.
6+
7+
Supported formats:
8+
* WAV
9+
* AAC
10+
* MP3
11+
* M4A
12+
* WMA
13+
* FLAC
14+
15+
## How To Use
16+
17+
1 - Add these permissions into your `AndroidManifest.xml` and [request for them in Android 6.0+](https://developer.android.com/training/permissions/requesting.html)
18+
```xml
19+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
20+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
21+
```
22+
23+
2 - Load the lib inside your `Application` class
24+
```java
25+
public class App extends Application {
26+
@Override
27+
public void onCreate() {
28+
super.onCreate();
29+
AndroidAudioConverter.load(this, new IInitCallback() {
30+
@Override
31+
public void onSuccess() {
32+
// Great!
33+
}
34+
@Override
35+
public void onFailure(FFmpegNotSupportedException error) {
36+
// FFmpeg is not supported by device
37+
}
38+
});
39+
}
40+
}
41+
```
42+
43+
3 - Convert audio files async
44+
```java
45+
File wavFile = new File(Environment.getExternalStorageDirectory(), "my_audio.wav");
46+
AndroidAudioConverter.convert(this,
47+
wavFile, // Your current audio file
48+
AndroidAudioConverter.AudioFormat.AAC, // Your desired audio format
49+
new IConvertCallback() {
50+
@Override
51+
public void onSuccess(File convertedFile) {
52+
// So fast? Love it!
53+
}
54+
@Override
55+
public void onFailure(Exception error) {
56+
// Oops! Somethin went wrong
57+
}
58+
});
59+
```
60+
61+
## Import to your project
62+
Put this into your `app/build.gradle`:
63+
```
64+
repositories {
65+
maven {
66+
url "https://jitpack.io"
67+
}
68+
}
69+
70+
dependencies {
71+
compile 'com.github.adrielcafe:AndroidAudioConverter:0.0.1'
72+
}
73+
```
74+
75+
## Dependencies
76+
* [FFmpeg-Android-Java](https://github.com/WritingMinds/ffmpeg-android-java)
77+
78+
## Want to RECORD AUDIO into your app?
79+
**Take a look at [AndroidAudioRecorder](https://github.com/adrielcafe/AndroidAudioRecorder)!**
80+
81+
## License
82+
```
83+
The MIT License (MIT)
84+
85+
Copyright (c) 2016 Adriel Café
86+
87+
Permission is hereby granted, free of charge, to any person obtaining a copy
88+
of this software and associated documentation files (the "Software"), to deal
89+
in the Software without restriction, including without limitation the rights
90+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
91+
copies of the Software, and to permit persons to whom the Software is
92+
furnished to do so, subject to the following conditions:
93+
94+
The above copyright notice and this permission notice shall be included in
95+
all copies or substantial portions of the Software.
96+
97+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
98+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
99+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
100+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
101+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
102+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
103+
THE SOFTWARE.
104+
```

app/.gitignore

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

app/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 24
5+
buildToolsVersion "24.0.1"
6+
defaultConfig {
7+
applicationId "cafe.adriel.androidaudioconverter.sample"
8+
minSdkVersion 16
9+
targetSdkVersion 24
10+
versionCode 1
11+
versionName "1.0"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
compile fileTree(dir: 'libs', include: ['*.jar'])
23+
compile project(':lib')
24+
compile 'com.android.support:appcompat-v7:24.2.0'
25+
}

app/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/adrielcafe/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+
#}

app/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="cafe.adriel.androidaudioconverter.sample">
4+
5+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
7+
8+
<application
9+
android:name=".App"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:theme="@style/AppTheme">
13+
<activity android:name=".MainActivity">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cafe.adriel.androidaudioconverter.sample;
2+
3+
import android.app.Application;
4+
5+
import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException;
6+
7+
import cafe.adriel.androidaudiorecorder.AndroidAudioConverter;
8+
import cafe.adriel.androidaudiorecorder.callback.IInitCallback;
9+
10+
public class App extends Application {
11+
@Override
12+
public void onCreate() {
13+
super.onCreate();
14+
AndroidAudioConverter.load(this, new IInitCallback() {
15+
@Override
16+
public void onSuccess() {
17+
// Great!
18+
}
19+
@Override
20+
public void onFailure(FFmpegNotSupportedException error) {
21+
// FFmpeg is not supported by device
22+
error.printStackTrace();
23+
}
24+
});
25+
}
26+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package cafe.adriel.androidaudioconverter.sample;
2+
3+
import android.os.Bundle;
4+
import android.os.Environment;
5+
import android.support.v7.app.AppCompatActivity;
6+
import android.util.Log;
7+
8+
import java.io.File;
9+
10+
import cafe.adriel.androidaudiorecorder.AndroidAudioConverter;
11+
import cafe.adriel.androidaudiorecorder.callback.IConvertCallback;
12+
13+
public class MainActivity extends AppCompatActivity {
14+
15+
@Override
16+
protected void onCreate(Bundle savedInstanceState) {
17+
super.onCreate(savedInstanceState);
18+
setContentView(R.layout.activity_main);
19+
20+
/**
21+
* Update with a valid audio file!
22+
* Supported formats: {@link AndroidAudioConverter.AudioFormat}
23+
*/
24+
File wavFile = new File(Environment.getExternalStorageDirectory(), "my_audio.wav");
25+
26+
AndroidAudioConverter.convert(this, wavFile, AndroidAudioConverter.AudioFormat.AAC, new IConvertCallback() {
27+
@Override
28+
public void onSuccess(File convertedFile) {
29+
Log.d("SUCCESS", convertedFile.getPath());
30+
}
31+
32+
@Override
33+
public void onFailure(Exception error) {
34+
error.printStackTrace();
35+
}
36+
});
37+
}
38+
39+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:id="@+id/activity_main"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:paddingBottom="@dimen/activity_vertical_margin"
8+
android:paddingLeft="@dimen/activity_horizontal_margin"
9+
android:paddingRight="@dimen/activity_horizontal_margin"
10+
android:paddingTop="@dimen/activity_vertical_margin"
11+
tools:context="cafe.adriel.androidaudioconverter.sample.MainActivity">
12+
13+
</RelativeLayout>
3.34 KB
Loading

0 commit comments

Comments
 (0)