 		playLayer.videoGravity = AVLayerVideoGravityResizeAspect
 		view.layer.addSublayer(playLayer)
 
-		NSNotificationCenter.defaultCenter().addObserver(self,
-			selector: Selector("playbackReachedEndNotification:"),
-			name: AVPlayerItemDidPlayToEndTimeNotification,
-			object: nil)
-
 		NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("applicationDidBecomeActiveNotification:"), name: UIApplicationDidBecomeActiveNotification, object: nil)
 		NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("applicationWillResignActiveNotification:"), name: UIApplicationWillResignActiveNotification, object: nil)
-
-		play()
     }
 
 	@objc
 	func applicationDidBecomeActiveNotification(note: NSNotification) {
-		play(1.0)
+		play(rate)
 	}
 
 	@objc

		}
	}

    override func viewDidLoad() {
        super.viewDidLoad()



	override func viewWillAppear(animated: Bool) {
		super.viewWillAppear(animated)
		play(rate)
	}

	override func viewDidDisappear(animated: Bool) {
		super.viewDidDisappear(animated)
		play(0.0)
	}

	func resetPlayer() {
		playControl?.removeObserver(self, forKeyPath: "status", context: UnsafeMutablePointer<Void>())
		NSNotificationCenter.defaultCenter().removeObserver(self, name: "playbackReachedEndNotification", object: playControl?.currentItem)

		if let url = url {
			playControl = AVPlayer(URL: url)
			playControl?.addObserver(self, forKeyPath: "status", options: .Initial, context: UnsafeMutablePointer<Void>())
			playLayer.player = playControl

			NSNotificationCenter.defaultCenter().addObserver(self,
				selector: Selector("playbackReachedEndNotification"),
				name: AVPlayerItemDidPlayToEndTimeNotification,
				object: playControl?.currentItem)
		}
	}

