Created
October 8, 2015 00:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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