螢幕分享
ArctosLinks.Media 提供了一套 API 來啟用與停用螢幕分享的操作。
啟用螢幕分享
功能:啟用螢幕分享。 返回值:如果成功啟用則完成,若是使用時發生例外狀況,則返回錯誤。
注意事項
螢幕分享功能僅能在會議進行時由會議室主持人使用。值得注意的是:在iOS系統上開啟螢幕分享的情況下,若是使用者啟用系統[原生的螢幕錄影器](https://developer.apple.com/documentation/replaykit/rpscreenrecorder),會發生無法取得影像的狀況。
在Android系統上需要先取得權限同意後才能使用此功能
Swift
import ArctosLinks
private func startShareScreen() {
    ArctosLinks.Conference.hostStartShareScreen { result in
        switch result {
        case .success():
            break
        case .failure(let error):
            displayNotification(title: "🚨 Process ERROR", body: error.localizedDescription)
        }
    }
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks
import android.media.projection.MediaProjectionManager
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
private val screenProjectionLauncher: ActivityResultLauncher<Intent> =
    registerForActivityResult(
        ActivityResultContracts.StartActivityForResult()
    ) { result ->
        if (Activity.RESULT_OK == result?.resultCode) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                runCatching {
                    ArctosLinks.getInstance(Context).conferenceManager.hostStartShareScreen(
                        result.resultCode,
                        result.data!!
                    ).getOrThrow()
                }.onSuccess {
                    Log.d(TAG, "Successfully start share screen")                        
                }.onFailure {
                    Log.d(TAG, "Failed : ${it.message}")
                }                    
            }
        } else {                
            runCatching {
                ArctosLinks.getInstance(Context).conferenceManager.hostStopShareScreen().getOrThrow()
            }.onFailure {
                Log.d(TAG, "Failed to stop share screen: ${it.message} ")
            }                
        }
    }
private fun startShareScreen() {        
    val mediaProjectionManager: MediaProjectionManager =
        requireContext().getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
    screenProjectionLauncher.launch(mediaProjectionManager.createScreenCaptureIntent())
}
c++
#include "arctos_qt.h"
void startShareScreen() {
    arctos_app.media()->setShareScreen(true);
}
停用螢幕分享
功能:停用螢幕分享。
返回值:如果成功停用則完成,若是使用時發生例外狀況,則返回錯誤。
Swift
import ArctosLinks
private func stopShareScreen() {
    ArctosLinks.Conference.hostStopShareScreen { result in
        switch result {
        case .success():
            break
        case .failure(let error):
            displayNotification(title: "🚨 Process ERROR", body: error.localizedDescription)
        }
    }
}
Kotlin
import com.arctos.sdk.links.core.application.ArctosLinks
private fun stopShareScreen() {
    runCatching {
        ArctosLinks.getInstance(Context).conferenceManager.hostStopShareScreen()
            .getOrThrow()
    }.onSuccess {
        Log.d(TAG, "Successfully stop Share Screen")
    }.onFailure {
        Log.d(TAG, "Failed : ${it.message}")
    }
}
c++
#include "arctos_qt.h"
void stopShareScreen() {
    arctos_app.media()->setShareScreen(false);
}
