Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save norio-nomura/a29a626faa9ffb5b72ad to your computer and use it in GitHub Desktop.
Save norio-nomura/a29a626faa9ffb5b72ad to your computer and use it in GitHub Desktop.
Playing "Apple Special Event September 2015" in Playground on Xcode 7.1 beta 3. #swiftlang
/// Playing Apple Special Event September 2015 in Playground on Xcode 7.1 beta 3
/// Work load will be lowest when Platform = "OS X"
import AVFoundation
import AVKit
import XCPlayground
protocol Playable: XCPlaygroundLiveViewable {
var player: AVPlayer? {get set}
}
let liveView: Playable
#if os(iOS) || os(tvOS)
extension AVPlayerViewController: Playable {}
liveView = AVPlayerViewController()
#elseif os(OSX)
extension AVPlayerView: Playable {}
liveView = AVPlayerView(frame: NSRect(x: 0, y: 0, width: 640, height: 360))
#endif
XCPlaygroundPage.currentPage.liveView = liveView
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
let movieOfAppleSpecialEventSeptember2015 = "http://p.events-delivery.apple.com.edgesuite.net/1509pijnedfvopihbefvpijlkjb/m3u8/hls_vod_mvp.m3u8"
if let player = NSURL(string: movieOfAppleSpecialEventSeptember2015)
.map(AVPlayer.init) {
liveView.player = player
player.play()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment