Windows.Storage.FileProperties.MusicProperties

December 9, 2020 ยท View on GitHub

-description

Provides access to the music-related properties of an item (like a file or folder).

-remarks

You can access a MusicProperties object asynchronously using the GetMusicPropertiesAsync method from the Properties property of an item (like a file of folder), or synchronously using the MusicProperties property if it is available. You can get a musicProperties object using any of the following methods and properties:

Note

Properties that are get or set using a property handler that is defined by another app (like Microsoft Word) may not be accessible. Instead, you can try to get these properties using a file query that is backed by the system index. For more information, see QueryOptions.

For more code samples about accessing properties, see the File access sample.

-examples

This example demonstrates how to retrieve properties of a file, including music properties like Album and Rating.


try
{
    StorageFile file = rootPage.sampleFile;
    if (file != null)
    {
        StringBuilder outputText = new StringBuilder();

        // Get music properties
        MusicProperties musicProperties = await file.Properties.GetMusicPropertiesAsync();
        outputText.AppendLine("Album: " + musicProperties.Album);
        outputText.AppendLine("Rating: " + musicProperties.Rating);
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
 // For example, handle a file not found error
}

After GetMusicPropertiesAsync completes, musicProperties gets a MusicProperties object.

In the example, file contains a StorageFile that represents the file to retrieve properties for.

-see-also

StorageItemContentProperties.getMusicPropertiesAsync method, Windows.Storage.BulkAccess.fileInformation.musicProperties property, Windows.Storage.BulkAccess.folderInformation.musicProperties property, Windows.Storage.BulkAccess.IStorageItemInformation.MusicProperties property