Getting number of chapters in DVD
This page shows you how to get the total number of chapters included in the DVD title. Please note that error handling codes are omitted to keep the sample code simple.
Sample code
The following sample code shows how to get the total number of chapters included in the DVD title. This sample code plays DVD in the DVD drive. If the DVD drive is empty, this sample will not work.
#include <stdio.h>
#include <dshow.h>
int
main()
{
IDvdGraphBuilder *pDvdGraphBuilder;
IDvdInfo2 *pDvdInfo2;
CoInitialize(NULL);
CoCreateInstance(CLSID_DvdGraphBuilder,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDvdGraphBuilder,
(LPVOID *)&pDvdGraphBuilder);
AM_DVD_RENDERSTATUS stat;
pDvdGraphBuilder->RenderDvdVideoVolume(NULL,
AM_DVD_HWDEC_PREFER, &stat);
pDvdGraphBuilder->GetDvdInterface(IID_IDvdInfo2,
(LPVOID *)&pDvdInfo2);
/*
This sample gets the number of chapters included
in the first title (title number 0).
*/
ULONG numChapters;
pDvdInfo2->GetNumberOfChapters(0, &numChapters);
printf("number of chapters in title 0 : %u\n", numChapters);
pDvdInfo2->Release();
pDvdGraphBuilder->Release();
CoUninitialize();
return 0;
}
The first argument of GetNumberOfChapters returns the total number of chapters. To use GetNumberOfChapters, you must know the total number of titles. You can get the total number of titles using GetDVDVolumeInfo.