Coder Social home page Coder Social logo

jeehut / swiftysound Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adamcichy/swiftysound

0.0 2.0 0.0 160 KB

Swifty Sound is a simple library that lets you play sounds with a single line of code.

License: MIT License

Swift 79.48% Objective-C 14.31% Ruby 6.21%

swiftysound's Introduction

Swifty Sound

CocoaPods CocoaPods CocoaPods CocoaPods Carthage Compatible Build status

Overview

Swifty Sound 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: 3)

The above will play the sound three times.

Specify a negative number of loops to play the sound continously in an intinite 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 sound = Sound(url: fileURL)
sound.play()

Features

  • Playing single sounds
  • Loops
  • Infinite loops
  • Playing the same sound multiple times simultaneously
  • Global static variable to enable/disable all sounds

Requirements

  • Swift 3
  • Xcode 8.0 or later
  • iOS 8.0 or later
  • tvOS 9.0 or later
  • OS X 10.10 or later

Installation

Installation with CocoaPods

CocoaPods is a dependency manager which automates and simplifies the process of using 3rd-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"

Manual installation

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

Licenses

Swifty Sound is licensed under the MIT License.

swiftysound's People

Contributors

adamcichy avatar jeehut avatar naeemshaikh90 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.