Playlist Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Fornisce l'accesso a una playlist multimediale.
public ref class Playlist sealed
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Media.Playlists.PlaylistsContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Media.Playlists.PlaylistsContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Playlist final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Media.Playlists.PlaylistsContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Media.Playlists.PlaylistsContract")]
class Playlist final
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Media.Playlists.PlaylistsContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Media.Playlists.PlaylistsContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class Playlist
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Media.Playlists.PlaylistsContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Media.Playlists.PlaylistsContract")]
public sealed class Playlist
function Playlist()
Public NotInheritable Class Playlist
- Ereditarietà
- Attributi
Requisiti Windows
Famiglia di dispositivi |
Windows Desktop Extension SDK (è stato introdotto in 10.0.10240.0)
|
API contract |
Windows.Media.Playlists.PlaylistsContract (è stato introdotto in v1.0)
|
Esempio
Questo esempio è un estratto dall'esempio Playlist. Vedere l'esempio per la soluzione completa.
// Create and save a playlist from a set of audio files.
async private void PickAudioButton_Click(object sender, RoutedEventArgs e)
{
FileOpenPicker picker = MainPage.CreateFilePicker(MainPage.audioExtensions);
IReadOnlyList<StorageFile> files = await picker.PickMultipleFilesAsync();
if (files.Count > 0)
{
Playlist playlist = new Playlist();
foreach (StorageFile file in files)
{
playlist.Files.Add(file);
}
StorageFolder folder = KnownFolders.MusicLibrary;
string name = "Sample";
NameCollisionOption collisionOption = NameCollisionOption.ReplaceExisting;
PlaylistFormat format = PlaylistFormat.WindowsMedia;
try
{
StorageFile savedFile = await playlist.SaveAsAsync(folder, name, collisionOption, format);
this.rootPage.NotifyUser(savedFile.Name + " was created and saved with " + files.Count + " files.", NotifyType.StatusMessage);
}
catch (Exception error)
{
rootPage.NotifyUser(error.Message, NotifyType.ErrorMessage);
}
}
else
{
rootPage.NotifyUser("No files picked.", NotifyType.ErrorMessage);
}
}
// Pick playlist and display its contents.
async private void PickPlaylistButton_Click(object sender, RoutedEventArgs e)
{
Playlist playlist = await PickPlaylistAsync();
if (playlist != null)
{
string result = "Songs in playlist: " + playlist.Files.Count.ToString() + "\n";
foreach (StorageFile file in playlist.Files)
{
MusicProperties properties = await file.Properties.GetMusicPropertiesAsync();
result += "\n";
result += "File: " + file.Path + "\n";
result += "Title: " + properties.Title + "\n";
result += "Album: " + properties.Album + "\n";
result += "Artist: " + properties.Artist + "\n";
}
this.OutputStatus.Text = result;
}
}
private async Task<Playlist> PickPlaylistAsync()
{
FileOpenPicker picker = CreateFilePicker(MainPage.playlistExtensions);
StorageFile file = await picker.PickSingleFileAsync();
if (file == null)
{
NotifyUser("No playlist picked.", NotifyType.ErrorMessage);
return null;
}
try
{
return await Playlist.LoadAsync(file);
}
catch (Exception ex)
{
NotifyUser(ex.Message, NotifyType.ErrorMessage);
return null;
}
}
Commenti
Questa API viene usata per salvare e caricare i file della playlist da e verso il disco. Per informazioni sulla riproduzione di elenchi di elementi multimediali, vedere Elementi multimediali, playlist e tracce.
Costruttori
Playlist() |
Crea una nuova istanza di un oggetto Playlist . |
Proprietà
Files |
Set di file multimediali che costituiscono la playlist. |
Metodi
LoadAsync(IStorageFile) |
Carica in modo asincrono i file in una playlist. |
SaveAsAsync(IStorageFolder, String, NameCollisionOption) |
Salva in modo asincrono la playlist in un file e una cartella specificati. |
SaveAsAsync(IStorageFolder, String, NameCollisionOption, PlaylistFormat) |
Salva in modo asincrono la playlist in un file e una cartella specificati, in un formato specificato. |
SaveAsync() |
Salva in modo asincrono la playlist. |