Export (0) Print
Expand All

Windows Media Player 11 SDK About Folder Monitoring 

Windows Media Player SDK banner art
PreviousNext

About Folder Monitoring

Windows Media Player can monitor folders that contain digital media files and update the library when files are added or removed. This folder monitoring functionality is provided by the IWMPFolderMonitorServices interface.

To use the folder monitoring services, you must create the Player object in a remote state. For more information about remoting, see Remoting the Windows Media Player Control. After you have created a remoted instance of the player, obtain a pointer to the IWMPFolderMonitorServices interface by calling QueryInterface on the IWMPPlayer interface.

Windows Media Player keeps a list of folders that are being monitored. To get a list of monitored folders, use the IWMPFolderMonitorServices::get_count and IWMPFolderMonitorServices::item methods. To add folders to the list or remove them from the list, use the IWMPFolderMonitorServices::add and remove methods, respectively.

Starting a Scan

Monitoring of folders is normally a background process that does not need to be called explicitly. If you want to actively scan a folder, call IWMPFolderMonitorServices::startScan. You can stop a scan in progress with the IWMPFolderMonitorServices::stopScan method.

Retrieving the Folder Monitoring Status

IWMPFolderMonitorServices provides functionality for retrieving the status of the folder monitoring process.

Folder scanning is done in two passes. In the first pass, the Player scans the folders named in the monitored folders list one by one and builds a list of files to be added to the library. In the second pass, it goes through the list of files and adds the files to the library, and also removes any media items from the library whose corresponding physical files have been deleted from the file system.

The FolderScanStateChange event is used to notify your program whenever the Player switches to a new state. You can also retrieve the current state by calling get_scanState. When the first pass starts, the current state value is wmpfssScanning. During the second pass, the state switches to wmpfssUpdating. After the process is finished, the state changes to wmpfssStopped.

While the Player is scanning the monitored folders on the first pass, call get_scannedFilesCount to check how many files have been scanned. The get_currentFolder method will tell you which folder is currently being scanned.

After the second pass starts, call get_addedFilesCount to check how many files have been added to the library. The get_updateProgress method will tell you the progress of the second pass, as a percentage from 0 to 100.

See Also

PreviousNext
Show:
© 2014 Microsoft