CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Jun 2018 |
| SPMSupports SPM | ✓ |
Maintained by Eric Conner Apps.
Just drop the SwiftyRadio.swift file into your project. That’s it!
The Swift Package Manager is a tool for managing the distribution of Swift code.
Update your Package.swift file to include the following:
import PackageDescription
let package = Package(
name: "My Radio App",
dependencies: [
.Package(url: "https://github.com/EricConnerApps/SwiftyRadio.git"),
]
)Run swift build.
In order to support background mode, append the following to your Info.plist:
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>If you want to stream from http:// URLs, append the following to your Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>In AppDelegate.swift add the following code after imports and before @UIApplicationMain.
// Create a variable for SwiftyRadio
var swiftyRadio: SwiftyRadio = SwiftyRadio()In ViewController.swift include the following code in viewDidLoad()
// Initialize SwiftyRadio
swiftyRadio.setup()
// Setup the station
swiftyRadio.setStation("Classic Rock 109", URL: "http://198.27.70.42:10042/stream")
// Start playing the station
swiftyRadio.play()In order to handle remote events, you should do the following:
In AppDelegate.swift add the following code in didFinishLaunchingWithOptions: UIApplication.shared.beginReceivingRemoteControlEvents()
Then add the following code in applicationWillTerminate: UIApplication.shared.endReceivingRemoteControlEvents()
All notable changes to this project will be documented in CHANGELOG.md.
SwiftyRadio is available under the MIT license. See the LICENSE file for more info.
Got a bug fix, or a new feature? Create a pull request and go for it!
If you use SwiftyRadio, please let me know about your app.