ColiseuPlayer 1.0.0

ColiseuPlayer 1.0.0

Ricardo Pereira 维护。



ColiseuPlayer

Build Status Swift 5 Platforms iOS Carthage Compatible Version License MIT

ColiseuPlayer 是一个用 Swift 编写的音频播放框架,为 Coliseu 应用程序创建。它使用 AVFoundation。

使用

import AVFoundation
import ColiseuPlayer

class ViewController: UIViewController, ColiseuPlayerDataSource, ColiseuPlayerDelegate {

    let player = ColiseuPlayer()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.player.startSession()
        self.player.dataSource = self

        var list = [AudioFile]()

        if let path = Bundle.main.path(forResource: "sampleAudio", ofType: "m4a") {
            let urlFile = URL(fileURLWithPath: path)
            let audio = AudioFile(url: urlFile)
            audio.artwork = UIImage(named: "image-cover-artwork")
            list.append(audio)
        }

        if list.count > 0 {
            // Play first song (it will continue playing with the current playlist)
            player.playSong(index: 0, songsList: list)
        }
    }

    override func viewDidDisappear(animated: Bool) {
        super.viewDidDisappear(animated)

        self.player.stopSession()
    }

    override func remoteControlReceived(with event: UIEvent?) {
        self.player.didReceiveRemoteControl(event: event)
    }

    func audioRepeatType(in player: ColiseuPlayer) -> ColiseuPlayerRepeat {
        return .all
    }

    func audioWillShuffle(in player: ColiseuPlayer) -> Bool {
        return true
    }
}

要求

  • iOS 8.0+
  • Xcode 10.2+

安装

Carthage

要安装它,只需将以下行添加到您的 Cartfile

github "ricardopereira/ColiseuPlayer"

然后在终端中运行 carthage update

请按照Carthage的README中的最新安装说明进行操作。

CocoaPods

安装它,只需将以下行添加到您的Podfile中

pod 'ColiseuPlayer'

同时,请确保您已选择使用框架

use_frameworks!

然后使用CocoaPods 0.36或更高版本运行pod install

手动操作

在您的项目中使用ColiseuPlayer需要进行以下步骤:

  1. 通过打开终端,进入到顶层项目目录,并输入git submodule add https://github.com/ricardopereira/coliseu.ios.player.git命令来将ColiseuPlayer作为一个< CFRG
  2. 打开ColiseuPlayer文件夹,并将ColiseuPlayer.xcodeproj拖到您的应用程序项目的文件导航器中。
  3. 在Xcode中,通过点击蓝色的项目图标,然后在侧边栏的“Targets”标题下选择应用程序目标来导航到目标配置窗口。
  4. 确保ColiseuPlayer.framework的部署目标与应用程序目标的部署目标相匹配。
  5. 在该窗口顶部的标签栏中,打开“Build Phases”面板。
  6. 展开“Link Binary with Libraries”组,并添加ColiseuPlayer.framework
  7. 点击面板左上角的+按钮,选择“New Copy Files Phase”,将此新阶段重命名为“Copy Frameworks”,将“Destination”设置为“Frameworks”,并添加ColiseuPlayer.framework

作者

(@SentulAsia)

许可协议

ColiseuPlayer是在MIT许可下发布的。有关详细信息,请参阅LICENSE