Return to Video

Making Sense of Audio Recorder - Intro to iOS App Development with Swift

  • 0:00 - 0:02
    Here is what I gather from the code.
  • 0:02 - 0:05
    We are importing AV foundation at the very top.
  • 0:05 - 0:08
    This tells me that we will use a library from this framework, and
  • 0:08 - 0:13
    sure enough, we use AV audio recorder which sounds like a library that
  • 0:13 - 0:14
    will help us record audio.
  • 0:14 - 0:18
    If you look at how this object audio recorder is being initialized a little bit
  • 0:18 - 0:19
    further down the cord.
  • 0:19 - 0:22
    We will notice that while creating its instance,
  • 0:22 - 0:24
    we are giving it something called a filePath.
  • 0:24 - 0:27
    Now this seems like the path, or the address,
  • 0:27 - 0:30
    of a file on our phone where we actually want to record our audio, and
  • 0:30 - 0:34
    it seems that this last line will actually record the audio.
  • 0:34 - 0:35
    So far, so good.
  • 0:35 - 0:38
    Let's investigate this thing called filePath a little bit more.
  • 0:38 - 0:43
    Now, all of this code here, it seems to me, is helping us get to the filePath or
  • 0:43 - 0:45
    the location of our recorded audio.
  • 0:45 - 0:48
    It looks like this line of code here is getting the path of
  • 0:48 - 0:50
    a directory within our app.
  • 0:50 - 0:53
    Now the thing to notice here is that our app can't just
  • 0:53 - 0:55
    store a file anywhere on the phone.
  • 0:55 - 0:58
    That would actually create serious security implications.
  • 0:58 - 1:02
    So what we are doing is getting the path to the document directory
  • 1:02 - 1:03
    within our app.
  • 1:03 - 1:07
    This is a place where our app is actually permitted to store files.
  • 1:07 - 1:09
    Then we are getting the current date and
  • 1:09 - 1:12
    time from the phone and converting it into this format.
  • 1:12 - 1:16
    And it seems to me that we are using that as the name of our audio file.
  • 1:16 - 1:19
    I think what this mechanism does, is that it ensures that
  • 1:19 - 1:24
    no two audio files are of the same name in our documents directory folder.
  • 1:24 - 1:24
    All right.
  • 1:24 - 1:27
    Now that we have a high level understanding of this code,
  • 1:27 - 1:30
    let's add this to our project and see if it works.
  • 1:30 - 1:33
    By the way, all of this code is available in the instructor notes for
  • 1:33 - 1:33
    you to experiment with.
Cím:
Making Sense of Audio Recorder - Intro to iOS App Development with Swift
Leírás:

05-04 Making Sense of Audio Recorder

more » « less
Video Language:
English
Team:
Udacity
Projekt:
UD585 - Intro to iOS App Development with Swift
Duration:
01:34

English subtitles

Felülvizsgálatok Compare revisions