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

Add android Oreo support. #8

Merged
merged 1 commit into from Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions manifest
Expand Up @@ -2,9 +2,9 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 0.4
apiversion: 3
architectures: armeabi-v7a x86
version: 0.5
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86
description: AudioRecorder
author: Karthi ponnusamy
license: Specify your license
Expand All @@ -16,4 +16,4 @@ name: audiorecorder
moduleid: titutorial.audiorecorder
guid: d69ff376-8e98-4f9f-876c-f807e5f50933
platform: android
minsdk: 6.0.0.GA
minsdk: 7.0.1.GA
16 changes: 8 additions & 8 deletions src/titutorial/audiorecorder/AudiorecorderModule.java
Expand Up @@ -45,13 +45,13 @@ public class AudiorecorderModule extends KrollModule

private KrollFunction successCallback = null;
private KrollFunction errorCallback = null;

// Standard Debugging variables
private static final String TAG = "AudiorecorderModule";

// You can define constants with @Kroll.constant, for example:
// @Kroll.constant public static final String EXTERNAL_NAME = value;

public AudiorecorderModule()
{
super();
Expand Down Expand Up @@ -148,7 +148,7 @@ private String getFilename(int selectedFormat, String selectedFileName, String s
//System.out.println("@@## outPutFileName: " + outPutFileName);
System.out.println("@@## chking external storage: " + isExternalStorageWritable());
if(location.equals("internal")){
File audioDirectory = TiApplication.getAppRootOrCurrentActivity().getDir(directoryName, Context.MODE_WORLD_READABLE);
File audioDirectory = new File(TiApplication.getAppRootOrCurrentActivity().getCacheDir(), directoryName);
//System.out.println("@@## audioDirectory.exists(): " + audioDirectory.exists());
if (!audioDirectory.exists()) {
audioDirectory.mkdirs();
Expand Down Expand Up @@ -182,7 +182,7 @@ public void onError(MediaRecorder mr, int what, int extra) {
//System.out.println("@@## Error: " + what + ", " + extra);
}
};

private MediaRecorder.OnInfoListener infoListener = new MediaRecorder.OnInfoListener() {
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
Expand Down Expand Up @@ -221,21 +221,21 @@ public void startRecording(HashMap args) {
fileLocation = (String) options.get("fileLocation");
}
//System.out.println("@@## fileLocation : " + fileLocation);
String outputFileName = getFilename(fileFormat, fileName, fileDirectory, "external");
String outputFileName = getFilename(fileFormat, fileName, fileDirectory, fileLocation);
//System.out.println("@@## outputFileName = "+outputFileName);
if(outputFileName == null || outputFileName == ""){
sendErrorEvent("External storage not available");
return;
}

recorder = new MediaRecorder();

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(fileFormat);
recorder.setAudioEncoder(audioEncoder);
recorder.setAudioEncodingBitRate(audioEncodingBitRate);
recorder.setAudioSamplingRate(audioSamplingRate);

if (options.containsKey("maxDuration")) {
int maxDurValue = options.optInt("maxDuration", 5000);
//System.out.println("@@## maxDurValue : " + maxDurValue);
Expand All @@ -255,7 +255,7 @@ public void startRecording(HashMap args) {
//System.out.println("@@## setMaxFileSize failed !");
}
}

recorder.setOutputFile(outputFileName);
recorder.setOnErrorListener(errorListener);
recorder.setOnInfoListener(infoListener);
Expand Down