("SoundRecorder" in the code snippets below is just a "namespace" for
recording related stuff and the two last params are callback functions
- of which none is called...)
If I do
SoundRecorder.currentRecordingMedia = new Media("samplefile1.mp3",
onRecordSuccess, onRecordError);
SoundRecorder.currentRecordingMedia.startAudioRecord();
, I get "Cannot use audio file from resource". If I do
SoundRecorder.currentRecordingMedia = new Media(null,
onRecordSuccess, onRecordError);
SoundRecorder.currentRecordingMedia.startAudioRecord();
, I get log lines like this:
2011-04-30 19:58:26.550 <appname>[385:707] Will use resource
'documents://1304186306504' from the documents folder.
2011-04-30 19:58:26.570 <appname>[385:707] Failed to initialize
AVAudioPlayer: Error Domain=NSOSStatusErrorDomain Code=-43 "The
operation couldn’t be completed. (OSStatus error -43.)"
2011-04-30 19:58:26.580 <appname>[385:707] Will use resource
'documents://1304186306504' from the documents folder.
[Switching to thread 11779]
2011-04-30 19:58:27.411 <appname>[385:707] Started recording audio
sample 'documents://1304186306504'
and when doing stopAudioRecord() at the end of recording (when I want
to store to file):
2011-04-30 19:58:42.369 <appname>[385:707] Will use resource
'documents://1304186306504' from the documents folder.
2011-04-30 19:58:42.374 <appname>[385:707] Stopped recording audio
sample 'documents://1304186306504'
2011-04-30 19:58:42.788 <appname>[385:707] Unknown resource '/var/
mobile/Applications/E690DB48-D065-4D97-9365-XXXX9347/Documents/
1304186306504'
2011-04-30 19:58:42.792 <appname>[385:707] Cannot use audio file from
resource '/var/mobile/Applications/E690DB48-D065-4D97-9365-XXXX39347/
Documents/1304186306504'
2011-04-30 19:58:42.795 <appname>[385:707] Finished recording audio
sample 'documents://1304186306504'
As mentioned my callbacks are not called. Above testing and logs are
from testing on device from Xcode, but similar with emulator.
I guess what I need is just a push in the right direction (I see the
"IOS quirks" in http://docs.phonegap.com/phonegap_media_media.md.html mention that files must exist?) on how to specify the files and paths
and how to access them again, for playing and possibly sending them to
the plugin mentioned above (but plain PCM might also do for my use
case, but would be nice to save some space on the user's behalf!).
The second method you're using should work (the first method, btw,
should work, but you're not actually encoding an mp3 so the file name
is wrong... AFAIK, there is no free way to record/encode mp3s on the
ipad). Can you play the audio file despite all the error messages?
TBH, I don't think the recording callbacks actually work. Looking at
them, there is an alert() in there and that certainly never gets
fired.
Cheers,
Matt
On Apr 30, 11:12 am, Sondre <sondre.bjorneb...@gmail.com> wrote:
> ("SoundRecorder" in the code snippets below is just a "namespace" for
> recording related stuff and the two last params are callback functions
> - of which none is called...)
> If I do
> SoundRecorder.currentRecordingMedia = new Media("samplefile1.mp3",
> onRecordSuccess, onRecordError);
> SoundRecorder.currentRecordingMedia.startAudioRecord();
> , I get "Cannot use audio file from resource". If I do
> SoundRecorder.currentRecordingMedia = new Media(null,
> onRecordSuccess, onRecordError);
> SoundRecorder.currentRecordingMedia.startAudioRecord();
> , I get log lines like this:
> 2011-04-30 19:58:26.550 <appname>[385:707] Will use resource
> 'documents://1304186306504' from the documents folder.
> 2011-04-30 19:58:26.570 <appname>[385:707] Failed to initialize
> AVAudioPlayer: Error Domain=NSOSStatusErrorDomain Code=-43 "The
> operation couldn’t be completed. (OSStatus error -43.)"
> 2011-04-30 19:58:26.580 <appname>[385:707] Will use resource
> 'documents://1304186306504' from the documents folder.
> [Switching to thread 11779]
> 2011-04-30 19:58:27.411 <appname>[385:707] Started recording audio
> sample 'documents://1304186306504'
> and when doing stopAudioRecord() at the end of recording (when I want
> to store to file):
> 2011-04-30 19:58:42.369 <appname>[385:707] Will use resource
> 'documents://1304186306504' from the documents folder.
> 2011-04-30 19:58:42.374 <appname>[385:707] Stopped recording audio
> sample 'documents://1304186306504'
> 2011-04-30 19:58:42.788 <appname>[385:707] Unknown resource '/var/
> mobile/Applications/E690DB48-D065-4D97-9365-XXXX9347/Documents/
> 1304186306504'
> 2011-04-30 19:58:42.792 <appname>[385:707] Cannot use audio file from
> resource '/var/mobile/Applications/E690DB48-D065-4D97-9365-XXXX39347/
> Documents/1304186306504'
> 2011-04-30 19:58:42.795 <appname>[385:707] Finished recording audio
> sample 'documents://1304186306504'
> As mentioned my callbacks are not called. Above testing and logs are
> from testing on device from Xcode, but similar with emulator.
> I guess what I need is just a push in the right direction (I see the
> "IOS quirks" inhttp://docs.phonegap.com/phonegap_media_media.md.html > mention that files must exist?) on how to specify the files and paths
> and how to access them again, for playing and possibly sending them to
> the plugin mentioned above (but plain PCM might also do for my use
> case, but would be nice to save some space on the user's behalf!).
Hi again Matt and others (thanks to Matt for taking the time),
It does matter if I specify a .wav file name, same result and same
error messages (Unknown resource / Cannot use audio file from
resource) when I call Media::play() for the (not) recorded media.
If I just send null (second case above) it turns out it actually does
record despite all error messages, if I do this hack:
when ending recording and then instead of creating a new Media object
for the src name I want, I use the above
SoundRecorder.currentPlayingMedia reference in my play-function, the
iPad actually plays the recorded sound from the last time around.
So how do I go from here to obtain a predictable reference to the
recorded file that can be used as the first param to the Media object
when starting the app the next time? Any takers? :-)
-S-
On May 2, 6:21 pm, mcrider <mattcri...@gmail.com> wrote:
> The second method you're using should work (the first method, btw,
> should work, but you're not actually encoding an mp3 so the file name
> is wrong... AFAIK, there is no free way to record/encode mp3s on the
> ipad). Can you play the audio file despite all the error messages?
> TBH, I don't think the recording callbacks actually work. Looking at
> them, there is an alert() in there and that certainly never gets
> fired.
> Cheers,
> Matt
> On Apr 30, 11:12 am, Sondre <sondre.bjorneb...@gmail.com> wrote:
> > Hi,
> > I am trying to record multiple files (most likely as m4a or mp3), to
> > store for playing later through the same app, on the iPad.
> > ("SoundRecorder" in the code snippets below is just a "namespace" for
> > recording related stuff and the two last params are callback functions
> > - of which none is called...)
> > As mentioned my callbacks are not called. Above testing and logs are
> > from testing on device from Xcode, but similar with emulator.
> > I guess what I need is just a push in the right direction (I see the
> > "IOS quirks" inhttp://docs.phonegap.com/phonegap_media_media.md.html > > mention that files must exist?) on how to specify the files and paths
> > and how to access them again, for playing and possibly sending them to
> > the plugin mentioned above (but plain PCM might also do for my use
> > case, but would be nice to save some space on the user's behalf!).
OK, tested some more and it if I do
JSON.stringify(SoundRecorder.currentRecordingMedia) when stopping the
recording I get something like:
{"src":"documents://1304443600444"}
That (minus the documents:// part) is what Matt's m4a encoder expects
and from there I guess it is just a matter of file renaming to get to
a predictable filename to test on the next time around... But will
also test with a documents:// path from the start of the recording,
suspect that this was my real initial mistake.
-S-
On May 3, 7:06 pm, Sondre <sondre.bjorneb...@gmail.com> wrote:
> Hi again Matt and others (thanks to Matt for taking the time),
> It does matter if I specify a .wav file name, same result and same
> error messages (Unknown resource / Cannot use audio file from
> resource) when I call Media::play() for the (not) recorded media.
> If I just send null (second case above) it turns out it actually does
> record despite all error messages, if I do this hack:
> when ending recording and then instead of creating a new Media object
> for the src name I want, I use the above
> SoundRecorder.currentPlayingMedia reference in my play-function, the
> iPad actually plays the recorded sound from the last time around.
> So how do I go from here to obtain a predictable reference to the
> recorded file that can be used as the first param to the Media object
> when starting the app the next time? Any takers? :-)
> -S-
> On May 2, 6:21 pm, mcrider <mattcri...@gmail.com> wrote:
> > Hi there,
> > The second method you're using should work (the first method, btw,
> > should work, but you're not actually encoding an mp3 so the file name
> > is wrong... AFAIK, there is no free way to record/encode mp3s on the
> > ipad). Can you play the audio file despite all the error messages?
> > TBH, I don't think the recording callbacks actually work. Looking at
> > them, there is an alert() in there and that certainly never gets
> > fired.
> > Cheers,
> > Matt
> > On Apr 30, 11:12 am, Sondre <sondre.bjorneb...@gmail.com> wrote:
> > > Hi,
> > > I am trying to record multiple files (most likely as m4a or mp3), to
> > > store for playing later through the same app, on the iPad.
> > > ("SoundRecorder" in the code snippets below is just a "namespace" for
> > > recording related stuff and the two last params are callback functions
> > > - of which none is called...)
> > > As mentioned my callbacks are not called. Above testing and logs are
> > > from testing on device from Xcode, but similar with emulator.
> > > I guess what I need is just a push in the right direction (I see the
> > > "IOS quirks" inhttp://docs.phonegap.com/phonegap_media_media.md.html > > > mention that files must exist?) on how to specify the files and paths
> > > and how to access them again, for playing and possibly sending them to
> > > the plugin mentioned above (but plain PCM might also do for my use
> > > case, but would be nice to save some space on the user's behalf!).
Just a quick update in case this thread finds someone else in
desperate search for the conclusion:
- As long as the correct path is used (including "documents://"), the
file is stored[1] even if some error messages may appear when
initiating the Media object
- Recording callbacks are *not* called (playback success callback is
called, though) - so don't do anything critical in there (to say the
least)
- The m4a encoder as-is will not work if the encoded m4a-file already
exists in the documents folder (in fact it crashes the app), add tests
and handle appropriately for your app -- either PG side or plugin side
- The m4a encoder adds the extension (so "myRecordring.wav" becomes
"myRecording.wav.m4a"), if you prefer to replace it, replace
- You need to call startAudioRecord()/stopAudioRecord() not
startRecord()/stopRecord() on IOS
Cheers,
-S-
[1] - To see the documents folder, access your application in Xcode
Organizer and click the arrow on the right of "Application Data" to
transfer to a local folder.
On May 3, 7:58 pm, Sondre <sondre.bjorneb...@gmail.com> wrote:
> OK, tested some more and it if I do
> JSON.stringify(SoundRecorder.currentRecordingMedia) when stopping the
> recording I get something like:
> {"src":"documents://1304443600444"}
> That (minus the documents:// part) is what Matt's m4a encoder expects
> and from there I guess it is just a matter of file renaming to get to
> a predictable filename to test on the next time around... But will
> also test with a documents:// path from the start of the recording,
> suspect that this was my real initial mistake.
> -S-
> On May 3, 7:06 pm, Sondre <sondre.bjorneb...@gmail.com> wrote:
> > Hi again Matt and others (thanks to Matt for taking the time),
> > It does matter if I specify a .wav file name, same result and same
> > error messages (Unknown resource / Cannot use audio file from
> > resource) when I call Media::play() for the (not) recorded media.
> > If I just send null (second case above) it turns out it actually does
> > record despite all error messages, if I do this hack:
> > when ending recording and then instead of creating a new Media object
> > for the src name I want, I use the above
> > SoundRecorder.currentPlayingMedia reference in my play-function, the
> > iPad actually plays the recorded sound from the last time around.
> > So how do I go from here to obtain a predictable reference to the
> > recorded file that can be used as the first param to the Media object
> > when starting the app the next time? Any takers? :-)
> > -S-
> > On May 2, 6:21 pm, mcrider <mattcri...@gmail.com> wrote:
> > > Hi there,
> > > The second method you're using should work (the first method, btw,
> > > should work, but you're not actually encoding an mp3 so the file name
> > > is wrong... AFAIK, there is no free way to record/encode mp3s on the
> > > ipad). Can you play the audio file despite all the error messages?
> > > TBH, I don't think the recording callbacks actually work. Looking at
> > > them, there is an alert() in there and that certainly never gets
> > > fired.
> > > > ("SoundRecorder" in the code snippets below is just a "namespace" for
> > > > recording related stuff and the two last params are callback functions
> > > > - of which none is called...)
> > > > As mentioned my callbacks are not called. Above testing and logs are
> > > > from testing on device from Xcode, but similar with emulator.
> > > > I guess what I need is just a push in the right direction (I see the
> > > > "IOS quirks" inhttp://docs.phonegap.com/phonegap_media_media.md.html > > > > mention that files must exist?) on how to specify the files and paths
> > > > and how to access them again, for playing and possibly sending them to
> > > > the plugin mentioned above (but plain PCM might also do for my use
> > > > case, but would be nice to save some space on the user's behalf!).