您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ViewController.swift 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright @ 2017-present Atlassian Pty Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import UIKit
  17. import JitsiMeet
  18. class ViewController: UIViewController {
  19. @IBOutlet weak var videoButton: UIButton?
  20. fileprivate var pipViewCoordinator: PiPViewCoordinator?
  21. fileprivate var jitsiMeetView: JitsiMeetView?
  22. override func viewDidLoad() {
  23. super.viewDidLoad()
  24. }
  25. override func viewWillTransition(to size: CGSize,
  26. with coordinator: UIViewControllerTransitionCoordinator) {
  27. super.viewWillTransition(to: size, with: coordinator)
  28. let rect = CGRect(origin: CGPoint.zero, size: size)
  29. pipViewCoordinator?.resetBounds(bounds: rect)
  30. }
  31. // MARK: - Actions
  32. @IBAction func openJitsiMeet(sender: Any?) {
  33. cleanUp()
  34. // create and configure jitsimeet view
  35. let jitsiMeetView = JitsiMeetView()
  36. jitsiMeetView.welcomePageEnabled = true
  37. jitsiMeetView.pictureInPictureEnabled = true
  38. jitsiMeetView.load(nil)
  39. jitsiMeetView.delegate = self
  40. self.jitsiMeetView = jitsiMeetView
  41. // Enable jitsimeet view to be a view that can be displayed
  42. // on top of all the things, and let the coordinator to manage
  43. // the view state and interactions
  44. pipViewCoordinator = PiPViewCoordinator(withView: jitsiMeetView)
  45. pipViewCoordinator?.configureAsStickyView(withParentView: view)
  46. // animate in
  47. jitsiMeetView.alpha = 0
  48. pipViewCoordinator?.show()
  49. }
  50. fileprivate func cleanUp() {
  51. jitsiMeetView?.removeFromSuperview()
  52. jitsiMeetView = nil
  53. pipViewCoordinator = nil
  54. }
  55. }
  56. extension ViewController: JitsiMeetViewDelegate {
  57. func conferenceFailed(_ data: [AnyHashable : Any]!) {
  58. hideJitsiMeetViewAndCleanUp()
  59. }
  60. func conferenceLeft(_ data: [AnyHashable : Any]!) {
  61. hideJitsiMeetViewAndCleanUp()
  62. }
  63. func enterPicture(inPicture data: [AnyHashable : Any]!) {
  64. DispatchQueue.main.async {
  65. self.pipViewCoordinator?.enterPictureInPicture()
  66. }
  67. }
  68. private func hideJitsiMeetViewAndCleanUp() {
  69. DispatchQueue.main.async {
  70. self.pipViewCoordinator?.hide() { _ in
  71. self.cleanUp()
  72. }
  73. }
  74. }
  75. }