title: iOS Swift Mute-unmute audio like facebook autoplay videos
body: <p>I am currently using MPMoviePlayerController? to play video inside my app. But I want to have facebook style videos where initially the video plays mute but when the user taps it un-mutes. </p>
  
  <p>I am new in programming, but as per my research I wasn't able to find anything in MPMoviePlayerController? in which we can do that.</p>
  
  <p>Currently I am using the following code to play a video.</p>
  
  <pre><code>class InformationViewController: UIViewController {
  
  @IBOutlet var thumbnailImage: UIImageView!
  @IBOutlet var videoPlayerView: UIView!
  
  @IBOutlet var controlBtn: UIButton!
  
  var moviePlayer:MPMoviePlayerController!
  var url:NSURL = NSURL(string: "http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v")!
  var audioPlayer = AVAudioPlayer()
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
  
  }
  
  
  @IBAction func controlBtn(sender: AnyObject) {
      controlBtn.alpha = 0
      moviePlayer = MPMoviePlayerController(contentURL: url)
      let frameWidth = self.videoPlayerView.frame.size.width
      let frameHeight = self.videoPlayerView.frame.size.height
  
      //moviePlayer.view.frame = CGRect(x: 24, y: 18, width: frameWidth, height: frameHeight)
  
      self.videoPlayerView.addSubview(moviePlayer.view)
  
  
      //     Send button backword
      self.videoPlayerView.sendSubviewToBack(moviePlayer.view)
      moviePlayer.fullscreen = false
      moviePlayer.controlStyle = MPMovieControlStyle.Embedded
  
      // Pure Visual Format Language style (http://stackoverflow.com/questions/26180822/swift-adding-constraints-programmatically)
      (moviePlayer.view).setTranslatesAutoresizingMaskIntoConstraints(false)
      let views = ["view": videoPlayerView, "videoView": moviePlayer.view]
  
      var constH = NSLayoutConstraint.constraintsWithVisualFormat("H:[view]-(&lt;=0)-[videoView(\(frameWidth))]", options: .AlignAllCenterY, metrics: nil, views: views)
      view.addConstraints(constH)
      var constW = NSLayoutConstraint.constraintsWithVisualFormat("V:[view]-(&lt;=0)-[videoView(\(frameHeight))]", options: .AlignAllCenterX, metrics: nil, views: views)
      view.addConstraints(constW)
  
  }
  
  override func viewDidDisappear(animated: Bool) {
      super.viewDidDisappear(animated)  ///&lt; Don't for get this BTW!
  
      if let player = self.moviePlayer {
          player.stop()
      }
  }}
  </code></pre>