【问题标题】:Recording an iOS device's screen from an OSX cocoa app with a lightning cable使用闪电电缆从 OSX 可可应用程序记录 iOS 设备的屏幕
【发布时间】:2015-05-05 16:03:03
【问题描述】:

可以在 Quicktime 中使用新电影录制 > 相机下拉菜单 > 选择 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

但这给了我

错误“QuickTime Player 出现错误:无法将文档 \"Movie Recording\" 的视频录制设备 \"Morten's iPod touch\" 设置为文档 \"Movie" 的名为 \"Morten's iPod touch\" 的视频录制设备记录\”。”来自文档“Movie Recording”的视频录制设备“Morten's iPod touch”的编号 -10006

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

for device in AVCaptureDevice.devices() {
    println(device)
}

只要给我我的 Facetime 高清摄像头和麦克风。

【问题讨论】:

标签: ios macos cocoa avfoundation quicktime


【解决方案1】:

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

见“How do I set up a mirroring session between iOS 8 and Yosemite?

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

CMIOObjectSetPropertyData(kCMIOObjectSystemObject, &prop, 0, NULL, sizeof(allow), &allow);

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

NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeMuxed];

【讨论】:

  • 有效!我无法将其翻译成 Swift。也许这是不可能的? (我写了一个 objc 类,它只做上面的事情,但是桥接头让 Xcode 自动完成非常慢!)
【解决方案2】:
var property = CMIOObjectPropertyAddress(mSelector: CMIOObjectPropertySelector(kCMIOHardwarePropertyAllowScreenCaptureDevices), mScope: CMIOObjectPropertyScope(kCMIOObjectPropertyScopeGlobal), mElement: CMIOObjectPropertyElement(kCMIOObjectPropertyElementMaster))
var allow : UInt32 = 1
let sizeOfAllow = MemoryLayout<UInt32>.size
CMIOObjectSetPropertyData(CMIOObjectID(kCMIOObjectSystemObject), &property, 0, nil, UInt32(sizeOfAllow), &allow)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-21
    • 2019-07-08
    • 1970-01-01
    • 2016-12-31
    • 1970-01-01
    • 1970-01-01
    • 2015-04-20
    • 1970-01-01
    相关资源
    最近更新 更多