//
//  ViewController.swift
//  tdvideo
//
//  Created by aaa on 2024/1/19.
// https://www.finnvoorhees.com/words/reading-and-writing-spatial-video-with-avfoundation#reading-spatial-video-using-avassetreader

//import UIKit
//import AVKit
//import AVFoundation
//import CoreImage
//import Foundation
//import Observation
//import VideoToolbox
//import CoreMedia

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
    let options = ["视频转码", "图片转码", "设备投流","视频导出","普通图片合成空间图片","普通视频合成空间视频","拍摄空间图片","拍摄空间视频","边转边播"]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.brown
        
        let tableView = UITableView(frame: view.bounds, style: .plain)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
        view.addSubview(tableView)
    }
    
    // MARK: - UITableViewDataSource
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return options.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        cell.textLabel?.text = options[indexPath.row]
        return cell
    }
    
    // MARK: - UITableViewDelegate
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        
        //视频转码
        if(indexPath.row == 0){
            let vc:ViewController2 = ViewController2()
            self.present(vc, animated: true, completion: nil)
            
        }
        //图片转码
        if(indexPath.row == 1){
            let vc:PlayController = PlayController()
            self.present(vc, animated: true, completion: nil)
            
        }
        //设备连接
        if(indexPath.row == 2){
            let vc = PlayContoller4()
            self.present(vc, animated: true, completion: nil)
            
        }
        //视频导出
        if(indexPath.row == 3){
            let vc = PlayContoller6()
            self.present(vc, animated: true, completion: nil)
            
        }
        //两张普通图片合成空间图片
        if(indexPath.row == 4){
            let vc = PlayContoller7()
            self.present(vc, animated: true, completion: nil)
            
        }
        //两个普通视频合成空间视频
        if(indexPath.row == 5){
            let vc = PlayContoller10()
            self.present(vc, animated: true, completion: nil)
            
        }
        
        //拍摄空间图片
        if(indexPath.row == 6){
            let vc = PlayContoller5()
            self.present(vc, animated: true, completion: nil)
            
        }
        //拍摄空间视频
        if(indexPath.row == 7){
            let vc = PlayContoller9()
            self.present(vc, animated: true, completion: nil)
            
        }
        
        //边转边播
        if(indexPath.row == 8){
            let vc = PlayContoller8()
            self.present(vc, animated: true, completion: nil)
            
        }
        //边拍边转
        if(indexPath.row == 9){
            let vc = PlayContoller11()
            self.present(vc, animated: true, completion: nil)
            
        }
    }
    
}
