Does anyone know when Titanium will support Android audio recording?
Spent an hour trying to get audio recording to work on Android then realized it was not yet supported. However, I need it for the app I am working on and would hate to start over on iPhone. Any idea if this will be supported in the next release?
3 Answers
-
I just spent a few hours also discovering that the promise of a cross-platform API has not quite been realized yet on Titanium. Looking at Jeff's blog, doesn't look like it will be included in release 1.5 which will be available in a couple weeks. Shoot! I need this functionality.
-
Now recording is possible on Android, natively, without Intents.
We just released the Audio Recorder Titanium Module for Android.
You can see more details on Codeboxed Titanium Audio Recorder Module
Follow us on Twitter: @codeboxed for more updates. -
Hi ,
You can try it with this code
var win = Titanium.UI.createWindow({
title: 'Video Recording from Appcelerator Titanium',
backgroundColor: '#fff'
});// const value grabbed from
// http://developer.android.com/reference/android/provider/MediaStore.Audio.Media.html#RECORD_SOUND_ACTION
var RECORD_SOUND_ACTION = "android.provider.MediaStore.RECORD_SOUND";
var soundUri = null; // Will be set as a result of recording action.var recordButton = Titanium.UI.createButton({
top: 10, left: 10, right: 10, height: 35, title: "Record Audio"
});
var labelResultCaption = Titanium.UI.createLabel({
top: 50, left: 10, right: 10, height: 35, visible: false, color: 'yellow'
});
var labelResult = Titanium.UI.createLabel({
top: 90, left: 10, right: 10, height: 100, visible: false,
backgroundColor: 'white', color: 'black',
verticalAlign: 'top'
});var shareButton = Titanium.UI.createButton({
top: 50, left: 10, right: 10, height: 35,
title: 'Share Recorded Video', visible: false
});
win.add(shareButton);
var saveButton = Titanium.UI.createButton({
top: 100, left: 10, right: 10, height: 35,
title: 'Save Recorded Video', visible: false
});
win.add(saveButton);recordButton.addEventListener('click', function()
{
var intent = Titanium.Android.createIntent({ action: RECORD_SOUND_ACTION });
Titanium.Android.currentActivity.startActivityForResult(intent, function(e)
{
if (e.error)
{
Titanium.UI.createNotification({
duration: Titanium.UI.NOTIFICATION_DURATION_LONG,
message: 'Error: ' + e.error
}).show();
}
else
{
if (e.resultCode === Titanium.Android.RESULT_OK)
{
soundUri = e.intent.data;
Titanium.UI.createNotification({
duration: Titanium.UI.NOTIFICATION_DURATION_LONG,
message: 'Video captured; now share or save it!'
}).show();
// note that this isn't a physical file! it's a URI in to the MediaStore.
shareButton.visible = true;
saveButton.visible = true;
}
else
{
Titanium.UI.createNotification({
duration: Titanium.UI.NOTIFICATION_DURATION_LONG,
message: 'Canceled/Error? Result code: ' + e.resultCode
}).show();
}
}
});
});
saveButton.addEventListener('click', function()
{
var source = Titanium.Filesystem.getFile(soundUri);
var target = Titanium.Filesystem.getFile('appdata://harsh.amr');
// note: source.exists() will return false, because this is a URI into the MediaStore.
// BUT we can still call "copy" to save the data to an actual file
source.copy(target.nativePath);Ti.UI.createNotification({ duration: Titanium.UI.NOTIFICATION_DURATION_LONG, message: 'Saved to: ' + target.nativePath }).show();
});
shareButton.addEventListener('click', function()
{
var intent = Titanium.Android.createIntent({
action: Titanium.Android.ACTION_SEND,
type: 'audio/amr'
});
intent.putExtraUri(Titanium.Android.EXTRA_STREAM, soundUri);
Titanium.Android.currentActivity.startActivity(
Titanium.Android.createIntentChooser(intent, 'Send Video via'));
});win.add(recordButton);
win.add(labelResultCaption);
win.add(labelResult);
win.open();