Note that there are some explanatory texts on larger screens.

plurals
  1. POcordova 1.7 iOS audiorecord plugin
    text
    copied!<p>I've implemented the audio record plugin on IOS using phonegap/cordova 1.7. IOS5.1</p> <p>I'm using it over the standard media.startrecord() function as I want to change the bitrate to reduce the size of the file.</p> <p>It works fine in the simulator.</p> <p>On the real iphone it records successfully once but subsequently refuses.. it seems to work but on playback I'm getting an error 4 MediaError.MEDIA_ERR_NONE_SUPPORTED</p> <p>I've created a new project with just a bare bones record and playback and I'm still getting the same issue.</p> <p>Here's the test code - It's very basic - just a couple of links to record two separate files and play them back. The setTimeout is there to record just a couple of seconds of audio each time.</p> <p>I've googled til I've worn out my fingerprints but haven't found a resolution.</p> <p>Any insight you can give would be very gratefully received. </p> <p>I'm wondering if I'm failing to close out the recording/playback properly? Or are files referenced differently on the sim v the iPhone?</p> <p>Many thanks!</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /&gt; &lt;meta charset="utf-8"&gt; &lt;link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" /&gt; &lt;script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var fs,mediaRec=null, recInterval,recordSettings = {"FormatID": "kAudioFormatULaw","SampleRate": 16000.0,"NumberOfChannels": 1,"LinearPCMBitDepth": 16}; function recfile1() {recordAudio("test.wav");} function recfile2() {recordAudio("test2.wav");} function success(){console.log("ok");} function recordAudio(fname) { fs.root.getFile(fname, {create: true, exclusive: false}, function(entry){ mediaRec = new Media(entry.fullPath, success, function(){alert("failed");}); mediaRec.startRecordWithSettings(recordSettings); recInterval = setTimeout(function() { mediaRec.stopRecordWithSettings(); }, 2000); }, function(){console.log("error");}); } function playfile(fname) { var my_media; fs.root.getFile(fname, {create: false, exclusive: false}, function success(entry) { my_media = new Media(entry.fullPath,function(){console.log("ok");},function(err){alert(err.code+" "+err.message);}); my_media.play(); }, function() { console.log("not found file"); } ); } function onBodyLoad() { document.addEventListener("deviceready", onDeviceReady, false); } function onDeviceReady(){ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){fs=fileSystem;}, function(){console.log("failed");}); Media.prototype.startRecordWithSettings = function(options) { Cordova.exec(null, null, "AudioRecord","startAudioRecord", [this.id, this.src, options]); }; Media.prototype.stopRecordWithSettings = function() { Cordova.exec(null, null, "AudioRecord","stopAudioRecord", [this.id, this.src]); }; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="onBodyLoad()"&gt; &lt;a onclick="playfile('test.wav');"&gt;play&lt;/a&gt; &lt;a style='margin-top:100px;' onclick="recfile1();"&gt;record 1&lt;/a&gt; &lt;a style='margin-top:100px;' onclick="recfile2();"&gt;record 2&lt;/a&gt; &lt;a onclick="playfile('test2.wav');"&gt;play2&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload