The Game DVR feature allows titles to capture audio and video during game play and save them to the local system or the cloud. The feature also provides a way to play back videos in games.
To use Game DVR features, add the following lines to the beginning of your program:
using namespace Windows::Xbox::Media::Capture;
using namespace Windows::Foundation;
The ApplicationClipCapture class includes the methods games call to record a clip. There are two options - games can call RecordTimespanAsync to record a specific time interval, or they can call StartRecordAsync and StopRecordAsync to indicate when to begin and end recording.
The ApplicationClipCapture class saves the clip on the local file system. In this release, the path is d:\ApplicationClips.
The following example shows how to use RecordTimespanAsync to record a clip.
// Find a signed in user
User^ user;
for( UINT32 iUser = 0; iUser < User::Users->Size; iUser++ )
{
user = User::Users->GetAt(iUser);
if( user->IsSignedIn && !user->IsGuest )
break;
}
// Get current date/time to set up the start and stop times
DateTime start;
DateTime end;
::GetSystemTimeAsFileTime(reinterpret_cast<FILETIME*>(&start));
// Record next 1 minute
end.UniversalTime = start.UniversalTime + 60L * 10000000L;
// Create the capture object
ApplicationClipCapture^ applicationClipCapture = ref new ApplicationClipCapture();
// Provide information about this recording
ApplicationClipInfo^ info = ref new ApplicationClipInfo(L"myClipNameStringId");
// This starts recording at current time and stops the recording after 1 minute
auto recordOp = applicationClipCapture->RecordTimespanAsync(currentUser, info, start, end);
recordOp->Completed = ref new AsyncOperationWithProgressCompletedHandler< ApplicationClip^,
ApplicationClip^ >( [ this, user ] ( IAsyncOperationWithProgress< ApplicationClip^,
ApplicationClip^ >^ operation, Windows::Foundation::AsyncStatus status )
{
If (status != Windows::Foundation::AsyncStatus::Completed)
{
// Exit on error
return;
}
ApplicationClip^ clip = operation->GetResults();
DebugTrace(L"Completed - found %s\n", clip->LocalId->Data());
});
The ApplicationClipQuery class includes methods for looking up clips associated with the current user, title and sandbox.
The following example shows how to use find a clip.
ApplicationClipQuery^applicationClipQuery = ref new ApplicationClipQuery();
auto queryOp = applicationClipQuery->GetClipsAsync(currentUser);
queryOp->Completed = ref new AsyncOperationCompletedHandler<IVectorView<ApplicationClip^>^>(
[this] (IAsyncOperation<IVectorView<ApplicationClip^>^>^ operation,
Windows::Foundation::AsyncStatus status)
{
if (status != Windows::Foundation::AsyncStatus::Completed)
{
// Show error
return;
}
IVectorView<ApplicationClip^>^ clips = operation->GetResults();
for (unsigned int i = 0; i < clips->Size; i++)
{
ApplicationClip^ clip = clips->GetAt(i);
IVectorView<ApplicationClipLocation^>^ locations = clip->Locations;
for (unsigned int j = 0; j < locations->Size; j++)
{
auto uri = locations->GetAt(j)->Uri;
// Do something with uri
}
}
});