ScreenMeetSDK 3.0.9

ScreenMeetSDK 3.0.9

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布日期最后发布Nov 2023
SPM支持 SPM

ScreenMeet 管理员IvanEvance Mok 维护。



 
依赖关系
Socket.IO-Client-Swift~> 15.2.0
UniversalWebRTC~> 106.0.7
 

  • ScreenMeet

ScreenMeetSDK

Version License Platform

ScreenMeet

ScreenMeet.com

使用方法

加入 ScreenMeetLive 会话

ScreenMeet.config.organizationKey = yourMobileAPIKey //provided by ScreenMeet
let code = "OdeWGubyvsUh"             // session code
ScreenMeet.connect(code) { [weak self] error in  
    if let error = error { 
        // session start error
    } else {
        // session started
    }
}

检索连接状态

let connectionState = ScreenMeet.getConnectionState() 

switch connectionState {
case .connecting:
    print("waiting for connecting to call ...")
case .connected:
    print("joined the call")
case .reconnecting:
    print("trying to restore connection to call ...")
case .disconnected(.callNotStarted):
    print("Call disconnected. Call is not started")
case .disconnected(.callEnded):
    print("Call disconnected. Call is finished")
case .disconnected(.leftCall):
    print("Call disconnected. Client left call")
case .disconnected(.networkError):
    print("Call disconnected. Network error")
}

共享摄像头

ScreenMeet.shareCamera() // by default start front camera sharing

要指定摄像头和/或摄像头配置,请使用 AVCaptureDevice

let device = AVCaptureDevice.DiscoverySession.init(deviceTypes: [.builtInWideAngleCamera],
                                                    mediaType: .video,
                                                    position: .back).devices.first!
ScreenMeet.shareCamera(device)

共享屏幕

ScreenMeet.shareScreen()

共享图像流(可以通过连续提供原始图像、屏幕截图等来用于屏幕共享)SMImageHandler 包含单个接口 transferImage(_ image: UIImage),您可以使用它来发送图像

ScreenMeet.shareScreenWithImageTransfer(_ completion: @escaping ((SMImageHandler?) -> Void))

停止视频共享

ScreenMeet.stopVideoSharing() // Stop Camera or Screen sharing

共享麦克风

ScreenMeet.shareMicrophone()

停止音频共享

ScreenMeet.stopAudioSharing() // Stop audio sharing

检索音频和视频状态

let state = ScreenMeet.getMediaState()

let isAudioActive = state.isAudioActive // true: unmuted, false: muted 
let isVideoActive = state.isVideoActive // true: unmuted, false: muted 

let videoState = state.videoState // VideoState enum [CAMERA, SCREEN, NONE]
let audioState = state.audioState // AudioState enum [MICROPHONE, NONE]

离开会话

ScreenMeet.disconnect()

呼叫参与者

let partisipantsList =  ScreenMeet.getParticipants() // Returns list of call participants [SMParticipant]

示例

要运行示例项目,请克隆仓库,然后首先从示例目录运行pod install。有关使用 SwiftUI 的更高级示例,请查看FullExample应用程序。

需求

最低 iOS 版本
ScreenMeetSDK iOS 12.0
示例 iOS 13.0

安装

ScreenMeetSDK 通过CocoaPods提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'ScreenMeetSDK'

当使用 xCode14.3 构建时,应在 Podfile 中添加一个设置最小部署目标的 post install 钩子

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

ScreenMeetLive 事件处理

配置事件处理器

设置您的事件处理器

ScreenMeet.delegate = yourSMDelegate

其中yourSMDelegate是您对 ScreenMeetDelegate 协议的实现

本地跟踪事件

/// on Audio stream created
func onLocalAudioCreated()

/// on Local Video stream created
/// - Parameter videoTrack: Can be used to preview local video. See `RTCVideoTrack`
func onLocalVideoCreated(_ videoTrack: RTCVideoTrack)

/// on Local Video stream stoped
func onLocalVideoStopped()

/// on Local Audio stream stoped
func onLocalAudioStopped()

