|
| 1 | +[](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 | +``` |
0 commit comments