MusicProperties Class

Definition

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

public ref class MusicProperties sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class MusicProperties final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class MusicProperties
Public NotInheritable Class MusicProperties
Inheritance
Object Platform::Object IInspectable MusicProperties
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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.

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.

Properties

Album

Gets or sets the name of the album that contains the song.

AlbumArtist

Gets or sets the name of the album artist of the song.

Artist

Gets the artists that contributed to the song.

Bitrate

Gets the bit rate of the song file.

Composers

Gets the composers of the song.

Conductors

Gets the conductors of the song.

Duration

Gets the duration of the song in milliseconds.

Genre

Gets the names of music genres that the song belongs to.

Producers

Gets the producers of the song.

Publisher

Gets or sets the publisher of the song.

Rating

Gets or sets the rating associated with a music file.

Subtitle

Gets or sets the subtitle of the song.

Title

Gets or sets the title of the song

TrackNumber

Gets or sets the track number of the song on the song's album.

Writers

Gets the songwriters.

Year

Gets or sets the year that the song was released.

Methods

RetrievePropertiesAsync(IIterable<String>)

Retrieves the specified music-related Windows file properties associated with the item.

SavePropertiesAsync()

Saves all properties associated with the item.

SavePropertiesAsync(IIterable<KeyValuePair<String,Object>>)

Saves the specified properties and values associated with the item.

Applies to

See also