RATHI
RATHI

Reputation: 5299

How to read from win8 library

I want to read the filenames from the win8 music library and show them in a metro app.

Upvotes: 0

Views: 301

Answers (2)

Disco Banana
Disco Banana

Reputation: 102

  1. Change the app manifest in its "Capabilities" section to state you will be accessing the user's Music Library
  2. Change the app manifest in its "Declarations" section to state you will be using a File Picker (the old File Open dialog)

You can then use code similar to this:

var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);

Upvotes: 0

Sajid
Sajid

Reputation: 320

You can access the music library by this:

SuggestedStartLocation = PickerLocationId.MusicLibrary

You can play it in a metro app like this for example:

MediaElement snd = new MediaElement();
StorageFolder folder = await Package.Current.InstalledLocation.GetFolderAsync("Sounds");
StorageFile file = await folder.GetFileAsync("bee.wav");
var stream = await file.OpenAsync(FileAccessMode.Read);
snd.SetSource(stream, file.ContentType);
snd.Play();

You can change location, I used this location within my app

Upvotes: 2

Related Questions