Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlayerManager #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
compileSdkVersion 29
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "cafe.adriel.androidaudiorecorder.example"
minSdkVersion 15
targetSdkVersion 24
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand All @@ -19,9 +19,8 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:24.2.1'
compile project(':lib')
// compile 'com.github.adrielcafe:AndroidAudioRecorder:0.1.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
}

repositories {
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:4.0.1'
}
}

allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Aug 25 11:20:16 BRT 2016
#Fri Jul 24 22:18:11 IST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
15 changes: 8 additions & 7 deletions lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
compileSdkVersion 29
buildToolsVersion "24.0.3"

defaultConfig {
minSdkVersion 15
targetSdkVersion 24
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand All @@ -19,7 +19,8 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.kailashdabhi:om-recorder:1.1.0'
compile 'com.cleveroad:audiovisualization:1.0.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.kailashdabhi:om-recorder:1.1.5'
implementation 'com.cleveroad:audiovisualization:1.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,105 +11,105 @@
import cafe.adriel.androidaudiorecorder.model.AudioSource;

public class AndroidAudioRecorder {

protected static final String EXTRA_FILE_PATH = "filePath";
protected static final String EXTRA_COLOR = "color";
protected static final String EXTRA_SOURCE = "source";
protected static final String EXTRA_CHANNEL = "channel";
protected static final String EXTRA_SAMPLE_RATE = "sampleRate";
protected static final String EXTRA_AUTO_START = "autoStart";
protected static final String EXTRA_KEEP_DISPLAY_ON = "keepDisplayOn";

private Activity activity;
private Fragment fragment;

private String filePath = Environment.getExternalStorageDirectory() + "/recorded_audio.wav";
private AudioSource source = AudioSource.MIC;
private AudioChannel channel = AudioChannel.STEREO;
private AudioSampleRate sampleRate = AudioSampleRate.HZ_44100;
private int color = Color.parseColor("#546E7A");
private int requestCode = 0;
private boolean autoStart = false;
private boolean keepDisplayOn = false;

private AndroidAudioRecorder(Activity activity) {
this.activity = activity;
}

private AndroidAudioRecorder(Fragment fragment) {
this.fragment = fragment;
}

public static AndroidAudioRecorder with(Activity activity) {
return new AndroidAudioRecorder(activity);
}

public static AndroidAudioRecorder with(Fragment fragment) {
return new AndroidAudioRecorder(fragment);
}

public AndroidAudioRecorder setFilePath(String filePath) {
this.filePath = filePath;
return this;
}

public AndroidAudioRecorder setColor(int color) {
this.color = color;
return this;
}

public AndroidAudioRecorder setRequestCode(int requestCode) {
this.requestCode = requestCode;
return this;
}

public AndroidAudioRecorder setSource(AudioSource source) {
this.source = source;
return this;
}

public AndroidAudioRecorder setChannel(AudioChannel channel) {
this.channel = channel;
return this;
}

public AndroidAudioRecorder setSampleRate(AudioSampleRate sampleRate) {
this.sampleRate = sampleRate;
return this;
}

public AndroidAudioRecorder setAutoStart(boolean autoStart) {
this.autoStart = autoStart;
return this;
}

public AndroidAudioRecorder setKeepDisplayOn(boolean keepDisplayOn) {
this.keepDisplayOn = keepDisplayOn;
return this;
}

public void record() {
Intent intent = new Intent(activity, AudioRecorderActivity.class);
intent.putExtra(EXTRA_FILE_PATH, filePath);
intent.putExtra(EXTRA_COLOR, color);
intent.putExtra(EXTRA_SOURCE, source);
intent.putExtra(EXTRA_CHANNEL, channel);
intent.putExtra(EXTRA_SAMPLE_RATE, sampleRate);
intent.putExtra(EXTRA_AUTO_START, autoStart);
intent.putExtra(EXTRA_KEEP_DISPLAY_ON, keepDisplayOn);
activity.startActivityForResult(intent, requestCode);
}

public void recordFromFragment() {
Intent intent = new Intent(fragment.getActivity(), AudioRecorderActivity.class);
intent.putExtra(EXTRA_FILE_PATH, filePath);
intent.putExtra(EXTRA_COLOR, color);
intent.putExtra(EXTRA_SOURCE, source);
intent.putExtra(EXTRA_CHANNEL, channel);
intent.putExtra(EXTRA_SAMPLE_RATE, sampleRate);
intent.putExtra(EXTRA_AUTO_START, autoStart);
intent.putExtra(EXTRA_KEEP_DISPLAY_ON, keepDisplayOn);
fragment.startActivityForResult(intent, requestCode);
}

}
protected static final String EXTRA_FILE_PATH = "filePath";
protected static final String EXTRA_COLOR = "color";
protected static final String EXTRA_SOURCE = "source";
protected static final String EXTRA_CHANNEL = "channel";
protected static final String EXTRA_SAMPLE_RATE = "sampleRate";
protected static final String EXTRA_AUTO_START = "autoStart";
protected static final String EXTRA_KEEP_DISPLAY_ON = "keepDisplayOn";
private Activity activity;
private Fragment fragment;
private String filePath = Environment.getExternalStorageDirectory() + "/recorded_audio.wav";
private AudioSource source = AudioSource.MIC;
private AudioChannel channel = AudioChannel.STEREO;
private AudioSampleRate sampleRate = AudioSampleRate.HZ_44100;
private int color = Color.parseColor("#546E7A");
private int requestCode = 0;
private boolean autoStart = false;
private boolean keepDisplayOn = false;
private AndroidAudioRecorder(Activity activity) {
this.activity = activity;
}
private AndroidAudioRecorder(Fragment fragment) {
this.fragment = fragment;
}
public static AndroidAudioRecorder with(Activity activity) {
return new AndroidAudioRecorder(activity);
}
public static AndroidAudioRecorder with(Fragment fragment) {
return new AndroidAudioRecorder(fragment);
}
public AndroidAudioRecorder setFilePath(String filePath) {
this.filePath = filePath;
return this;
}
public AndroidAudioRecorder setColor(int color) {
this.color = color;
return this;
}
public AndroidAudioRecorder setRequestCode(int requestCode) {
this.requestCode = requestCode;
return this;
}
public AndroidAudioRecorder setSource(AudioSource source) {
this.source = source;
return this;
}
public AndroidAudioRecorder setChannel(AudioChannel channel) {
this.channel = channel;
return this;
}
public AndroidAudioRecorder setSampleRate(AudioSampleRate sampleRate) {
this.sampleRate = sampleRate;
return this;
}
public AndroidAudioRecorder setAutoStart(boolean autoStart) {
this.autoStart = autoStart;
return this;
}
public AndroidAudioRecorder setKeepDisplayOn(boolean keepDisplayOn) {
this.keepDisplayOn = keepDisplayOn;
return this;
}
public void record() {
Intent intent = new Intent(activity, AudioRecorderActivity.class);
intent.putExtra(EXTRA_FILE_PATH, filePath);
intent.putExtra(EXTRA_COLOR, color);
intent.putExtra(EXTRA_SOURCE, source);
intent.putExtra(EXTRA_CHANNEL, channel);
intent.putExtra(EXTRA_SAMPLE_RATE, sampleRate);
intent.putExtra(EXTRA_AUTO_START, autoStart);
intent.putExtra(EXTRA_KEEP_DISPLAY_ON, keepDisplayOn);
activity.startActivityForResult(intent, requestCode);
}
public void recordFromFragment() {
Intent intent = new Intent(fragment.getActivity(), AudioRecorderActivity.class);
intent.putExtra(EXTRA_FILE_PATH, filePath);
intent.putExtra(EXTRA_COLOR, color);
intent.putExtra(EXTRA_SOURCE, source);
intent.putExtra(EXTRA_CHANNEL, channel);
intent.putExtra(EXTRA_SAMPLE_RATE, sampleRate);
intent.putExtra(EXTRA_AUTO_START, autoStart);
intent.putExtra(EXTRA_KEEP_DISPLAY_ON, keepDisplayOn);
fragment.startActivityForResult(intent, requestCode);
}
}
Loading