vMix doesn't provide a callable API, but instead provides an Interface, which you can implement in your XAML codebehind.
Code:Reference C:\Program Files\vMix\vMixInterop.dll, then have your class implement vMixWPFUserControl:
namespace vMix {
using vMixInterop;
public partial class UserControl1 : UserControl, vMixWPFUserControl, INotifyPropertyChanged {
}
There are eight methods, of which two return a TimeSpan, and must be implemented (GetDuration and GetPosition). The other six return a void, so implementation is optional. Here's a summary of the eight methods:
Close() : Called when the Close button is clicked. Close your properties window.
GetDuration() : Called twice per second for each window (once for Preview, and again for Output). Return the duration of your animation, or TimeSpan.Zero if none.
GetPosition() : Called every second for each window (once for Preview, and again for Output). Return the current "position in time" of your animation, TimeSpan.Zero if none.
Load(int width, int height) : Called after your constructor. Stash the width and height in member variables if you need them.
Pause() : Called when: (a) Pause is clicked, (b) Auto Pause with Transition is true, or (c) Position equals Duration. Set your "m_running" member variable to false.
Play() : Called when: (a) Play is clicked, or (b) Auto Play with Transition is true. Set your "m_running" member variable to true.
SetPosition(TimeSpan position) : Called when: (a) Restart is clicked, (b) Auto Restart with Transition is true, or (c) User is scrubbing the control. Update your "m_position" variable.
ShowProperties() : Called when "XAML Properties" is clicked. Show a Windows Form properties window.
If you want to change your image based on user input, implement a Windows Form for a "Properties" window, and show it in the ShowProperties() method:
Code:Reference System.Windows.Forms
namespace vMix {
using System.Windows.Forms;
public partial class Form1 : Form {
private UserControl1 m_parent;
public Form1(UserControl1 parent) {
InitializeComponent();
m_parent = parent;
TopMost = true;
}
}
If you want to change your image based on the DirectShow clock reference, use the GetPosition() method to: (a) update your current "position in time", and (b) update the ImageSource property that your Image control Source property is bound to.
Jon