使用闪电线从OSX cocoa应用程序录制iOS设备的屏幕

Mor*_*n J 4 macos cocoa quicktime avfoundation ios

在Quicktime中可以使用New Movie Recording> Camera dropdown>选择iOS设备.AppShowScreenflow都做到了.

我试过这个

AppleScript的

tell application "QuickTime Player"
set myrec to new movie recording
  tell myrec
      set current camera to video recording device named "Morten's iPod touch"
  end tell
end tell
Run Code Online (Sandbox Code Playgroud)

但这给了我

错误"QuickTime播放器出错:无法将视频录制设备"Morten的iPod touch"文件"电影录制"发送到名为"Morten的iPod touch"的视频录制设备"电影录制" ".数字-10006来自视频录制设备"莫滕的iPod touch"文件"电影录制"

AVFoundation 由于iOS设备在Quicktime中显示为相机,我认为它将是AVFoundation中的捕获设备,但此代码

for device in AVCaptureDevice.devices() {
    println(device)
}
Run Code Online (Sandbox Code Playgroud)

只是给我我的Facetime高清摄像头和麦克风.

Pie*_*ard 11

您必须选择在OS X应用中查看iOS屏幕设备.

请参阅" 如何在iOS 8和Yosemite之间设置镜像会话? "

CMIOObjectPropertyAddress   prop    = {
    kCMIOHardwarePropertyAllowScreenCaptureDevices,
    kCMIOObjectPropertyScopeGlobal,
    kCMIOObjectPropertyElementMaster
};
UInt32                      allow   = 1;

CMIOObjectSetPropertyData(kCMIOObjectSystemObject, &prop, 0, NULL, sizeof(allow), &allow);
Run Code Online (Sandbox Code Playgroud)

您可以使用以下方式获取设备列表:

NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed];
Run Code Online (Sandbox Code Playgroud)