Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Audio recording and file paths on the iPad
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sondre  
View profile  
 More options Apr 30 2011, 2:12 pm
From: Sondre <sondre.bjorneb...@gmail.com>
Date: Sat, 30 Apr 2011 11:12:15 -0700 (PDT)
Local: Sat, Apr 30 2011 2:12 pm
Subject: Audio recording and file paths on the iPad
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.

I might be using the plugin provided  by Matt Crider at
https://github.com/mcrider/phonegap-plugins/tree/master/iPhone/Record...
to store as m4a, but currently I am having a little hard time with the
js/IOS interaction and paths before getting that far.

("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!).

TIA and Cheers,

-S-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mcrider  
View profile  
 More options May 2 2011, 12:21 pm
From: mcrider <mattcri...@gmail.com>
Date: Mon, 2 May 2011 09:21:00 -0700 (PDT)
Subject: Re: Audio recording and file paths on the iPad
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sondre  
View profile  
 More options May 3 2011, 1:06 pm
From: Sondre <sondre.bjorneb...@gmail.com>
Date: Tue, 3 May 2011 10:06:45 -0700 (PDT)
Local: Tues, May 3 2011 1:06 pm
Subject: Re: Audio recording and file paths on the iPad
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:

        SoundRecorder.currentPlayingMedia =
SoundRecorder.currentRecordingMedia;

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sondre  
View profile  
 More options May 3 2011, 1:58 pm
From: Sondre <sondre.bjorneb...@gmail.com>
Date: Tue, 3 May 2011 10:58:05 -0700 (PDT)
Local: Tues, May 3 2011 1:58 pm
Subject: Re: Audio recording and file paths on the iPad
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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sondre  
View profile  
 More options May 4 2011, 3:29 am
From: Sondre <sondre.bjorneb...@gmail.com>
Date: Wed, 4 May 2011 00:29:58 -0700 (PDT)
Local: Wed, May 4 2011 3:29 am
Subject: Re: Audio recording and file paths on the iPad
Hi,

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

        NSURL* destinationURL = [exportURL
URLByAppendingPathExtension:@"m4a"];

with

        NSURL* destinationURL = [[exportURL URLByDeletingPathExtension]
URLByAppendingPathExtension:@"m4a"];;

(Hey, ugly braces inside ugly braces, there!)

in the RecordingEncoder.m file.

- 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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »