<commit_before>//
//  DetailViewController.swift
//  YoutubeClient
//
//  Created by <NAME> on 12/23/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import youtube_parser
import AVKit
import AVFoundation

class DetailViewController: UIViewController {

    @IBOutlet weak var playButton: UIButton!
    @IBOutlet weak var detailDescriptionLabel: UILabel!

    let moviePlayer = AVPlayerViewController()


    var detailItem: AnyObject? {
        didSet {
            // Update the view.
            self.configureView()
        }
    }

    func configureView() {
        // Update the user interface for the detail item.
        if let youtubeURLString = self.detailItem {
            if let label = self.detailDescriptionLabel {
                label.text = youtubeURLString.description
            }
            
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        self.configureView()
        
        
        moviePlayer.view.frame = view.frame
//        view.addSubview(moviePlayer.view)
        self.presentViewController(moviePlayer, animated: true) { () -> Void in
            //
        }
        

//        let youtubeURL = NSURL(string: "https://www.youtube.com/watch?v=swZJwZeMesk")!
        if let videoInfo = self.detailItem {
            if let videoURLString = videoInfo["url"] as? String {
                let youtubeURL = NSURL(string: videoURLString)!
                playVideoWithYoutubeURL(youtubeURL)
            }
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    func playVideoWithYoutubeURL(url: NSURL) {
        let playerItem = AVPlayerItem.init(URL: url)
        let player = AVPlayer(playerItem: playerItem)
        
        self.moviePlayer.player = player

        
        Youtube.h264videosWithYoutubeURL(url, completion: { (videoInfo, error) -> Void in
            if let videoURLString = videoInfo?["url"] as? String where ((videoInfo?["title"] as? String) != nil) {
                
                print("動画のURL: \(videoURLString)")
                let playerItem = AVPlayerItem.init(URL: NSURL(string: videoURLString)!)
                let player = AVPlayer(playerItem: playerItem)
                
                self.moviePlayer.player = player
//                self.moviePlayer.contentURL = NSURL(string: videoURLString)

            }
        })
    }
    
    @IBAction func tappedPlayButton(sender: AnyObject) {
    }

}
<commit_msg>コードのリファクタリング（主に変数名）<commit_after>//
//  DetailViewController.swift
//  YoutubeClient
//
//  Created by <NAME> on 12/23/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import UIKit
import youtube_parser
import AVKit
import AVFoundation

class DetailViewController: UIViewController {

    // MARK: - Properties
    
    @IBOutlet weak var playButton: UIButton!
    @IBOutlet weak var detailDescriptionLabel: UILabel!

    let avPlayer = AVPlayerViewController()

    var detailItem: AnyObject? {
        didSet {
            // Update the view.
            self.configureView()
        }
    }

    // MARK: - View life cycle

    func configureView() {
        // Update the user interface for the detail item.
        if let youtubeURLString = self.detailItem {
            if let label = self.detailDescriptionLabel {
                label.text = youtubeURLString.description
            }
            
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        self.configureView()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    // MARK: - Actions
    
    @IBAction func tappedPlayButton(sender: AnyObject) {
        avPlayer.view.frame = view.frame
        self.presentViewController(avPlayer, animated: true) { () -> Void in
            //
        }
        
        
        //        let youtubeURL = NSURL(string: "https://www.youtube.com/watch?v=swZJwZeMesk")!
        if let videoInfo = self.detailItem {
            if let videoURLString = videoInfo["url"] as? String {
                let youtubeURL = NSURL(string: videoURLString)!
                playVideoWithYoutubeURL(youtubeURL)
            }
        }
    }

    // MARK: - Utility Methods
    
    func playVideoWithYoutubeURL(url: NSURL) {
        let playerItem = AVPlayerItem.init(URL: url)
        let player = AVPlayer(playerItem: playerItem)
        
        self.avPlayer.player = player
        
        Youtube.h264videosWithYoutubeURL(url, completion: { (videoInfo, error) -> Void in
            if let videoURLString = videoInfo?["url"] as? String where ((videoInfo?["title"] as? String) != nil) {
                
                print("動画のURL: \(videoURLString)")
                let playerItem = AVPlayerItem.init(URL: NSURL(string: videoURLString)!)
                let player = AVPlayer(playerItem: playerItem)
                
                self.avPlayer.player = player
                //                self.avPlayer.contentURL = NSURL(string: videoURLString)
                self.avPlayer.player?.play()
            }
        })
    }
}

{'fraction_non_alphanumeric': 0.09242144177449169, 'fraction_numerical': 0.004805914972273568, 'mean_word_length': 1.8982324584895554, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1688192', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1445, 'n_words': 357}