Timer_SetupSoundsViewController

class Timer_SetupSoundsViewController : A_TimerSetPickerController

This controller handles setting sounds

  • This is the size of our label text.

    Declaration

    Swift

    let labelTextSize: CGFloat
  • This contains our audio player.

    Declaration

    Swift

    var audioPlayer: AVAudioPlayer!
  • The vibrate switch

    Declaration

    Swift

    @IBOutlet
    weak var vibrateSwitch: UISwitch!
  • The vibrate text button

    Declaration

    Swift

    @IBOutlet
    weak var vibrateButton: UIButton!
  • The segmented control for the sound mode

    Declaration

    Swift

    @IBOutlet
    weak var soundModeSegmentedSwitch: UISegmentedControl!
  • The dismiss/done button

    Declaration

    Swift

    @IBOutlet
    weak var doneButton: UIButton!
  • The view containing the label that is displayed when there is no music available

    Declaration

    Swift

    @IBOutlet
    weak var noMusicLabelView: UIView!
  • The label that is displayed when there is no music available

    Declaration

    Swift

    @IBOutlet
    weak var noMusicLabel: UILabel!
  • The container for the artist selection picker

    Declaration

    Swift

    @IBOutlet
    weak var artistSoundSelectPickerContainerView: UIView!
  • The artist selection picker view

    Declaration

    Swift

    @IBOutlet
    weak var artistSoundSelectPicker: UIPickerView!
  • The song selection picker container

    Declaration

    Swift

    @IBOutlet
    weak var songSelectPickerContainerView: UIView!
  • The song selection picker view

    Declaration

    Swift

    @IBOutlet
    weak var songSelectPicker: UIPickerView!
  • The test sound button container

    Declaration

    Swift

    @IBOutlet
    weak var testSoundButtonContainerView: UIView!
  • The test sound button

    Declaration

    Swift

    @IBOutlet
    weak var testSoundButton: SoundTestButton!
  • The container for the music test button

    Declaration

    Swift

    @IBOutlet
    weak var musicTestButtonContainerView: UIView!
  • The music test button

    Declaration

    Swift

    @IBOutlet
    weak var musicTestButton: SoundTestButton!
  • The activity indicator container view

    Declaration

    Swift

    @IBOutlet
    weak var activityContainerView: UIView!
  • The fecthing music label

    Declaration

    Swift

    @IBOutlet
    weak var fetchingMusicLabel: UILabel!
  • The switch for audible ticks

    Declaration

    Swift

    @IBOutlet
    weak var audibleTicksSwitch: UISwitch!
  • The button for the audible ticks switch

    Declaration

    Swift

    @IBOutlet
    weak var audibleTicksSwitchButton: UIButton!
  • This is called when we want to access the music library to make a list of artists and songs.

    Declaration

    Swift

    func loadMediaLibrary(forceReload inForceReload: Bool = false)

    Parameters

    forceReload

    If true (default is false), then the entire music library will be reloaded, even if we already have it.

  • This loads the music, assuming that we have been authorized.

    Declaration

    Swift

    func loadUpOnMusic()
  • This is called after the music has been loaded. It sets up the Alarm Editor.

    Declaration

    Swift

    func dunLoadin()
  • This reads all the user’s music, and sorts it into a couple of bins for us to reference later.

    Declaration

    Swift

    func loadSongData(_ inSongs: [MPMediaItemCollection])

    Parameters

    inSongs

    The list of songs we read in, as media items.

  • This plays any sound, using a given URL.

    Declaration

    Swift

    func playThisSound(_ inSoundURL: URL)

    Parameters

    inSoundURL

    This is the URI to the sound resource.

  • If the audio player is not going, this continues it. Nothing happens if no audio player is stopped.

    Declaration

    Swift

    func continueAudioPlayer()
  • If the audio player is going, this pauses it. Nothing happens if no audio player is going.

    Declaration

    Swift

    func pauseAudioPlayer()
  • This terminates the audio player. Nothing happens if no audio player is going.

    Declaration

    Swift

    func stopAudioPlayer()
  • This looks for the system URI of a given song.

    Declaration

    Swift

    func findSongURL(artistIndex: Int, songIndex: Int) -> String

    Parameters

    artistIndex

    The index of the artist, in our Array.

    songIndex

    The index of the song, in that artists’ song list Array.

  • This returns the artist and song info for a given song URL.

    Declaration

    Swift

    func findSongInfo(_ inURL: String = "") -> (artistIndex: Int, songIndex: Int)

    Parameters

    inURL

    The URL of the song.

    Return Value

    A tuple, containing the artist index, and the song index.

  • This tells the picker to select the currently chosen song.

    Declaration

    Swift

    func selectSong()
  • This starts the busy throbber, while the music library is being loaded.

    Declaration

    Swift

    func startSpinner()
  • This stops the throbber.

    Declaration

    Swift

    func stopSpinner()
  • This sets up the UI to match the current state.

    Declaration

    Swift

    func setUpUIElements()
  • This is called when the audible ticks switch is hit.

    Declaration

    Swift

    @IBAction
    func audibleTicksSwitchHit(_ sender: UISwitch)

    Parameters

    sender

    The switch object.

  • This is called when the audible ticks switch label (a button) is hit. It toggles the switch.

    Declaration

    Swift

    @IBAction
    func audibleTicksButtonHit(_: Any)
  • This is called when the test icon button is hit.

    Declaration

    Swift

    @IBAction
    func soundTestButtonHit(_ inSender: SoundTestButton)

    Parameters

    sender

    The button object.

  • This is called when the DONE button is hit, or the screen is dismissed.

    Declaration

    Swift

    @IBAction
    func doneButtonHit(_: Any! = nil)
  • Declaration

    Swift

    @IBAction
    func soundModeSegmentedSwitchHit(_ sender: UISegmentedControl)
  • This is called when the vibrate switch is hit.

    Declaration

    Swift

    @IBAction
    func vibrateSwitchHit(_: UISwitch! = nil)
  • This is called when the vibrate switch label (a button) is hit.

    Declaration

    Swift

    @IBAction
    func vibrateButtonHit(_: UIButton)
  • This is called when the view finishes loading.

    Declaration

    Swift

    override func viewDidLoad()
  • this is called just prior to the view appearing.

    Declaration

    Swift

    override func viewDidAppear(_ animated: Bool)
  • This method adds all the accessibility stuff.

    Declaration

    Swift

    override func addAccessibilityStuff()
  • Declaration

    Swift

    override func numberOfComponents(in pickerView: UIPickerView) -> Int

    Return Value

    1

  • This simply returns the number of rows in the pickerview. It will switch on which picker is calling it.

    Declaration

    Swift

    override func pickerView(_ inPickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int

    Parameters

    inPickerView

    The UIPickerView being queried.

  • This generates one row’s content, depending on which picker is being specified.

    Declaration

    Swift

    override func pickerView(_ inPickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing inView: UIView?) -> UIView

    Parameters

    inPickerView

    The UIPickerView being queried.

  • This is called when a picker row is selected, and sets the value for that picker.

    Declaration

    Swift

    func pickerView(_ inPickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)

    Parameters

    inPickerView

    The UIPickerView being queried.

    inRow

    The 0-based row index being selected.

    inComponent

    The 0-based component index being selected.

  • This returns the accesibility label for a given picker component.

    Declaration

    Swift

    override func pickerView(_ inPickerView: UIPickerView, accessibilityLabelForComponent inComponent: Int) -> String?

    Return Value

    The accessibility string.