Skip to content

Commit

Permalink
0.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
adrielcafe committed Sep 16, 2016
1 parent eba0328 commit 7f13969
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class App extends Application {
// Great!
}
@Override
public void onFailure(FFmpegNotSupportedException error) {
public void onFailure(Exception error) {
// FFmpeg is not supported by device
}
});
Expand All @@ -44,7 +44,7 @@ public class App extends Application {

3 - Convert audio files async
```java
File wavFile = new File(Environment.getExternalStorageDirectory(), "my_audio.flac");
File flacFile = new File(Environment.getExternalStorageDirectory(), "my_audio.flac");
IConvertCallback callback = new IConvertCallback() {
@Override
public void onSuccess(File convertedFile) {
Expand All @@ -57,11 +57,15 @@ IConvertCallback callback = new IConvertCallback() {
};
AndroidAudioConverter.with(this)
// Your current audio file
.setFile(wavFile)
.setFile(flacFile)

// Your desired audio format
.setFormat(AndroidAudioConverter.AudioFormat.MP3)
.setFormat(AudioFormat.MP3)

// An callback to know when conversion is finished
.setCallback(callback)

// Start conversion
.convert();
```

Expand All @@ -75,7 +79,7 @@ repositories {
}
dependencies {
compile 'com.github.adrielcafe:AndroidAudioConverter:0.0.7'
compile 'com.github.adrielcafe:AndroidAudioConverter:0.0.8'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import cafe.adriel.androidaudioconverter.AndroidAudioConverter;
import cafe.adriel.androidaudioconverter.callback.IConvertCallback;
import cafe.adriel.androidaudioconverter.model.AudioFormat;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -48,7 +49,7 @@ public void onFailure(Exception error) {
Toast.makeText(this, "Converting audio file...", Toast.LENGTH_SHORT).show();
AndroidAudioConverter.with(this)
.setFile(wavFile)
.setFormat(AndroidAudioConverter.AudioFormat.MP3)
.setFormat(AudioFormat.MP3)
.setCallback(callback)
.convert();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,10 @@

import cafe.adriel.androidaudioconverter.callback.IConvertCallback;
import cafe.adriel.androidaudioconverter.callback.ILoadCallback;
import cafe.adriel.androidaudioconverter.model.AudioFormat;

public class AndroidAudioConverter {

public enum AudioFormat {
AAC,
MP3,
M4A,
WMA,
WAV,
FLAC;

@Override
public String toString() {
return name().toLowerCase();
}
}

private static boolean loaded;

private Context context;
Expand Down Expand Up @@ -142,7 +129,7 @@ public void onFinish() {

private static File getConvertedFile(File originalFile, AudioFormat format){
String[] f = originalFile.getPath().split("\\.");
String filePath = originalFile.getPath().replace(f[f.length - 1], format.toString());
String filePath = originalFile.getPath().replace(f[f.length - 1], format.getFormat());
return new File(filePath);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cafe.adriel.androidaudioconverter.model;

public enum AudioFormat {
AAC,
MP3,
M4A,
WMA,
WAV,
FLAC;

public String getFormat() {
return name().toLowerCase();
}
}

0 comments on commit 7f13969

Please sign in to comment.