测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可 | MIT |
Released最新版本 | 2018年6月 |
SPM支持 SPM | ✓ |
由 Eric Conner Apps 维护。
只需将 SwiftyRadio.swift 文件放入您的项目即可。就是这样!
Swift 包管理器 是一种用于管理 Swift 代码分发的工具。
更新您的 Package.swift
文件以包含以下内容
import PackageDescription
let package = Package(
name: "My Radio App",
dependencies: [
.Package(url: "https://github.com/EricConnerApps/SwiftyRadio.git"),
]
)
运行 swift build
。
为了支持后台模式,请在您的 Info.plist
中追加以下内容
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
如果您想从 http://
URLs 流式传输,请在您的 Info.plist
中追加以下内容
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
在 AppDelegate.swift
中,在导入之后和在 @UIApplicationMain
之前添加以下代码。
// Create a variable for SwiftyRadio
var swiftyRadio: SwiftyRadio = SwiftyRadio()
在 ViewController.swift
中,在 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()
为了处理远程事件,您应该执行以下操作
在 AppDelegate.swift
中,在 didFinishLaunchingWithOptions
中添加以下代码:UIApplication.shared.beginReceivingRemoteControlEvents()
然后在 applicationWillTerminate
中添加以下代码:UIApplication.shared.endReceivingRemoteControlEvents()
本项目中所有显著的更改都将记录在 CHANGELOG.md 中。
SwiftyRadio 可在 MIT 许可下使用。更多详细信息请参阅 LICENSE 文件。
修复了 bug 或添加了新功能?创建一个 pull request,然后继续吧!
如果你使用了 SwiftyRadio,请告诉我你的应用。