Getting Serious on the Playground

I know, let’s write a streaming web radio application!

Don’t panic; this isn’t as scary as you think. We can get this running with shockingly little code. But let’s do so in a new playground. Close the current playground window, and use File > New > Playground to create a new playground. Call it WebRadioPlayground. Keep the line that says import UIKit, but delete the var str = "Hello, playground" line, and replace it with the following:

1: import​ ​AVFoundation
2: let​ url = ​NSURL​(string: ​"http://armitunes.com:8010/listen.pls"​)
3: let​ player = ​AVPlayer​(​URL​: url!)
4: player.play()

Nothing will happen just yet, but hang in there…

The code we’ve ...

Get iOS 9 SDK Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.