<commit_before>//
//  MediaPreviewViewController.swift
//  Yep
//
//  Created by nixzhu on 15/11/10.
//  Copyright © 2015年 Catch Inc. All rights reserved.
//

import UIKit
import AVFoundation
import MonkeyKing

let mediaPreviewWindow = UIWindow(frame: UIScreen.mainScreen().bounds)

class MediaPreviewViewController: UIViewController {

    var previewMedias: [PreviewMedia] = []
    var startIndex: Int = 0
    var currentIndex: Int = 0

    var currentPlayer: AVPlayer?

    @IBOutlet weak var mediasCollectionView: UICollectionView!<commit_msg>record mediaPlayed when preview message<commit_after>//
//  MediaPreviewViewController.swift
//  Yep
//
//  Created by nixzhu on 15/11/10.
//  Copyright © 2015年 Catch Inc. All rights reserved.
//

import UIKit
import AVFoundation
import MonkeyKing

let mediaPreviewWindow = UIWindow(frame: UIScreen.mainScreen().bounds)

class MediaPreviewViewController: UIViewController {

    var previewMedias: [PreviewMedia] = []
    var startIndex: Int = 0
    var currentIndex: Int = 0 {
        didSet {
            if let previewMedia = previewMedias[safe: currentIndex] {
                switch previewMedia {
                case .MessageType(let message):
                    guard !message.mediaPlayed else {
                        break
                    }
                    guard let realm = message.realm else {
                        break
                    }
                    let _ = try? realm.write {
                        message.mediaPlayed = true
                    }
                case .AttachmentType:
                    break
                }
            }
        }
    }

    var currentPlayer: AVPlayer?

    @IBOutlet weak var mediasCollectionView: UICollectionView!
{'fraction_non_alphanumeric': 0.07511467889908256, 'fraction_numerical': 0.013761467889908258, 'mean_word_length': 1.9034941763727122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1792086', 'n_tokens_mistral': 492, 'n_tokens_neox': 446, 'n_words': 128}