teodorpatras / Jukebox

Player for streaming local and remote audio files. Written in Swift.
MIT License
551 stars 122 forks source link

.play freezes the main thread #91

Closed neilgandhi95 closed 6 years ago

neilgandhi95 commented 6 years ago

The following code freezes the whole main thread until the state is changed to .playing. Any idea why?

               if (jukeboxPlayer.jukebox != nil) {

                    if let playingURL = jukeboxPlayer.jukebox?.currentItem?.URL {
                        jukeboxPlayer.jukebox?.removeItems(withURL: playingURL)
                    }
                    jukeboxPlayer.jukebox?.append(item: JukeboxItem(URL: url), loadingAssets: false)

                } else {

                    jukeboxPlayer.jukebox = Jukebox(delegate: self, items: [
                        JukeboxItem(URL: url)
                    ])

                }

                jukeboxPlayer.jukebox?.play(atIndex: 0)
neilgandhi95 commented 6 years ago

nvm solved it, just load the avurlasset in the background thread async in jukeboxitem