Closed yeralin closed 5 years ago
I've been asked for the solution several times already. And each time I responded with the workaround that you've described.
With the current implementation, I can't think of any "proper" way to deal with urls that don't end with an extension. The reason for this is that AVPlayerItem, that is the superclass of the CachingPlayerItem, determines the type of the file to play based on the file's url extension. If we omit an extension, there's simply no way for AVPlayerItem to tell how to treat the file.
It seems like it's a common issue. I'll leave it open for now. Duplicate of #5
Думаю тут для многих эта проблема возникнет, так что я по английски.
So, if I use your code as is, everything seems fine up until I try to start playing
player.play()
.I found out that
AVURLAsset
requires an extension like.mp3
in a url. In my case though, I don't use any extensions. My urls are of this formlocalhost:8000/stream?someId=<id>
, andAVPlayer
withAVURLAsset
won't play the audio from such link (thanks to Apple).Right now, I doing it a very hacky way by adding the following:
let asset = AVURLAsset(url: urlWithCustomScheme.appendingPathComponent("/fake.mp3"))
And then in
ResourceLoader
implementation, I removefake.mp3
path:Basically adding
.mp3
extention forAVURLAsset
, and then removing inResourceLoader
, so thatResourceLoader
could actually get my audio file.I'm looking for a nice workaround. You have any ideas?