0
votes

I have an URL. It looks like this:

https://content.stage.someCompany.net/deliveries/artistNameHere/songNameHere-128.mp3?Expires=someNumberHere&Signature=someReallyReallyReallyLongStringHere&Key-Pair-Id=someIdHere

Let me break it down in pieces:

https://content.stage.someCompany.net/deliveries/artistNameHere/songNameHere-128.mp3

?Expires=someNumberHere

&Signature=someReallyReallyReallyLongStringHere

&Key-Pair-Id=someIdHere

As you can see, it's just a glorified .mp3 restricted to 128 kbps, with some security stuff at the end.

If I load it in Safari on my Mac, it will play. If I pass it to an AVPlayer constructor in my iOS app, it will play as well.

If, however, I use it to create an AVURLAsset, it reports that .isPlayable is false. If I stubbornly persist in further creating an AVPlayerItem based on that asset, it will report AVPlayerItemStatusFailed.

Needless to say, in these conditions my AVURLAsset + AVPlayerItem + AVPLayer infrastructure, which culminates in player.play(), actually plays no music.

However, it does successfully play if I substitute other URLs, like Apple's own https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8

or

(some random .mp3 from another stackoverflow topic) http://podcast.cbc.ca/mp3/podcasts/asithappens_20160907_50906.mp3

The differences that I see: Apple's url is in fact a "playlist" of some sort, while the second one in a plain, "civilised" .mp3. No more security mambo-jumbo at the end of the link.

Why won't my url play? Do I need to do something specific with the security stuff? Right now, I'm just naively "hey, AVURLAsset...here's my (entire) URL...do your stuff with it..."

1
Well, the working samples you provided did NOT have url attributes. Is your request getting redirected by the webserver or something else and not pointing directly to the file?Lepidopteron

1 Answers

0
votes

Found it.

The links that I receive are valid only once. Apparently that's why "the security" is in place at the end of them.

Testing one in Safari and "seeing that it works" invalidates it. Subsequently, trying the same one in the app results is .isPlayable = false. Simply requesting & using directly in the app results in .isPlayable = true.

So AVURLAsset + AVPlayerItem + AVPLayer are working just fine. I was just a bloody fool.