YouTubeViewController.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // YouTubeViewController.swift
  3. // LMS
  4. //
  5. // Created by Suraj Kumar Mandal on 19/10/23.
  6. //
  7. import UIKit
  8. import WebKit
  9. class YouTubeViewController: UIViewController {
  10. @IBOutlet var navigationBar: UINavigationBar!
  11. @IBOutlet var youtubeWebView: WKWebView!
  12. var pageName = String()
  13. var youtubeId = String()
  14. override func viewDidLoad() {
  15. super.viewDidLoad()
  16. // Do any additional setup after loading the view.
  17. navigationBar.topItem?.title = pageName
  18. // Set the navigation delegate to monitor page load progress.
  19. //youtubeWebView.navigationDelegate = self
  20. // Replace "VIDEO_ID" with your YouTube video's ID.
  21. let videoID = youtubeId
  22. let videoURL = URL(string: "https://www.youtube.com/embed/\(videoID)")
  23. if let url = videoURL {
  24. let request = URLRequest(url: url)
  25. youtubeWebView.load(request)
  26. }
  27. }
  28. /*
  29. // MARK: - Navigation
  30. // In a storyboard-based application, you will often want to do a little preparation before navigation
  31. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  32. // Get the new view controller using segue.destination.
  33. // Pass the selected object to the new view controller.
  34. }
  35. */
  36. @IBAction func backAction(_ sender: UIBarButtonItem) {
  37. self.navigationController?.popViewController(animated: true)
  38. }
  39. }