IWMEncDeviceControlPlugin::get_CurrentPosition

Windows Media Encoder SDK banner art

The get_CurrentPosition method retrieves the current time code position on tape.

Syntax

HRESULT get_CurrentPosition(
  WMTIMECODE_SAMPLE*  ptimecodeSample
);

Parameters

ptimecodeSample

[out]  Pointer to a member of the WMTIMECODE_SAMPLE structure specifying the time code.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code Number Description
E_POINTER 0x80004003 The pointer to the structure is NULL.

Example Code

// Include libraries.#include <windows.h>
#include <atlbase.h>
#include <comdef.h>
#include "C:\WMSDK\WMEncSDK9\include\wmencode.h"
#include "C:\WMSDK\WMEncSDK9\include\wmdevctl.h"

    // Declare variables.
    HRESULT hr;
    IWMEncoder2* pEncoder;
    IWMEncSource* pSrcAud;
    IWMEncSource* pSrcVid;
    IWMEncDeviceControlCollection* pDCColl;
    IWMEncDeviceControl* pDControl;
    IWMEncDeviceControlPlugin* pDCPlugin;

    // Initialize the COM library and retrieve a pointer
    // to an IWMEncoder interface.
    hr = CoInitialize(NULL);
    if ( SUCCEEDED( hr ) )
    {
        hr = CoCreateInstance(CLSID_WMEncoder,
            NULL,
            CLSCTX_INPROC_SERVER,
            IID_IWMEncoder2,
            (void**) &pEncoder);
    }

    // Configure the encoding session, including the sources, profile,
    // and output file.

    // Add the device as the audio source and video source.
    if ( SUCCEEDED( hr ) )
    {
        hr = pSrcAud->SetInput(CComBSTR("Device://DEVICENAME"));
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pSrcVid->SetInput(CComBSTR("Device://DEVICENAME"));
    }

    // Retrieve the device control collection, then add a device to it.
    if ( SUCCEEDED( hr ) )
    {
        hr = pSrcGrp2->get_DeviceControlCollection(&pDCColl);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pDCColl->Add(&pDControl);
    }
    if ( SUCCEEDED( hr ) )
    {
        hr = pDControl->SetInput(CComBSTR("DeviceControl://DEVICENAME")); // Replace the device name.
    }

    // Initialize the encoding session.    if ( SUCCEEDED( hr ) )
    {
        hr = pEncoder->PrepareToEncode(VARIANT_TRUE);
    }

    // Get the plug-in from the device.    if ( SUCCEEDED( hr ) )
    {
        hr = pDControl->GetDeviceControlPlugin((IUnknown**)&pDCPlugin);
    }

    // Retrieve the current position as a WMTIMECODE_SAMPLE structure.
    WMTIMECODE_SAMPLE strucPosition;
    if ( SUCCEEDED( hr ) )
    {
        hr = pDCPlugin->get_CurrentPosition(&strucPosition);
    }

    // Release pointers.
    if ( pSrcAud )
    {
        pSrcAud->Release();
        pSrcAud = NULL;
    }
    if ( pSrcVid )
    {
        pSrcVid->Release();
        pSrcVid = NULL;
    }
    if ( pDCColl )
    {
        pDCColl->Release();
        pDCColl = NULL;
    }
    if ( pDControl )
    {
        pDControl->Release();
        pDControl = NULL;
    }
    if ( pDCPlugin )
    {
        pDCPlugin->Release();
        pDCPlugin = NULL;
    }
    if ( pEncoder )
    {
        pEncoder->Release();
        pEncoder = NULL;
    }

Requirements

Header: wmdevctl.h

Library: wmdevctl.dll

See Also