{"id":13465349,"url":"https://github.com/tbaranes/AudioPlayerSwift","last_synced_at":"2025-03-25T16:31:36.871Z","repository":{"id":47850338,"uuid":"50016416","full_name":"tbaranes/AudioPlayerSwift","owner":"tbaranes","description":"AudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps.","archived":false,"fork":false,"pushed_at":"2021-08-12T11:59:02.000Z","size":236,"stargazers_count":278,"open_issues_count":0,"forks_count":43,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-16T05:28:14.189Z","etag":null,"topics":[],"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/tbaranes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-20T08:37:17.000Z","updated_at":"2024-08-31T01:26:43.000Z","dependencies_parsed_at":"2022-08-12T13:50:59.879Z","dependency_job_id":null,"html_url":"https://github.com/tbaranes/AudioPlayerSwift","commit_stats":null,"previous_names":["recisio/audioplayerswift"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbaranes%2FAudioPlayerSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbaranes%2FAudioPlayerSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbaranes%2FAudioPlayerSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbaranes%2FAudioPlayerSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbaranes","download_url":"https://codeload.github.com/tbaranes/AudioPlayerSwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222088539,"owners_count":16928976,"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":[],"created_at":"2024-07-31T15:00:28.054Z","updated_at":"2024-10-29T17:30:45.254Z","avatar_url":"https://github.com/tbaranes.png","language":"Swift","funding_links":[],"categories":["HarmonyOS","Libs","Audio [🔝](#readme)","Media","Media and Graphics","多媒体功能"],"sub_categories":["Windows Manager","Audio","音频"],"readme":"\u003ch1 align=center\u003e\n\u003cimg src=\"logo.png\" width=60%\u003e\n\u003c/h1\u003e\n\n# AudioPlayer\n\n[![Travis](https://img.shields.io/travis/tbaranes/AudioPlayerSwift.svg)](https://travis-ci.org/tbaranes/AudioPlayerSwift)\n![Language](https://img.shields.io/badge/language-Swift%205.0-orange.svg)\n[![CocoaPods](https://img.shields.io/cocoapods/v/AudioPlayerSwift.svg?style=flat)](https://github.com/tbaranes/AudioPlayerSwift)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Platform](https://img.shields.io/cocoapods/p/AudioPlayerSwift.svg?style=flat)](http://cocoadocs.org/docsets/AudioPlayerSwiftft)\n\nAudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps.\n\n## Usage\n\n```swift\n// Initialize\nlet audioPlayer = AudioPlayer(\"sound.mp3\")\n\n// Start playing\naudioPlayer.play()\n\n// Stop playing with a fade out\naudioPlayer.fadeOut()\n```\n\nSee the samples project to see advanced usage\n\n## Installation\n\n### CocoaPods\n\nAdd the following to your Podfile:\n\n```\npod 'AudioPlayerSwift'\n```\n\n### Carthage\n\nAdd the following to your Cartfile:\n\n```\ngithub 'tbaranes/AudioPlayerSwift'\n```\n\n### Swift Package Manager\n\nAudioPlayer is available on SPM. Just add the following to your Package file:\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    dependencies: [\n        .Package(url: \"https://github.com/tbaranes/AudioPlayerSwift.git\", majorVersion: 1)\n    ]\n)\n```\n\n### Manual Installation\n\nJust drag the `Source/*.swift` files into your project.\n\n\n## AudioPlayer properties\n\n```swift\nname\n```\n\nThe name of the sound. This is either the name that was passed to the `init`, or the last path component of the audio file.\n\n```swift\nurl\n```\n\nThe absolute URL of the audio file.\n\n```swift\ncompletionHandler\n```\n\nA callback closure that will be called when the audio finishes playing, or is stopped.\n\n```swift\nisPlaying\n```\n\nIs it playing or not?\n\n```swift\nduration\n```\n\nThe duration of the sound.\n\n```swift\ncurrentTime\n```\n\nThe current time offset into the sound of the current playback position.\n\n```swift\nvolume\n```\n\nThe volume for the sound. The nominal range is from 0.0 to 1.0.\n\n```swift\nnumberOfLoops\n```\n\nNumber of times that the sound will return to the beginning upon reaching the end.\n\n- A value of zero means to play the sound just once.\n- A value of one will result in playing the sound twice, and so on..\n- Any negative number will loop indefinitely until stopped.\n  \n  \n```swift\npan\n```\n\nThe left/right stereo pan of the file. -1.0 is left, 0.0 is center, 1.0 is right.\n \n## AudioPlayer methods\n\n```swift\ninit(fileName: String) throws\ninit(contentsOfPath path: String) throws\ninit(contentsOf url: URL) throws\n```\n\nThese methods create a new AudioPlayer instance from a file name or file path.\n\n```swift\nfunc play()\n```\n\nPlays the sound. Has no effect if the sound is already playing.\n\n```swift\nfunc stop()\n```\n\nStops the sound. Has no effect if the sound is not already playing. \n\n```swift\nfunc fadeTo(volume: Float, duration: TimeInterval = 1.0)\n```\n\nThis method fades a sound from it's current volume to the specified volume over the specified time period. \n\n```swift\nfunc fadeIn(duration: TimeInterval = 1.0)\n```\n\nFades the sound volume from 0.0 to 1.0 over the specified duration. \n\n```swift\nfunc fadeOut(duration: TimeInterval = 1.0)\n```\n\nFades the sound from it's current volume to 0.0 over the specified duration. \n\n\n## Notifications\n\n```swift\nSoundDidFinishPlayingNotification\n```\n\nThis notification is fired (via NSNotificationCenter) whenever a sound finishes playing, either due to it ending naturally, or because the stop method was called. The notification object is an instance of the AudioPlayer class. You can access the AudioPlayer class's `name` property to find out which sound has finished.\n\n## What's next\n\n- AudioPlayerManager\n- Your features!\n\n## Contribution\n\n- If you found a **bug**, open an **issue**\n- If you have a **feature request**, open an **issue**\n- If you want to **contribute**, submit a **pull request**\n\n## Licence\n\nAudioPlayerSwift is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbaranes%2FAudioPlayerSwift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbaranes%2FAudioPlayerSwift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbaranes%2FAudioPlayerSwift/lists"}