当前位置: 首页>>代码示例>>C#>>正文


C# MediaLibrary.SaveSong方法代码示例

本文整理汇总了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));
            }
        }
开发者ID:pmacn,项目名称:VoiceRecorder.WP8,代码行数:38,代码来源:ExportRecordingViewModel.cs

示例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);
     }
 }
开发者ID:hutchgard,项目名称:audio-recorder,代码行数:30,代码来源:AudioFilePage.xaml.cs

示例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);
 }
开发者ID:ktos,项目名称:sayanything,代码行数:5,代码来源:Microphone.cs


注:本文中的Microsoft.Xna.Framework.Media.MediaLibrary.SaveSong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。