SwiftyRadio 1.4.9

SwiftyRadio 1.4.9

测试已测试
Lang语言 SwiftSwift
许可 MIT
Released最新版本2018年6月
SPM支持 SPM

Eric Conner Apps 维护。



SwiftyRadio

安装

手动

只需将 SwiftyRadio.swift 文件放入您的项目即可。就是这样!

Swift 包管理器

Swift 包管理器 是一种用于管理 Swift 代码分发的工具。

  1. 更新您的 Package.swift 文件以包含以下内容

    import PackageDescription
    
    let package = Package(
        name: "My Radio App",
        dependencies: [
            .Package(url: "https://github.com/EricConnerApps/SwiftyRadio.git"),
        ]
    )
  2. 运行 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,请告诉我你的应用。