title: How can I play a video using AVPlayer?
body: <p><strong>Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)</strong></p>
  
  <p>I would like to play a video from internet using AVPlayer.
  But, a error occurred "super.init(frame: frame)" in AVPlayer.swift of below source list.</p>
  
  <blockquote>
    <p>Thread 1:EXC_BAD_ACCESS (code=2, address=0x16fc07fe0)
    <a href="https://i.stack.imgur.com/jWdRX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jWdRX.png" alt="enter image description here"></a></p>
  </blockquote>
  
  <p>How can I play a video using AVPlayer?
  If there is wrong point except point of error, let me know it, too.</p>
  
  <p>AVPlayerView.swift</p>
  
  <pre><code>import Foundation
  import UIKit
  
  final class AVPlayerView : UIView {
      required init(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)!
      }
      override init(frame: CGRect) {
          super.init(frame: frame)
      }
      override public class var layerClass: Swift.AnyClass {
          get {
              return AVPlayerView.self
          }
      }
  </code></pre>
  
  <p>}</p>
  
  <p>ViewController.swift</p>
  
  <pre><code>import UIKit
  import AVFoundation
  import CoreMedia
  
  class ViewController: UIViewController {
      var playerItem : AVPlayerItem!
      var videoPlayer : AVPlayer!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          let url:NSURL = NSURL(string: "https://aaa.com/test.m3u8")!
          let avAsset = AVURLAsset(url: url as URL, options: nil)
  
          playerItem = AVPlayerItem(asset: avAsset)
  
          videoPlayer = AVPlayer(playerItem: playerItem)
  
          print(self.view.bounds)
          let videoPlayerView = AVPlayerView(frame: self.view.bounds)
  
          let layer = videoPlayerView.layer as! AVPlayerLayer
          layer.videoGravity = AVLayerVideoGravityResizeAspect
          layer.player = videoPlayer
  
          self.view.layer.addSublayer(layer)
          videoPlayer.play()
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  }
  </code></pre>