// // VideoIntroductionViewController.swift // Learn Genie // // Created by Suraj Kumar Mandal on 30/08/21. // import UIKit import youtube_ios_player_helper import SideMenu class VideoIntroductionViewController: UIViewController { @IBOutlet weak var playerView: YTPlayerView! @IBOutlet var navigationBar: UINavigationBar! let translation = DBManager.sharedInstance.database.objects(TopicModel.self) var topicName = "" var videoId = String() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } override func viewWillAppear(_ animated: Bool) { navigationBar.topItem?.title = Helper.translateText(inputText: topicName) getVideoId() } func getVideoId() { for item in translation { if topicName == item.name { videoId = item.video self.playVideo() } else { //self.view.makeToast("No topic found!") } } } func playVideo() { playerView.load(withVideoId: videoId, playerVars: ["playsinline": "1"]) } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ @IBAction func menuNavAction(_ sender: Any) { let menu = storyboard!.instantiateViewController(withIdentifier: "SideMenuNavigationController") as! SideMenuNavigationController present(menu, animated: true, completion: nil) } @IBAction func headerNavigation(_ sender: UIButton) { switch sender.tag { case 0: DispatchQueue.main.async { let introVC = self.storyboard?.instantiateViewController(withIdentifier: "IntroductionViewController") as! IntroductionViewController introVC.topicName = self.topicName self.navigationController?.pushViewController(introVC, animated: false) } break case 1: DispatchQueue.main.async { let videoVC = self.storyboard?.instantiateViewController(withIdentifier: "VideoIntroductionViewController") as! VideoIntroductionViewController videoVC.topicName = self.topicName self.navigationController?.pushViewController(videoVC, animated: false) } case 2: DispatchQueue.main.async { let audioVC = self.storyboard?.instantiateViewController(withIdentifier: "AudioIntroductionViewController") as! AudioIntroductionViewController audioVC.topicName = self.topicName self.navigationController?.pushViewController(audioVC, animated: false) } default: break } } }