我在尝试将音频录制到文件时遇到问题。我正在尝试运行示例代码(在tiapp.xml中具有所需的权限)但我总是得到错误(例如“+ [NSBlock boundBridge:withKrollObject:]:无法识别的选择器发送到类0x1b5549500”;在停止()行动)。
我找不到录音模块(我已经使用了tutorial.audiorecord,但它在最新版本的SDK中不起作用)
这是来自appcelerator文档页面https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.AudioRecorder的示例代码
我尝试了一切但不起作用。
有人为Appcelerator SDK 7提供了工作示例或模块吗?
var window = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var recordStart = Ti.UI.createButton({
title: 'Start',
top: 10
});
var recordPause = Ti.UI.createButton({
title: 'Pause',
top: 60
});
var recordStop = Ti.UI.createButton({
title: 'Stop',
top: 110
});
var recordPlay = Ti.UI.createButton({
title: 'Play',
top: 160
});
var audioRecorder = Ti.Media.createAudioRecorder();
var record;
var audioPlayer;
window.addEventListener('open', function(e) {
if (!Ti.Media.hasAudioRecorderPermissions()) {
Ti.Media.requestAudioRecorderPermissions(function(e) {
if (e.success) {
window.add(recordStart);
}
});
} else {
window.add(recordStart);
}
});
recordStart.addEventListener('click', function(e) {
audioRecorder.start();
});
recordPause.addEventListener('click', function(e) {
if (audioRecorder.getPaused()) {
recordPause.setTitle('Pause');
audioRecorder.resume();
} else {
recordPause.setTitle('Resume');
audioRecorder.pause();
}
});
recordStop.addEventListener('click', function(e) {
record = audioRecorder.stop();
Ti.API.info(record.getNativePath());
});
recordPlay.addEventListener('click', function(e) {
audioPlayer = Ti.Media.createAudioPlayer({
url: record.getNativePath()
});
audioPlayer.start();
});
window.add(recordPause);
window.add(recordStop);
window.add(recordPlay);
window.open();
提前致谢
这是使用Titanium的Hyperloop的一个例子:https://gist.github.com/dinahgarcia/119ac00c91334d3951601cf347bad8d4为了能够使用它,你需要启用Hyperloop:https://docs.appcelerator.com/platform/latest/#!/guide/Enabling_Hyperloop