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

JitsiMeetViewController.swift 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. public enum JitsiMeetPresentationUpdate {
  17. /// The conference wants to enter Picture-in-Picture
  18. case enterPictureInPicture
  19. /// A system traitCollectionChange (usually screen rotation)
  20. case traitChange
  21. }
  22. public protocol JitsiMeetViewControllerDelegate: class {
  23. /// Notifies a change of the conference presentation style.
  24. ///
  25. /// - Parameter to: The presentation state that will be changed to
  26. func performPresentationUpdate(to: JitsiMeetPresentationUpdate)
  27. /// The conference started
  28. func conferenceStarted()
  29. /// The conference ended
  30. ///
  31. /// - Parameter didFail: The reason of ending the conference
  32. func conferenceEnded(didFail: Bool)
  33. }
  34. /// Wrapper ViewController of a JitsiMeetView
  35. ///
  36. /// Is suggested to override this class and implement some customization
  37. /// on how to handle the JitsiMeetView delegate events
  38. open class JitsiMeetViewController: UIViewController {
  39. open weak var delegate: JitsiMeetViewControllerDelegate?
  40. private(set) var jitsiMeetView: JitsiMeetView = JitsiMeetView()
  41. override open func loadView() {
  42. super.loadView()
  43. self.view = jitsiMeetView
  44. }
  45. open override func viewDidLoad() {
  46. super.viewDidLoad()
  47. jitsiMeetView.delegate = self
  48. }
  49. open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
  50. delegate?.performPresentationUpdate(to: .traitChange)
  51. }
  52. }
  53. extension JitsiMeetViewController: JitsiMeetViewDelegate {
  54. open func conferenceWillJoin(_ data: [AnyHashable : Any]!) {
  55. // do something
  56. }
  57. open func conferenceJoined(_ data: [AnyHashable : Any]!) {
  58. DispatchQueue.main.async {
  59. self.delegate?.conferenceStarted()
  60. }
  61. }
  62. open func conferenceWillLeave(_ data: [AnyHashable : Any]!) {
  63. // do something
  64. }
  65. open func conferenceLeft(_ data: [AnyHashable : Any]!) {
  66. DispatchQueue.main.async {
  67. self.delegate?.conferenceEnded(didFail: false)
  68. }
  69. }
  70. open func conferenceFailed(_ data: [AnyHashable : Any]!) {
  71. DispatchQueue.main.async {
  72. self.delegate?.conferenceEnded(didFail: true)
  73. }
  74. }
  75. open func loadConfigError(_ data: [AnyHashable : Any]!) {
  76. DispatchQueue.main.async {
  77. self.delegate?.conferenceEnded(didFail: true)
  78. }
  79. }
  80. open func enterPicture(inPicture data: [AnyHashable : Any]!) {
  81. DispatchQueue.main.async {
  82. self.delegate?.performPresentationUpdate(to: .enterPictureInPicture)
  83. }
  84. }
  85. }