API 參考
螢幕鏡像
透過 app.capabilities 判斷功能支援,透過 app.access 和主機權限判斷存取授權。範例使用合成值;呼叫前請替換路徑、ID、輸入和篩選條件。
型別定義
graphql
type Subscription {
screenMirrorState: MirrorState!
screenMirrorVideoCodec: MirrorCodecConfiguration
screenMirrorAudioGranted: Boolean!
}
type Mutation {
openAccessibilitySettings: Boolean!
requestScreenMirrorAudio: Boolean!
requestScreenMirrorKeyFrame: Boolean!
startScreenMirror(audio: Boolean!): Boolean!
stopScreenMirror: Boolean!
updateScreenMirrorQuality(mode: ScreenMirrorMode!): Boolean!
}
type Query {
isScreenMirroring: Boolean!
screenMirrorControlEnabled: Boolean!
screenMirrorQuality: ScreenMirrorQuality!
screenMirrorVideoCodec: ScreenMirrorVideoCodec
}
type MirrorCodecConfiguration {
annexB: String!
}
type MirrorState {
running: Boolean!
}
enum ScreenMirrorMode {
HD
SMOOTH
}
type ScreenMirrorQuality {
mode: ScreenMirrorMode!
resolution: Int!
}
type ScreenMirrorVideoCodec {
annexB: String!
keyFrame: String
}操作
subscription
screenMirrorState
讀取目前螢幕鏡像狀態。
graphql
subscription screenMirrorState {
screenMirrorState { running }
}subscription
screenMirrorVideoCodec
接收螢幕鏡像工作階段的視訊編碼設定更新。
graphql
subscription screenMirrorVideoCodec {
screenMirrorVideoCodec { annexB }
}subscription
screenMirrorAudioGranted
接收螢幕鏡像音訊權限已獲授權的通知。
graphql
subscription screenMirrorAudioGranted {
screenMirrorAudioGranted
}mutation
openAccessibilitySettings
在裝置上開啟 Android 無障礙設定;sendScreenMirrorControl 傳送手勢前必須先完成此設定。
graphql
mutation openAccessibilitySettings {
openAccessibilitySettings
}mutation
requestScreenMirrorAudio
為螢幕鏡像音訊申請麥克風權限;已授權時回傳 true,否則回傳 false 並彈出權限對話方塊。
graphql
# Returns false when the device has not granted RECORD_AUDIO yet; the
# platform asks for it and the caller retries.
mutation requestScreenMirrorAudio {
requestScreenMirrorAudio
}mutation
requestScreenMirrorKeyFrame
向正在執行的螢幕鏡像影片編碼器請求新的關鍵影格。
graphql
mutation requestScreenMirrorKeyFrame {
requestScreenMirrorKeyFrame
}mutation
startScreenMirror
開始螢幕鏡像工作階段;audio=true 時同時傳輸裝置音訊,需要 RECORD_AUDIO 權限。
graphql
mutation startScreenMirror($audio: Boolean!) {
startScreenMirror(audio: $audio)
}mutation
stopScreenMirror
停止正在執行的螢幕鏡像工作階段。
graphql
mutation stopScreenMirror {
stopScreenMirror
}mutation
updateScreenMirrorQuality
設定螢幕鏡像畫質預設。
graphql
mutation updateScreenMirrorQuality($mode: ScreenMirrorMode!) {
updateScreenMirrorQuality(mode: $mode)
}query
isScreenMirroring
檢查是否存在正在執行的螢幕鏡像工作階段。
graphql
query isScreenMirroring {
isScreenMirroring
}query
screenMirrorControlEnabled
PlainApp 無障礙服務已啟用且可傳送手勢時回傳 true。
graphql
query screenMirrorControlEnabled {
screenMirrorControlEnabled
}query
screenMirrorQuality
取得目前螢幕鏡像畫質預設。
graphql
query screenMirrorQuality {
screenMirrorQuality { mode resolution }
}query
screenMirrorVideoCodec
取得目前或上一次螢幕鏡像工作階段使用的影片編碼格式。
graphql
# Null while the pipeline has not published its codec configuration.
query screenMirrorVideoCodec {
screenMirrorVideoCodec { annexB keyFrame }
}