 
 }
 
+extension ViewController: UIGestureRecognizerDelegate {
+    
+    func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
+        guard !self.childViewControllers.isEmpty else { return true }
+        let tapLocation = touch.locationInView(self.view)
+        guard let _ = musicQueueViewController.tableView.indexPathForRowAtPoint(tapLocation) else { return true }
+        return false
+    }
+    
+}
+
 extension ViewController: MPMediaPickerControllerDelegate {
     
     func mediaPicker(mediaPicker: MPMediaPickerController, didPickMediaItems mediaItemCollection: MPMediaItemCollection) {

    private var verticalConstraints: [NSLayoutConstraint] = []
    private var horizontalConstraints: [NSLayoutConstraint] = []
    
    private let albumListViewController = MusicQueueViewController()
    
    override func loadView() {
        super.loadView()

    
    func tapGestureRecognizerFired(gestureRecognizer: UITapGestureRecognizer) {
        let locationInView = gestureRecognizer.locationInView(self.view)
        
        guard !musPickerButton.frame.contains(locationInView) else {
            self.presentMusicPicker() // tapped on music picker button, present that instead
            return
        }
        
        if self.childViewControllers.isEmpty { // show albumList view
            self.addChildViewController(self.musicQueueViewController)
            self.musicQueueViewController.view.alpha = 0.0
            self.imageView.addSubview(self.musicQueueViewController.view)
            self.musicQueueViewController.view.frame = self.imageView.bounds
            UIView.animateWithDuration(0.5, animations: {
                self.musicQueueViewController.view.alpha = 1.0
                self.imageView.willMoveToSuperview(self.vibrancyEffectView)
            }) { _ in
                self.musicQueueViewController.didMoveToParentViewController(self)
            }
        } else { // hide albumList view
            UIView.animateWithDuration(0.5, animations: {
                self.musicQueueViewController.view.alpha = 0.0
                self.imageView.willMoveToSuperview(self.view)
            }) { bool in
                self.musicQueueViewController.removeFromParentViewController()
                self.musicQueueViewController.view.removeFromSuperview()
                self.musicQueueViewController.didMoveToParentViewController(nil)
            }
        }

    }

    func updateCurrentTrack() {
        guard let songItem = musicPlayer.nowPlayingItem else { return }
        
        self.updatePlaybackState()
        self.musicQueueViewController.currentTrack = songItem
        self.songTitleLabel.text = songItem.valueForProperty(MPMediaItemPropertyTitle) as? String
        let albumTitle = songItem.valueForProperty(MPMediaItemPropertyAlbumTitle) as! String
        let artistTitle = songItem.valueForProperty(MPMediaItemPropertyArtist) as! String