参与者事件

/// On participant joins call.
/// - Parameter participant: Participant details. See `SMParticipant`
func onParticipantJoined(_ participant: SMParticipant)

/// On receiving video stream from participant.
/// - Parameter participant: Participant details. See `SMParticipant`
/// - Parameter remoteVideoTrack: Can be used to preview participant video stream. See `RTCVideoTrack`
func onParticipantVideoTrackCreated(_ participant: SMParticipant, _ remoteVideoTrack: RTCVideoTrack)

/// On receiving video stream from participant.
/// - Parameter participant: Participant details. See `SMParticipant`
/// - Parameter remoteAudioTrack: Remote participant audio stream. See `RTCAudioTrack`
func onParticipantAudioTrackCreated(_ participant: SMParticipant, _ remoteAudioTrack: RTCAudioTrack)

/// On participant left call.
/// - Parameter participant: Participant details. See `SMParticipant`
func onParticipantLeft(_ participant: SMParticipant)

/// When participant state was changed. For example participant muted, paused, resumed video, etc
/// - Parameter participant: Participant details. See `SMParticipant`
func onParticipantMediaStateChanged(_ participant: SMParticipant)

/// When active speaker changed. 
/// - Parameter participant: Participant details. See `SMParticipant`
func onActiveSpeakerChanged(_ participant: SMParticipant, _ remoteVideoTrack: RTCVideoTrack)

功能请求(遥控,激光指针)

/// Occurs when approval for a feature(remote control or laser pointer) is requested from you
///
/// - Parameters:
///  - feature: Feature being requested. Containes details about type of the feature and participant who requested it
///  - decisionHandler: The callback called after request is accepted or denied
///  - granted: The retrieved decision for request.
func onFeatureRequest(_ feature: SMFeature, _ decisionHandler: @escaping (_ granted: Bool) -> Void)
    
/// Occurs when previous request is rejected
///
/// - Parameters:
/// - feature: Feature request that has been rejested. Containes details about type of the feature and participant who requested it
func onFeatureRequestRejected(feature: SMFeature)
    
/// Occurs when a feature has stopped
///
/// - Parameters:
///  - feture: Feature that has been stopped
func onFeatureStopped(feature: SMFeature)
    
/// Occurs when certain feature (you approved) starts its activity (remote control, laser pointer)
///
/// - Parameters:
///  - feature: Feature that has stated
func onFeatureStarted(feature: SMFeature)
    

遥控

/// Occures during remote control session when an agent triggers and event. Can be a mouse or a keybaord event
///
/// - Parameters:
///  - event: Remote control event. See `SMRemoteControlEvent`
func onRemoteControlEvent(_ event: SMRemoteControlEvent)
    
/// Root view controller to be remote controlled (Allowing viewer to perform touches on your view controller(s)). It should be the root(bottom most superview) view of the entire window
var rootViewController: UIViewController? { get }

重要错误事件

/// When error occurred
/// - Parameter error `SMError`
func onError(_ error: SMError)

连接状态变化

/// On connection state change
/// - Parameter new session state: `SMState`
func onConnectionStateChanged(_ newState: SMConnectionState)

配置

ScreenMeet Live 需要初始配置才能加入会议

//Create config object
let config = SMSessionConfig()

组织密钥

开始使用 SDK 需要 组织密钥(mobileKey)

//Set organization mobile Key
ScreenMeet.shared.config.organizationKey = yourMobileAPIKey //provided by ScreenMeet

日志级别

表示日志信息的严重性和重要性

config.loggingLevel = .debug

可能值

public enum LogLevel {
    /// Information that may be helpful, but is not essential, for troubleshooting errors
    case info
    /// Verbose information that may be useful during development or while troubleshooting a specific problem
    case debug
    /// Designates error events that might still allow the application to continue running
    case error
}

自定义端点 URL

设置自定义端点 URL

config.endpoint = yourEndpointURL

授权

ScreenMeetLiveSDK 采用 MIT 许可证。更多信息请查看 LICENSE 文件。