Swiftpack.co - Package - lloydkeijzer/SwimpleAudio

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

lloydkeijzer/SwimpleAudio

Simple audio playback in Swift

SwimpleAudio

version issues license size

Simple audio playback in Swift.

SwimpleAudio is part of the Swimple packages series. Swimple stands for Simple Swift. These packages make coding with Swift simpler and more convenient.

Swift Package Manager 📦

From within Xcode 11 or up you can add SwimpleAudio as a Swift Package:

  1. Select your project
  2. Go to Swift packages
  3. Add a package (+)
  4. Enter https://github.com/lloydkeijzer/SwimpleAudio.git as the package repository url
  5. Select the version you want to use and click next

You're now able to import SwimpleAudio in your source code 🎉

Binding audio 🔊

You can easily bind any sound effect to an action of a UIControl object.

class ViewController: UIViewController {

  let button = UIButton()

  override func viewDidLoad() {
    super.viewDidLoad()
    button.addSound(named: "button_click.mp3", for: .touchUpInside)
  }
  
  deinit {
    button.removeTargets()
  }
}

Delaying a sound effect after an UIControl.Event triggers.

button.addSound(named: "button_click.mp3", for: .touchUpInside, delay: .seconds(3))

Repeating a sound effect a number of times after an UIControl.Event triggers.

button.addSound(named: "button_click.mp3", for: .touchUpInside, repeats: 5)

Github

link
Stars: 3
Last commit: 1 year ago

Releases

Production ready 💪 - 2019-11-07T15:29:45

SwimpleAudio is production ready as of version 2.0.0 👏🏻. After swapping the binded actions logic with the code block sleeves the audio started working.