{"id":1556,"url":"https://github.com/teodorpatras/Jukebox","last_synced_at":"2025-08-02T04:31:38.256Z","repository":{"id":45245240,"uuid":"41479555","full_name":"teodorpatras/Jukebox","owner":"teodorpatras","description":"Player for streaming local and remote audio files. Written in Swift.","archived":true,"fork":false,"pushed_at":"2021-01-12T16:07:32.000Z","size":544,"stargazers_count":548,"open_issues_count":63,"forks_count":122,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-05-29T17:49:17.115Z","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/teodorpatras.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-08-27T10:05:21.000Z","updated_at":"2024-05-07T20:56:42.000Z","dependencies_parsed_at":"2022-09-09T22:52:02.307Z","dependency_job_id":null,"html_url":"https://github.com/teodorpatras/Jukebox","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodorpatras%2FJukebox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodorpatras%2FJukebox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodorpatras%2FJukebox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teodorpatras%2FJukebox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teodorpatras","download_url":"https://codeload.github.com/teodorpatras/Jukebox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228438962,"owners_count":17920017,"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-01-05T20:15:49.734Z","updated_at":"2024-12-06T08:31:10.951Z","avatar_url":"https://github.com/teodorpatras.png","language":"Swift","funding_links":[],"categories":["Media"],"sub_categories":["Streaming","Other free courses"],"readme":"![Jukebox: audio player in Swift](https://raw.githubusercontent.com/teodorpatras/Jukebox/master/assets/jukebox.png)\n\n![Swift3](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat\")\n[![Platform](https://img.shields.io/cocoapods/p/Jukebox.svg?style=flat)](http://cocoapods.org/pods/Jukebox)\n[![Build Status](https://travis-ci.org/teodorpatras/Jukebox.svg)](https://travis-ci.org/teodorpatras/Jukebox)\n[![Version](https://img.shields.io/cocoapods/v/Jukebox.svg?style=flat)](http://cocoapods.org/pods/Jukebox)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![License](https://img.shields.io/cocoapods/l/Jukebox.svg?style=flat)](http://cocoapods.org/pods/Jukebox)\n\nJukebox is an iOS audio player written in Swift.\n\n# Contents\n1. [Features](#features)\n3. [Installation](#installation)\n4. [Supported OS \u0026 SDK versions](#supported-versions)\n5. [Usage](#usage)\n6. [Handling remote events](#remote-events)\n7. [Public interface](#public-interface)\n8. [Delegation](#delegation)\n9. [License](#license)\n10. [Contact](#contact)\n\n##\u003ca name=\"features\"\u003e Features \u003c/a\u003e\n\n- [x] Support for streaming both remote and local audio files\n- [x] Support for streaming live audio feeds\n- [x] Functions to ``play``, ``pause``, ``stop``, ``replay``, ``play next``, ``play previous``, ``control volume`` and ``seek`` to a certain second.\n- [x] Background mode integration with ``MPNowPlayingInfoCenter``\n\n\u003ca name=\"installation\"\u003e Installation \u003c/a\u003e\n--------------\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects.\n\nCocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate ``Jukebox`` into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\npod 'Jukebox'\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate `Jukebox` into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"teodorpatras/Jukebox\"\n```\n\nRun `carthage update` to build the framework and drag the built `Jukebox.framework` into your Xcode project.\n\n### Manually\n\nIf you prefer not to use either of the aforementioned dependency managers, you can integrate Jukebox into your project manually.\n\n##\u003ca name=\"supported-versions\"\u003e Supported OS \u0026 SDK versions \u003c/a\u003e\n\n- iOS 8.0+\n- Xcode 7+\n\n##\u003ca name=\"usage\"\u003e Usage \u003c/a\u003e\n\n### Prerequisites\n\n* In order to support background mode, append the following to your ``Info.plist``:\n\n```\n\u003ckey\u003eUIBackgroundModes\u003c/key\u003e\n\u003carray\u003e\n    \u003cstring\u003eaudio\u003c/string\u003e\n\u003c/array\u003e\n```\n\n* If you want to stream from ``http://`` URLs, append the following to your ``Info.plist``:\n\n```\n\u003ckey\u003eNSAppTransportSecurity\u003c/key\u003e\n\u003cdict\u003e\n    \u003ckey\u003eNSAllowsArbitraryLoads\u003c/key\u003e\n        \u003ctrue/\u003e\n\u003c/dict\u003e\n```\n\n### Getting started\n\n1) Create an instance of ``Jukebox``:\n\n```swift\n// configure jukebox\njukebox = Jukebox(delegate: self, items: [\n    JukeboxItem(URL: NSURL(string: \"http://www.noiseaddicts.com/samples_1w72b820/2514.mp3\")!),\n    JukeboxItem(URL: NSURL(string: \"http://www.noiseaddicts.com/samples_1w72b820/2958.mp3\")!)\n    ])\n```\n\n2) Play and enjoy:\n\n```swift\njukebox?.play()\n```\n\n##\u003ca name=\"remote-events\"\u003e Handling remote events \u003c/a\u003e\n\nIn order to handle remote events, you should do the following:\n\n* First, you need to call for receiving remote events:\n\n`UIApplication.sharedApplication().beginReceivingRemoteControlEvents()`\n\n* Secondly, override `remoteControlReceivedWithEvent(event:)`:\n\n```\noverride func remoteControlReceived(with event: UIEvent?) {\n    if event?.type == .remoteControl {\n        switch event!.subtype {\n        case .remoteControlPlay :\n            jukebox.play()\n        case .remoteControlPause :\n            jukebox.pause()\n        case .remoteControlNextTrack :\n            jukebox.playNext()\n        case .remoteControlPreviousTrack:\n            jukebox.playPrevious()\n        case .remoteControlTogglePlayPause:\n            if jukebox.state == .playing {\n               jukebox.pause()\n            } else {\n                jukebox.play()\n            }\n        default:\n            break\n        }\n    }\n}\n```\n\n##\u003ca name=\"public-interface\"\u003ePublic interface \u003c/a\u003e\n\n##Public methods##\n```\n/**\n Starts item playback.\n*/\npublic func play()\n    \n/**\nPlays the item indicated by the passed index\n     \n - parameter index: index of the item to be played\n*/\npublic func play(atIndex index: Int)\n    \n/**\n Pauses the playback.\n*/\npublic func pause()\n    \n/**\n Stops the playback.\n*/\npublic func stop()\n    \n/**\n Starts playback from the beginning of the queue.\n*/\npublic func replay()\n    \n/**\n Plays the next item in the queue.\n*/\npublic func playNext()\n    \n/**\n Restarts the current item or plays the previous item in the queue\n*/\npublic func playPrevious()\n    \n/**\n Restarts the playback for the current item\n*/\npublic func replayCurrentItem()\n    \n/**\n Seeks to a certain second within the current AVPlayerItem and starts playing\n     \n - parameter second: the second to seek to\n - parameter shouldPlay: pass true if playback should be resumed after seeking\n*/\npublic func seek(toSecond second: Int, shouldPlay: Bool = false)\n    \n/**\n Appends and optionally loads an item\n     \n - parameter item:            the item to be appended to the play queue\n - parameter loadingAssets:   pass true to load item's assets asynchronously\n*/\npublic func append(item: JukeboxItem, loadingAssets: Bool)\n\n/**\n Removes an item from the play queue\n    \n - parameter item: item to be removed\n*/\npublic func remove(item: JukeboxItem)\n    \n/**\n Removes all items from the play queue matching the URL\n     \n - parameter url: the item URL\n*/\npublic func removeItems(withURL url : URL)\n```\n\n##Public properties##\n\n| Property   |      Type      | Description |\n|----------|-------------|------|\n|`volume`| `Float` | volume of the player |\n| `currentItem` | `JukeboxItem` | object encapsulating the meta of the current player item |\n\n##\u003ca name=\"delegation\"\u003e Delegation \u003c/a\u003e\n\n`Jukebox` defines a delegate protocol which you can use if you want to be announced when about custom events:\n\n```\npublic protocol JukeboxDelegate: class {\n    func jukeboxStateDidChange(_ state : Jukebox)\n    func jukeboxPlaybackProgressDidChange(_ jukebox : Jukebox)\n    func jukeboxDidLoadItem(_ jukebox : Jukebox, item : JukeboxItem)\n    func jukeboxDidUpdateMetadata(_ jukebox : Jukebox, forItem: JukeboxItem)\n}\n```\n\n##\u003ca name=\"license\"\u003e License \u003c/a\u003e\n\n```Jukebox``` is released under the MIT license. See the ```LICENSE``` file for details.\n\n##\u003ca name=\"contact\"\u003e Contact \u003c/a\u003e\n\nYou can follow or drop me a line on [my Twitter account](https://twitter.com/teodorpatras). If you find any issues on the project, you can open a ticket. Pull requests are also welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteodorpatras%2FJukebox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteodorpatras%2FJukebox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteodorpatras%2FJukebox/lists"}