當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。