dimitris-c / AudioStreaming

An AudioPlayer/Streaming library for iOS written in Swift using AVAudioEngine.
MIT License
266 stars 56 forks source link

MPMediaItem witch assetURL #54

Closed 666bsw closed 8 months ago

666bsw commented 1 year ago

Hello!

how to play files MPMediaItem witch assetURL ? for example: assetURL = Optional(ipod-library://item/item.m4a?id=6247563662587856568)

the framework tries to look for something on the network. the file is not played.

dimitris-c commented 1 year ago

You can look to add this functionality if you want, currently playing items this way is not supported.

adriatikgashi commented 1 year ago

@666bsw you can add this extension to play a sound file from your local:

extension AudioPlayer {

    func playFile(fileName: String) {
        let soundFileComponents = fileName.trimmingCharacters(in: .whitespacesAndNewlines).components(separatedBy: ".")
        guard soundFileComponents.count == 2 else {
            return
        }

        guard let url = Bundle.main.url(forResource: soundFileComponents[0], withExtension: soundFileComponents[1]) else {
            return
        }
        play(url: url)
    }
}