PlainApp
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 }
}