O'Reilly logo

iOS 9 SDK Development by Janie Clayton, Chris Adamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required