Skip to content

Commit

Permalink
Player, setupPlayerItem() should be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Piemonte committed Nov 27, 2014
1 parent 6dcae1d commit 0981ade
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Source/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ public class Player: UIViewController {
}

private var asset: AVURLAsset!
private var playerItem: AVPlayerItem?

private var player: AVPlayer!
private var playerItem: AVPlayerItem!
private var playerView: PlayerView!

// MARK: object lifecycle
Expand Down Expand Up @@ -161,7 +162,7 @@ public class Player: UIViewController {

self.player.pause()

self.playerItem = nil
self.setupPlayerItem(nil)
}

// MARK: view lifecycle
Expand Down Expand Up @@ -327,8 +328,10 @@ public class Player: UIViewController {
case (PlayerStatusKey, &PlayerItemObserverContext):
true
case (PlayerKeepUp, &PlayerItemObserverContext):
if self.playerItem.playbackLikelyToKeepUp && self.playbackState == .Playing {
self.playFromCurrentTime()
if let item = self.playerItem {
if item.playbackLikelyToKeepUp && self.playbackState == .Playing {
self.playFromCurrentTime()
}
}
let status = (change[NSKeyValueChangeNewKey] as NSNumber).integerValue as AVPlayerStatus.RawValue
switch (status) {
Expand Down

0 comments on commit 0981ade

Please sign in to comment.