Skip to content

Commit e164b6d

Browse files
committed
update for Swift 1.2, Xcode 6.3
1 parent 104f861 commit e164b6d

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

bk2ch15p659SimplestAVKit/SimplestAVKit/ViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ class ViewController: UIViewController {
88

99
@IBAction func doPresent(sender: AnyObject) {
1010

11-
let which = 1
11+
let which = 2
1212
switch which {
1313
case 1:
1414
let av = AVPlayerViewController()
15-
// let url = NSBundle.mainBundle().URLForResource("ElMirage", withExtension: "mp4")
16-
let url = NSBundle.mainBundle().URLForResource("wilhelm", withExtension: "aiff")
15+
let url = NSBundle.mainBundle().URLForResource("ElMirage", withExtension: "mp4")
16+
// let url = NSBundle.mainBundle().URLForResource("wilhelm", withExtension: "aiff")
1717
let player = AVPlayer(URL: url)
1818
av.player = player
1919
self.presentViewController(av, animated: true, completion: {

bk2ch15p660EmbeddedAVKit/EmbeddedAVKit/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ViewController: UIViewController {
7272
override func observeValueForKeyPath(keyPath: String, ofObject object: AnyObject, change: [NSObject : AnyObject], context: UnsafeMutablePointer<()>) {
7373
if keyPath == "readyForDisplay",
7474
let obj = object as? AVPlayerViewController,
75-
let ok = change[NSKeyValueChangeNewKey] as? Bool where ok {
75+
ok = change[NSKeyValueChangeNewKey] as? Bool where ok {
7676
dispatch_async(dispatch_get_main_queue(), {
7777
self.finishConstructingInterface(obj)
7878
})
@@ -82,7 +82,7 @@ class ViewController: UIViewController {
8282
func finishConstructingInterface (vc:AVPlayerViewController) {
8383
println("finishing")
8484
vc.removeObserver(self, forKeyPath:"readyForDisplay")
85-
vc.view.hidden = false
85+
vc.view.hidden = false // hmm, maybe I should be animating the alpha instead
8686
}
8787
}
8888

bk2ch15p661EmbeddedAVKit2/EmbeddedAVKit/ViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ViewController: UIViewController {
5050

5151
func getVideoTrack(asset:AVAsset) {
5252
// we have tracks or we wouldn't be here
53-
let vtrack = asset.tracksWithMediaCharacteristic(AVMediaCharacteristicVisual)[0] as AVAssetTrack
53+
let vtrack = asset.tracksWithMediaCharacteristic(AVMediaCharacteristicVisual)[0] as! AVAssetTrack
5454
vtrack.loadValuesAsynchronouslyForKeys(["naturalSize"], completionHandler: {
5555
let status = vtrack.statusOfValueForKey("naturalSize", error: nil)
5656
if status == .Loaded {
@@ -89,7 +89,7 @@ class ViewController: UIViewController {
8989
}
9090

9191
func finishConstructingInterface () {
92-
let vc = self.childViewControllers[0] as AVPlayerViewController
92+
let vc = self.childViewControllers[0] as! AVPlayerViewController
9393
if !vc.readyForDisplay {
9494
return
9595
}

bk2ch15p669playerLayer/ch28p939playerLayer/ViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class ViewController: UIViewController {
8787

8888
let type = AVMediaTypeVideo
8989
let arr = oldAsset.tracksWithMediaType(type)
90-
let track = arr.last as AVAssetTrack
90+
let track = arr.last as! AVAssetTrack
9191

9292
let duration : CMTime = track.timeRange.duration
9393

@@ -100,7 +100,7 @@ class ViewController: UIViewController {
100100

101101
let type2 = AVMediaTypeAudio
102102
let arr2 = oldAsset.tracksWithMediaType(type2)
103-
let track2 = arr2.last as AVAssetTrack
103+
let track2 = arr2.last as! AVAssetTrack
104104
let comptrack2 = comp.addMutableTrackWithMediaType(type2, preferredTrackID:Int32(kCMPersistentTrackID_Invalid))
105105

106106
comptrack2.insertTimeRange(CMTimeRangeMake(CMTimeMakeWithSeconds(0,600), CMTimeMakeWithSeconds(5,600)), ofTrack:track2, atTime:CMTimeMakeWithSeconds(0,600), error:nil)
@@ -111,7 +111,7 @@ class ViewController: UIViewController {
111111
let s = NSBundle.mainBundle().URLForResource("aboutTiagol", withExtension:"m4a")
112112
let asset = AVURLAsset(URL:s, options:nil)
113113
let arr3 = asset.tracksWithMediaType(type3)
114-
let track3 = arr3.last as AVAssetTrack
114+
let track3 = arr3.last as! AVAssetTrack
115115

116116
let comptrack3 = comp.addMutableTrackWithMediaType(type3, preferredTrackID:Int32(kCMPersistentTrackID_Invalid))
117117
comptrack3.insertTimeRange(CMTimeRangeMake(CMTimeMakeWithSeconds(0,600), CMTimeMakeWithSeconds(10,600)), ofTrack:track3, atTime:CMTimeMakeWithSeconds(0,600), error:nil)
@@ -129,7 +129,7 @@ class ViewController: UIViewController {
129129

130130
self.player.replaceCurrentItemWithPlayerItem(item)
131131
self.playerLayer.addObserver(self, forKeyPath:"readyForDisplay", options:nil, context:nil)
132-
(sender as UIControl).enabled = false
132+
(sender as! UIControl).enabled = false
133133
}
134134

135135
@IBAction func restart (sender:AnyObject!) {

bk2ch15p672AVKit/ch28p939playerLayer/ViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ViewController: UIViewController {
3535
}
3636

3737
func finishConstructingInterface () {
38-
let vc = self.childViewControllers[0] as AVPlayerViewController
38+
let vc = self.childViewControllers[0] as! AVPlayerViewController
3939
let p = vc.player
4040
if p.status != .ReadyToPlay {
4141
return
@@ -79,15 +79,15 @@ class ViewController: UIViewController {
7979
// can be a mutable composition
8080

8181
@IBAction func doButton2 (sender:AnyObject!) {
82-
let vc = self.childViewControllers[0] as AVPlayerViewController
82+
let vc = self.childViewControllers[0] as! AVPlayerViewController
8383
let p = vc.player
8484
p.pause()
8585

8686
let oldAsset = p.currentItem.asset
8787

8888
let type = AVMediaTypeVideo
8989
let arr = oldAsset.tracksWithMediaType(type)
90-
let track = arr.last as AVAssetTrack
90+
let track = arr.last as! AVAssetTrack
9191

9292
let duration : CMTime = track.timeRange.duration
9393

@@ -100,7 +100,7 @@ class ViewController: UIViewController {
100100

101101
let type2 = AVMediaTypeAudio
102102
let arr2 = oldAsset.tracksWithMediaType(type2)
103-
let track2 = arr2.last as AVAssetTrack
103+
let track2 = arr2.last as! AVAssetTrack
104104
let comptrack2 = comp.addMutableTrackWithMediaType(type2, preferredTrackID:Int32(kCMPersistentTrackID_Invalid))
105105

106106
comptrack2.insertTimeRange(CMTimeRangeMake(CMTimeMakeWithSeconds(0,600), CMTimeMakeWithSeconds(5,600)), ofTrack:track2, atTime:CMTimeMakeWithSeconds(0,600), error:nil)
@@ -111,7 +111,7 @@ class ViewController: UIViewController {
111111
let s = NSBundle.mainBundle().URLForResource("aboutTiagol", withExtension:"m4a")
112112
let asset = AVURLAsset(URL:s, options:nil)
113113
let arr3 = asset.tracksWithMediaType(type3)
114-
let track3 = arr3.last as AVAssetTrack
114+
let track3 = arr3.last as! AVAssetTrack
115115

116116
let comptrack3 = comp.addMutableTrackWithMediaType(type3, preferredTrackID:Int32(kCMPersistentTrackID_Invalid))
117117
comptrack3.insertTimeRange(CMTimeRangeMake(CMTimeMakeWithSeconds(0,600), CMTimeMakeWithSeconds(10,600)), ofTrack:track3, atTime:CMTimeMakeWithSeconds(0,600), error:nil)
@@ -129,7 +129,7 @@ class ViewController: UIViewController {
129129
// ...we supply the .Initial option
130130
p.addObserver(self, forKeyPath:"status", options:.Initial, context:nil)
131131
p.replaceCurrentItemWithPlayerItem(item)
132-
(sender as UIControl).enabled = false
132+
(sender as! UIControl).enabled = false
133133
}
134134

135135

bk2ch15p673onlyOne/ch28p939playerLayer/ViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class ViewController: UIViewController {
9696

9797
let type = AVMediaTypeVideo
9898
let arr = oldAsset.tracksWithMediaType(type)
99-
let track = arr.last as AVAssetTrack
99+
let track = arr.last as! AVAssetTrack
100100

101101
let duration : CMTime = track.timeRange.duration
102102

@@ -109,7 +109,7 @@ class ViewController: UIViewController {
109109

110110
let type2 = AVMediaTypeAudio
111111
let arr2 = oldAsset.tracksWithMediaType(type2)
112-
let track2 = arr2.last as AVAssetTrack
112+
let track2 = arr2.last as! AVAssetTrack
113113
let comptrack2 = comp.addMutableTrackWithMediaType(type2, preferredTrackID:Int32(kCMPersistentTrackID_Invalid))
114114

115115
comptrack2.insertTimeRange(CMTimeRangeMake(CMTimeMakeWithSeconds(0,600), CMTimeMakeWithSeconds(5,600)), ofTrack:track2, atTime:CMTimeMakeWithSeconds(0,600), error:nil)
@@ -120,7 +120,7 @@ class ViewController: UIViewController {
120120
let s = NSBundle.mainBundle().URLForResource("aboutTiagol", withExtension:"m4a")
121121
let asset = AVURLAsset(URL:s, options:nil)
122122
let arr3 = asset.tracksWithMediaType(type3)
123-
let track3 = arr3.last as AVAssetTrack
123+
let track3 = arr3.last as! AVAssetTrack
124124

125125
let comptrack3 = comp.addMutableTrackWithMediaType(type3, preferredTrackID:Int32(kCMPersistentTrackID_Invalid))
126126
comptrack3.insertTimeRange(CMTimeRangeMake(CMTimeMakeWithSeconds(0,600), CMTimeMakeWithSeconds(10,600)), ofTrack:track3, atTime:CMTimeMakeWithSeconds(0,600), error:nil)

0 commit comments

Comments
 (0)