Compartir a través de


Changing Discs (Windows Embedded CE 6.0)

1/6/2010

A general purpose DVD player application should be able to stop playing the current disc and allow the user to begin playing a new one.

To handle this scenario your application could continually destroy and recreate all the different DVD-Video API objects and interfaces to reset the internal information for the interfaces, but this is not necessary. Each interface has methods that you can call to reset their internal data.

To allow the user to change a disc, your player application should verify that the navigation manager is in the stopped state by calling IDVDUserOperation::Stop before the application unbinds the current disc. This assures that the navigation manager has valid data to manipulate.

Your application should call IDVDROM::Unbind to release the memory allocated for the old disc and then call IDVDROM::Bind to set the path for the new disc. After the path is set, call IDVDNavigationManager::SetVolume. This connects the navigation manager to its new data source. The navigation manager authenticates the disc during this process.

After IDVDNavigationManager::SetVolume returns, call IDVDVideoVolume::InitData to load the navigation data from the disc. This provides the IDVDVideoVolume interface with new pointers to all the VMGI and VTSI information on the disc.

Whenever you want to provide the navigation manager with a new disc or data source, stop the player and then call IDVDNavigationManager::SetVolume followed by IDVDVideoVolume::InitData for the new disc.

The following list summarizes the steps:

  1. Call IDVDUserOperation::Stop to stop the navigation manager.
  2. Call IDVDROM::Unbind to release the old disc.
  3. Call IDVDROM::Bind to set the path for the new disc.
  4. Call IDVDNavigationManager::SetVolume to connect the navigation manager to its new data source and authenticate the disc.
  5. Call IDVDVideoVolume::InitData to load the navigation data from the new disc.

The following code demonstrates how you can successively bind and unbind a disc. You must provide your own implementation for the function CheckHRESULT to maintain the security and stability of your application.

HRESULT ExampleFunction(void)
{
  HRESULT hr;

  CComPtr<IDVDNavigationManager> piDVDNavigationManager;
  hr = piDVDNavigationManager.CoCreateInstance(
                                CLSID_DVDNavigationManager);
  CheckHRESULT(hr);

  CComPtr<IDVDROM> piDVDROM;
  hr = piDVDROM.CoCreateInstance(CLSID_DVDData);
  CheckHRESULT(hr);

  CComPtr<IDVDVideoVolume> pidDVDVideoVolume;
  hr = piDVDROM.QueryInterface(&pidDVDVideoVolume);
  CheckHRESULT(hr);

  for(int i = 0; i < 10; i++)
  {
    hr = piDVDROM->Bind(TEXT("\\CDROM Drive"));
    CheckHRESULT(hr);

    hr = piDVDNavigationManager->SetVolume(pidDVDVideoVolume);
    CheckHRESULT(hr);

    hr = pidDVDVideoVolume->InitData(piDVDROM);
    CheckHRESULT(hr);

    // play the disc here

    // stop playback here

    hr = piDVDROM->Unbind();
    CheckHRESULT(hr);
  }
  return S_OK;
}

See Also

Concepts

Adding More Player Capabilities
Using the DVD-Video API
DVD-Video API Objects