我有 C# 的解决方案,你可以很容易地在 JS 中转换它。您需要使用FolderPicker
来选择您选择的位置来保存播放列表。您可以以 3 种格式保存播放列表。
Windows 媒体 (*.wpl)
祖尼 (*.zpl)
M3U (*.m3u)
请参见下面给出的代码。
var playlist = new Playlist();
//audio1 to audio4 are the object of StorageFile class
playlist.Files.Add(audio1);
playlist.Files.Add(audio2);
playlist.Files.Add(audio3);
playlist.Files.Add(audio4);
/* Initialize folder picker. Music lib is suggested start location and I've added
storage file type filters. */
FolderPicker folderPicker = new FolderPicker();
folderPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
folderPicker.FileTypeFilter.Add(".m3u");
folderPicker.FileTypeFilter.Add(".wpl");
folderPicker.FileTypeFilter.Add(".zpl");
StorageFolder folder = await folderPicker.PickSingleFolderAsync();
/* Playlist.SaveAsAsync takes four argument. First is destination folder, second is
playlist name, 3rd is file collision option and 4th is playlist format */
var file = await playlist.SaveAsAsync(folder, "myplaylist", NameCollisionOption.GenerateUniqueName, PlaylistFormat.WindowsMedia);
Playlist.SaveAsAsync 方法 - MSDN
MSDN 上的 FolderPicker 类