{"id":1419,"url":"https://github.com/adamcichy/SwiftySound","last_synced_at":"2025-08-06T13:31:58.996Z","repository":{"id":41070635,"uuid":"82700836","full_name":"adamcichy/SwiftySound","owner":"adamcichy","description":"SwiftySound is a simple library that lets you play sounds with a single line of code.","archived":false,"fork":false,"pushed_at":"2024-03-09T23:38:28.000Z","size":7897,"stargazers_count":1250,"open_issues_count":15,"forks_count":100,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-12-06T23:04:51.032Z","etag":null,"topics":["audio","carthage","cocoapods","ios","loop","macos","play-sounds","player","sound","spm","swift","swifty-sound","tvos","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamcichy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"adamcichy"}},"created_at":"2017-02-21T16:17:06.000Z","updated_at":"2024-11-30T14:19:50.000Z","dependencies_parsed_at":"2024-06-18T18:38:02.190Z","dependency_job_id":"7dc85a1a-e4bf-4300-aba5-bcde999ff033","html_url":"https://github.com/adamcichy/SwiftySound","commit_stats":{"total_commits":70,"total_committers":7,"mean_commits":10.0,"dds":0.1428571428571429,"last_synced_commit":"929742f4314ca7261791f969f667df71147e897f"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamcichy%2FSwiftySound","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamcichy%2FSwiftySound/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamcichy%2FSwiftySound/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamcichy%2FSwiftySound/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamcichy","download_url":"https://codeload.github.com/adamcichy/SwiftySound/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228905440,"owners_count":17989766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","carthage","cocoapods","ios","loop","macos","play-sounds","player","sound","spm","swift","swifty-sound","tvos","xcode"],"created_at":"2024-01-05T20:15:46.011Z","updated_at":"2024-12-09T14:30:41.982Z","avatar_url":"https://github.com/adamcichy.png","language":"Swift","funding_links":["https://github.com/sponsors/adamcichy"],"categories":["Media","Libs","Swift","HarmonyOS","Media and Graphics","Audio [🔝](#readme)","iOS"],"sub_categories":["Audio","Other free courses","Windows Manager","Android samples"],"readme":"## SwiftySound\n\n[![CocoaPods License](https://img.shields.io/cocoapods/l/SwiftySound.svg)](https://raw.githubusercontent.com/adamcichy/SwiftySound/master/LICENSE)\n[![CocoaPods](https://img.shields.io/cocoapods/v/SwiftySound.svg)](https://cocoapods.org/pods/SwiftySound)\n[![CocoaPods Platforms](https://img.shields.io/cocoapods/p/SwiftySound.svg)](https://cocoapods.org/pods/SwiftySound)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage)\n[![SPM ready](https://img.shields.io/badge/SPM-ready-orange.svg)](https://swift.org/package-manager/)\n[![codebeat](https://codebeat.co/badges/b51bedad-3c13-4ef2-a632-5c4e3d4fa759)](https://codebeat.co/projects/github-com-adamcichy-swiftysound-master)\n\n## Overview\nSwiftySound is a simple library that lets you deal with Swift sounds easily.\n\n##### Static methods\n\n```swift\nSound.play(file: \"dog.wav\")\n```\n\n```swift\nSound.play(url: fileURL)\n```\n\nMore advanced example:\n\n```swift\nSound.play(file: \"dog\", fileExtension: \"wav\", numberOfLoops: 2)\n```\nThe above will play the sound three times.\n\nSpecify a negative number of loops to play the sound continously in an infinite loop:\n\n```swift\nSound.play(file: \"dog\", fileExtension: \"wav\", numberOfLoops: -1)\n```\n\nStop currently playing sounds:\n\n```swift\nSound.stopAll()\n```\n\nEnable/disable all sounds:\n\n```swift\nSound.enabled = true\nSound.enabled = false\n```\n\nThe value of `Sound.enabled` property will be automatically persisted in `UserDefaults` and restored on the next launch of your app.\n\nChange sound categories. SwiftySound provides a simple way of changing sound category:\n\n```swift\nSound.category = .ambient\n```\nThis 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.\n\n##### Creating instances of *Sound* class\n\nYou can also create an instance of a Sound class and store it somewhere in your app.\n\n```swift\nlet mySound = Sound(url: fileURL)\nmySound.play()\n```\n\nCreating an instance has more benefits like the ability to adjust the volume and playback callbacks.\n\n##### Change the volume\n\nYou can change the volume of each *Sound* instance.\n\n```swift\nmySound.volume = 0.5\n```\nThe value of *volume* property should be between 0.0 and 1.0, where 1.0 is the maximum.\n\n##### Callbacks\n\nYou 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.\n\n```swift\nmySound.play { completed in\n    print(\"completed: \\(completed)\")\n}\n```\n\n\u003caside class=\"warning\"\u003e\nThe callback is not called if the sound was stopped, interrupted or in case of a playback error.\n\u003c/aside\u003e\n\n## Features\n- [x] Playing single sounds\n- [x] Loops\n- [x] Infinite loops\n- [x] Playing the same sound multiple times simultaneously\n- [x] Stopping all sounds with a global static method\n- [x] Ability to pause and resume\n- [x] Adjusting sound volume\n- [x] Callbacks\n- [x] Global static variable to enable/disable all sounds\n\n## Requirements\n- Swift 5\n- Xcode 15 or later\n- iOS 12.0 or later\n- tvOS 12.0 or later\n- macOS 10.13 or later\n\nFor Xcode 8 and Swift 3 support, please use SwiftySound version `0.7.0`.\nFor Xcode 9 and Swift 4 support, please use SwiftySound version `1.0.0`.\nFor Xcode 10 and iOS 9 support, please use SwiftySound version `1.2.0`.\n\n## Installation\n### Installation with CocoaPods\n\n[CocoaPods](http://cocoapods.org/) is a dependency manager which automates and simplifies the process of using third-party libraries in your projects. See the [Get Started](http://cocoapods.org/#get_started) section for more details.\n\n#### Podfile\n```ruby\nplatform :ios, '12.0'\nuse_frameworks!\npod 'SwiftySound'\n```\n### Installation with Carthage\n[Carthage](https://github.com/Carthage/Carthage) is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods.\n\nTo install with carthage, follow the instruction on [Carthage](https://github.com/Carthage/Carthage)\n\n#### Cartfile\n```\ngithub \"adamcichy/SwiftySound\"\n```\n\n### Installation with Swift Package Manager\n\nThe 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:\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"YourPackage\",\n    dependencies: [\n        .Package(url: \"https://github.com/adamcichy/SwiftySound.git\",\n                 majorVersion: 0)\n    ]\n)\n```\n\nThen run `swift build` and wait for SPM to install SwiftySound.\n\n### Manual installation\nDrop the `Sound.swift` file into your project, link against `AVFoundation.framework` and you are ready to go.\n\n## Licenses\n\nSwiftySound is licensed under the [MIT License](https://raw.githubusercontent.com/adamcichy/SwiftySound/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamcichy%2FSwiftySound","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamcichy%2FSwiftySound","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamcichy%2FSwiftySound/lists"}