Programming with DockKit

Any source code samples for how to program DockKit ?

I have read https://developer.apple.com/documentation/DockKit and would like to see it used in an app. For instance, how to setup notification in a SwiftUI-based app running code like this

do {
   for await accessory in try DockAccessoryManager.shared.accessoryStateChanges {
       // If this is an accessory you’re interested in, save it for later use.
   }
} catch {
   log(“Failed fetching state changes, \(error)“)
}
Answered by DTS Engineer in 800266022

In this video, it seems possible to retrieve dock accessory state changes and control the motors after stopping system tracking (06:39),

Sure, that's possible. "Stopping system tracking" basically means "stop moving the dock on your own", at which point you could manually move the dock. This is covered in "Modify rotation and positioning programmatically".

https://developer.apple.com/documentation/dockkit/modify-rotation-and-positioning-behavior-programmatically

However...

so perhaps I need to obtain a reference to the dock from AVCapture as you indicated.

...the more "interesting" parts of DockKit are how it interacts with the camera and image recognition. The APIs for that kind of control exist at many different "levels" of the API, with the right choice really depending on what you actually need/want.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Any source code samples for how to program DockKit ?

No, not that I'm aware of.

I have read https://developer.apple.com/documentation/DockKit and would like to see it used in an app. For instance, how to setup notification in a SwiftUI-based app running code like this

The main thing I'd note here is that DockKit would generally not be directly "tied" into your apps interface. DockKit doesn't really do anything without an active capture session, so it would typically be integrated into the code you were using to manage the camera, not directly tied into your interface.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

In this video, it seems possible to retrieve dock accessory state changes and control the motors after stopping system tracking (06:39), so perhaps I need to obtain a reference to the dock from AVCapture as you indicated.

Accepted Answer

In this video, it seems possible to retrieve dock accessory state changes and control the motors after stopping system tracking (06:39),

Sure, that's possible. "Stopping system tracking" basically means "stop moving the dock on your own", at which point you could manually move the dock. This is covered in "Modify rotation and positioning programmatically".

https://developer.apple.com/documentation/dockkit/modify-rotation-and-positioning-behavior-programmatically

However...

so perhaps I need to obtain a reference to the dock from AVCapture as you indicated.

...the more "interesting" parts of DockKit are how it interacts with the camera and image recognition. The APIs for that kind of control exist at many different "levels" of the API, with the right choice really depending on what you actually need/want.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Programming with DockKit
 
 
Q