本文整理汇总了C#中Microsoft.Xna.Framework.Media.MediaLibrary.SaveSong方法的典型用法代码示例。如果您正苦于以下问题:C# MediaLibrary.SaveSong方法的具体用法?C# MediaLibrary.SaveSong怎么用?C# MediaLibrary.SaveSong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Media.MediaLibrary
的用法示例。
在下文中一共展示了MediaLibrary.SaveSong方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
public async void Export()
{
TryClose();
using (var library = new MediaLibrary())
{
var existingTrackNames =
library.Songs.Where(
s => s.Album.Name == ApplicationSettings.AlbumName && s.Artist.Name == ApplicationSettings.ArtistName)
.Select(s => s.Name)
.ToList();
var trackName = ApplicationSettings.AutoGenerateUniqueTrackNames
? GetUniqueTrackName(RecordingToExport.Name, existingTrackNames)
: RecordingToExport.Name;
var metaData = new SongMetadata
{
ArtistName = ApplicationSettings.ArtistName,
AlbumName = ApplicationSettings.AlbumName,
Name = trackName
};
await CopyFileIntoIsoStore(await _streamManager.GetStorageFileAsync(RecordingToExport));
var recordingUri = new Uri(RecordingToExport.Id.ToString(), UriKind.RelativeOrAbsolute);
try
{
library.SaveSong(recordingUri, metaData, SaveSongOperation.CopyToLibrary);
}
catch (InvalidOperationException e)
{
MessageBox.Show(e.Message);
return;
}
MessageBox.Show(
String.Format("Copied this recording to the media library{3}Track: {0}{3}Album: {1}{3}Artist {2}",
trackName, ApplicationSettings.AlbumName, ApplicationSettings.ArtistName, Environment.NewLine));
}
}
示例2: Save_Click
/// <summary>
/// Save the audio file to media library.
/// </summary>
/// <param name="sender">Save menu item</param>
/// <param name="e">Event arguments</param>
private void Save_Click(object sender, EventArgs e)
{
AudioFileModel selected = (AudioFileModel)AudioFilesList.SelectedItem;
if (selected != null)
{
var library = new MediaLibrary();
Song s = library.SaveSong(
new Uri(selected.FileName, UriKind.RelativeOrAbsolute),
null,
/*
new SongMetadata()
{
ArtistName = "ArtistName",
AlbumArtistName = "AlbumArtistName",
Name = "SongName",
AlbumName = "AlbumName",
Duration = TimeSpan.FromSeconds(10),
TrackNumber = 1,
AlbumReleaseDate = DateTime.Now,
GenreName = "Genre"
},
*/
SaveSongOperation.CopyToLibrary);
}
}
示例3: SaveToMediaLibrary
public void SaveToMediaLibrary(string fileName, string artist, string name)
{
MediaLibrary ml = new MediaLibrary();
ml.SaveSong(new Uri(fileName, UriKind.Relative), new SongMetadata() { ArtistName = artist, Name = name }, SaveSongOperation.CopyToLibrary);
}