Music Bundle Sample
A sample application that uses the Packaging APIs to produce and consume a custom-format package, called a music bundle.
This topic contains the following sections.
Description
This sample demonstrates how to use the Packaging APIs to produce and consume a custom-format package, called a music bundle.
The sample demonstrates the following features of the Packaging APIs:
- Creating a new, empty package that will be a music bundle.
- Adding parts and relationships to the music bundle.
- Saving the music bundle.
- Loading the music bundle.
- Accessing music bundle parts and relationships.
Requirements
Product | Version |
---|---|
Microsoft Windows Software Development Kit (SDK) | Windows 7 |
ATL | .NET Framework |
Downloading the Sample
This sample is available in the following locations:
Location | Path/URL |
---|---|
Windows SDK | \Program Files\Microsoft SDKs\Windows\v7.0\Samples\dataaccess\OPC |
Code Gallery | Download from MSDN Code Gallery |
Building the Sample
The following procedure describes how to build the sample.
Install the Microsoft Windows Software Development Kit (SDK).
Register the Windows SDK.
Follow steps for building, using Visual Studio 2008 or the command prompt.
Using Visual Studio 2008:
- Open Windows Explorer.
- Navigate to the directory that contains the MusicBundle.sln file.
- Double-click the MusicBundle.sln file to open it with Visual Studio 2008.
- Go to the Build menu in Visual Studio 2008 and select Build Solution.
Note
If the sample does not build successfully, close Visual Studio 2008 and run the .NET Framework Configuration Tool (Mscorcfg.msc) before attempting to build the sample.
Using the command prompt:
- Open the command prompt.
- Navigate to the directory that contains the MusicBundle.vcproj file.
- Enter the following command: msbuild MusicBundle.vcproj.
Either the Debug or Release build mode may be used.
Running the Sample
Before running the sample application, ensure that the sample project has been built in the Debug or Release mode that corresponds to the build mode that will be used to run the sample.
The following procedures describe how to run the sample using Visual Studio or the command prompt.
- Using Visual Studio 2008:
- Open the Properties of the sample project.
- Under Configuration Properties, click the Debugging item.
- Type either of the following two sets of arguments into the Command Arguments text box and then click OK.
- To create and save the music bundle when the sample program runs, type: MusicBundle.exe -p <Input Directory><Output Package Path>.
- The <Input Directory> is the full path of the ProductionData directory provided with the sample.
The <Output Package Path> is the full path and name of the package to be created. - To load and unpack the music bundle when the sample program runs, type: MusicBundle.exe -c <Input Package Path><Output Directory>.
- <Input Package Path> is the full path to the \ConsumptionData\SampleMusicBundle.zip music bundle that is provided with the sample.
<Output Directory> is the full path to the directory where the music bundle will be unpacked.
- To create and save the music bundle when the sample program runs, type: MusicBundle.exe -p <Input Directory><Output Package Path>.
- Run the sample.
- Open the command prompt.
- Navigate to the directory that contains either the \Debug or the \Release project directory, as determined by the mode used to build and run the sample.
- Run the sample by entering either of the following commands.
- To create and save the music bundle when the sample program runs, enter: MusicBundle.exe -p <Input Directory><Output Package Path>.
- The <Input Directory> is the full path of the ProductionData directory provided with the sample.
The <Output Package Path> is the full path and name of the package to be created. - To load and unpack the music bundle when the sample program runs, enter: MusicBundle.exe -c <Input Package Path><Output Directory>.
- <Input Package Path> is the full path to the \ConsumptionData\SampleMusicBundle.zip music bundle that is provided with the sample.
<Output Directory> is the full path to the directory where the music bundle will be unpacked.
- To create and save the music bundle when the sample program runs, enter: MusicBundle.exe -p <Input Directory><Output Package Path>.
Sample Files
File | Description |
---|---|
musicbundle.sln | Visual Studio 2008 solution file. |
musicbundle.vcproj | Visual Studio 2008 project file. |
[musicbundle.h](musicbundle-h.md) | Main header file declaring two production and consumption functions. Also contains a description of the custom OPC file format used in the sample. |
[musicbundle.cpp](musicbundle-cpp.md) | Entry point for the sample. |
[MusicBundleProduction.cpp](./musicbundleproduction-cpp.md) | Definition of the production function declared in musicbundle.h and production helper functions. |
[MusicBundleConsumption.cpp](./musicbundleconsumption-cpp.md) | Definition of the consumption function declared in musicbundle.h and consumption helper functions. |
[util.h](musicbundle-util-h.md) | Declarations for helper utility functions for using OPC, COM, and managing resources. |
[util.cpp](musicbundle-util-cpp.md) | Definitions for helper utility functions for using OPC, COM, and managing resources. |
ConsumptionData\SampleMusicBundle.zip | A package containing sample music files that can be consumed using the sample application.
[!Note] |
ProductionData\* | Files used to produce the sample's music bundle OPC package, in the directory structure needed by the sample. |