IMFPMediaItem::SetStartStopPosition method (mfplay.h)
Sets the start and stop time for the media item.
Syntax
HRESULT SetStartStopPosition(
[in] const GUID *pguidStartPositionType,
[in] const PROPVARIANT *pvStartValue,
[in] const GUID *pguidStopPositionType,
[in] const PROPVARIANT *pvStopValue
);
Parameters
[in] pguidStartPositionType
Unit of time for the start position. See Remarks. This parameter can be NULL.
[in] pvStartValue
Start position. The meaning and data type of this parameter are indicated by the pguidStartPositionType parameter. The pvStartValue parameter must be NULL if pguidStartPositionType is NULL, and cannot be NULL otherwise.
[in] pguidStopPositionType
Unit of time for the stop position. See Remarks. This parameter can be NULL.
[in] pvStopValue
Stop position. The meaning and data type of this parameter are indicated by the pguidStopPositionType parameter. The pvStopValue parameter must be NULL if pguidStopPositionType is NULL, and cannot be NULL otherwise.
Return value
The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.
Return code | Description |
---|---|
|
The method succeeded. |
|
Invalid argument. |
|
Invalid start or stop time. Any of the following can cause this error:
|
Remarks
By default, a media item plays from the beginning to the end of the file. This method adjusts the start time and/or the stop time:
- To set the start time, pass non-NULL values for pguidStartPositionType and pvStartValue.
- To set the stop time, pass non-NULL values for pguidStopPositionType and pvStopValue.
Value | Description |
---|---|
MFP_POSITIONTYPE_100NS | 100-nanosecond units. The time parameter (pvStartValue or pvStopValue) uses the following data type:
|
The adjusted start and stop times are used the next time that IMFPMediaPlayer::SetMediaItem is called with this media item. If the media item is already set on the player, the change does not happen unless you call SetMediaItem again.
Examples
HRESULT PlayMediaClip(
IMFPMediaPlayer *pPlayer,
PCWSTR pszURL,
LONGLONG hnsStart,
LONGLONG hnsEnd
)
{
IMFPMediaItem *pItem = NULL;
PROPVARIANT varStart, varEnd;
ULONGLONG hnsDuration = 0;
HRESULT hr = pPlayer->CreateMediaItemFromURL(pszURL, TRUE, 0, &pItem);
if (FAILED(hr))
{
goto done;
}
hr = GetPlaybackDuration(pItem, &hnsDuration);
if (FAILED(hr))
{
goto done;
}
if ((ULONGLONG)hnsEnd > hnsDuration)
{
hnsEnd = hnsDuration;
}
hr = InitPropVariantFromInt64(hnsStart, &varStart);
if (FAILED(hr))
{
goto done;
}
hr = InitPropVariantFromInt64(hnsEnd, &varEnd);
if (FAILED(hr))
{
goto done;
}
hr = pItem->SetStartStopPosition(
&MFP_POSITIONTYPE_100NS,
&varStart,
&MFP_POSITIONTYPE_100NS,
&varEnd
);
if (FAILED(hr))
{
goto done;
}
hr = pPlayer->SetMediaItem(pItem);
done:
SafeRelease(&pItem);
return hr;
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7 [desktop apps only] |
Minimum supported server | Windows Server 2008 R2 [desktop apps only] |
Target Platform | Windows |
Header | mfplay.h |
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for