All Projects → adamcichy → Swiftysound

adamcichy / Swiftysound

Licence: mit
SwiftySound is a simple library that lets you play sounds with a single line of code.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftysound

Audioindicatorbars
AIB indicates for your app users which audio is playing. Just like the Podcasts app.
Stars: ✭ 279 (-71.96%)
Mutual labels:  xcode, audio, tvos, cocoapods, carthage
Color
Color utilities for macOS, iOS, tvOS, and watchOS
Stars: ✭ 145 (-85.43%)
Mutual labels:  tvos, cocoapods, carthage, spm
Pandoraplayer
🅿️ PandoraPlayer is a lightweight music player for iOS, based on AudioKit and completely written in Swift.
Stars: ✭ 1,037 (+4.22%)
Mutual labels:  audio, player, sound, cocoapods
Soundable
Soundable allows you to play sounds, single and in sequence, in a very easy way
Stars: ✭ 78 (-92.16%)
Mutual labels:  audio, sound, cocoapods, carthage
Ktvhttpcache
A powerful media cache framework.
Stars: ✭ 2,113 (+112.36%)
Mutual labels:  audio, player, cocoapods, carthage
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-84.12%)
Mutual labels:  xcode, tvos, cocoapods, carthage
Peep
Easy Sound Generator 🐥
Stars: ✭ 59 (-94.07%)
Mutual labels:  audio, sound, cocoapods, carthage
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+975.98%)
Mutual labels:  xcode, tvos, cocoapods, carthage
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-88.04%)
Mutual labels:  xcode, tvos, cocoapods, carthage
Shsearchbar
The search bar that doesn't suck.
Stars: ✭ 206 (-79.3%)
Mutual labels:  xcode, cocoapods, carthage, spm
Fwplayer
A video player SDK for iOS, it is based on AVPlayer. https://se.linkedin.com/in/foks-huiwang, https://fokswang.wixsite.com/home
Stars: ✭ 321 (-67.74%)
Mutual labels:  audio, player, cocoapods, carthage
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift
Stars: ✭ 538 (-45.93%)
Mutual labels:  cocoapods, carthage, spm
Sablurimageview
You can use blur effect and it's animation easily to call only two methods.
Stars: ✭ 538 (-45.93%)
Mutual labels:  tvos, cocoapods, carthage
Quiver
Validation, searching and filtering made easy for swift.
Stars: ✭ 27 (-97.29%)
Mutual labels:  xcode, cocoapods, carthage
Sica
🦌 Simple Interface Core Animation. Run type-safe animation sequencially or parallelly
Stars: ✭ 980 (-1.51%)
Mutual labels:  tvos, cocoapods, carthage
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (-47.04%)
Mutual labels:  tvos, cocoapods, carthage
Xcake
🍰 Describe Xcode projects in a human readable format and (re)generate one on demand.
Stars: ✭ 549 (-44.82%)
Mutual labels:  xcode, tvos, cocoapods
Hysteriaplayer
Objective-C audio player, sitting on top of AVPlayer
Stars: ✭ 568 (-42.91%)
Mutual labels:  audio, player, cocoapods
Sidemenu
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less.
Stars: ✭ 5,267 (+429.35%)
Mutual labels:  xcode, cocoapods, carthage
Swiftlyext
SwiftlyExt is a collection of useful extensions for Swift 3 standard classes and types 🚀
Stars: ✭ 31 (-96.88%)
Mutual labels:  xcode, cocoapods, carthage

SwiftySound

CocoaPods License CocoaPods CocoaPods Platforms Carthage Compatible SPM ready Build status codecov codebeat Codacy

Overview

SwiftySound is a simple library that lets you deal with Swift sounds easily.

Static methods
Sound.play(file: "dog.wav")
Sound.play(url: fileURL)

More advanced example:

Sound.play(file: "dog", fileExtension: "wav", numberOfLoops: 2)

The above will play the sound three times.

Specify a negative number of loops to play the sound continously in an infinite loop:

Sound.play(file: "dog", fileExtension: "wav", numberOfLoops: -1)

Stop currently playing sounds:

Sound.stopAll()

Enable/disable all sounds:

Sound.enabled = true
Sound.enabled = false

The value of Sound.enabled property will be automatically persisted in UserDefaults and restored on the next launch of your app.

Change sound categories. SwiftySound provides a simple way of changing sound category:

Sound.category = .ambient

This changes the category of the underlying shared AVAudioSession instance. The default value is SoundCategory.ambient. Due to AVAudioSession architecture, this property is not available on macOS.

Creating instances of Sound class

You can also create an instance of a Sound class and store it somewhere in your app.

let mySound = Sound(url: fileURL)
mySound.play()

Creating an instance has more benefits like the ability to adjust the volume and playback callbacks.

Change the volume

You can change the volume of each Sound instance.

mySound.volume = 0.5

The value of volume property should be between 0.0 and 1.0, where 1.0 is the maximum.

Callbacks

You can pass a callback to the play method. It will be played after the sound finished playing. For looped sounds, the callback will be called once after the last loop has been played.

mySound.play { completed in
    print("completed: \(completed)")
}
The callback is not called if the sound was stopped, interrupted or in case of a playback error.

Features

  • [x] Playing single sounds
  • [x] Loops
  • [x] Infinite loops
  • [x] Playing the same sound multiple times simultaneously
  • [x] Stopping all sounds with a global static method
  • [x] Ability to pause and resume
  • [x] Adjusting sound volume
  • [x] Callbacks
  • [x] Global static variable to enable/disable all sounds

Requirements

  • Swift 5
  • Xcode 10.2 or later
  • iOS 8.0 or later
  • tvOS 9.0 or later
  • macOS 10.9 or later

For Xcode 8 and Swift 3 support, please use SwiftySound version 0.7.0. For Xcode 9 and Swift 4 support, please use SwiftySound version 1.0.0.

Installation

Installation with CocoaPods

CocoaPods is a dependency manager which automates and simplifies the process of using third-party libraries in your projects. See the Get Started section for more details.

Podfile

platform :ios, '8.0'
use_frameworks!
pod 'SwiftySound'

Installation with Carthage

Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods.

To install with carthage, follow the instruction on Carthage

Cartfile

github "adamcichy/SwiftySound"

Installation with Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code. Just add the url of this repo to your Package.swift file as a dependency:

import PackageDescription

let package = Package(
    name: "YourPackage",
    dependencies: [
        .Package(url: "https://github.com/adamcichy/SwiftySound.git",
                 majorVersion: 0)
    ]
)

Then run swift build and wait for SPM to install SwiftySound.

Manual installation

Drop the Sound.swift file into your project, link against AVFoundation.framework and you are ready to go.

Licenses

SwiftySound is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].