Hi ,
Im trying to change the music properties but it doenst change. sometimes only title or sometime only artist updates in properties but mostly it doenst change.
have a look on this code :
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
var file = e.NavigationParameter as Windows.Storage.StorageFile;
selectedFile = file;
FillTable();
}
private void FillTable() {
SetProperties();
}
private async void SetProperties(){
property = await selectedFile.Properties.GetMusicPropertiesAsync();
txtAlbum.Text = property.Album;
txtAlbumArtist.Text = property.AlbumArtist;
txtArtist.Text = property.Artist;
txtPublisher.Text = property.Publisher;
txtRating.Text = property.Rating.ToString();
txtSubtitle.Text = property.Subtitle;
txtTitle.Text = property.Title;
txtTrackNumber.Text = property.TrackNumber.ToString();
txtYears.Text = property.Year.ToString();
lblBitRate.Text = property.Bitrate.ToString();
lblComposer.Text = string.Join(" , ", property.Composers.ToArray());
lblConductors.Text = string.Join(" , ", property.Conductors.ToArray());
lblDuration.Text = property.Duration.Minutes.ToString() + ":" + property.Duration.Seconds.ToString();
lblGenre.Text = string.Join(" , ", property.Genre.ToArray());
lblMediaTitle.Text = selectedFile.Name;
txtFileName.Text = selectedFile.Name;
lblFileType.Text = selectedFile.FileType;
lblProducers.Text = string.Join(" , ", property.Producers.ToArray());
lblWriters.Text = string.Join(" , ", property.Writers.ToArray());
}
Now following is the code for updateing the music properties. Sample audio file is mp3 format
private void btnSave_Click(object sender, RoutedEventArgs e)
{
property.Album = txtAlbum.Text;
property.AlbumArtist = txtAlbumArtist.Text;
property.Artist = txtArtist.Text;
property.Publisher = txtPublisher.Text;
property.Rating = uint.Parse(txtRating.Text);
property.Subtitle = txtSubtitle.Text;
property.Title = txtTitle.Text;
property.TrackNumber = uint.Parse(txtTrackNumber.Text);
property.Year = uint.Parse(txtYears.Text);
SaveProperties(property,txtFileName.Text);
Frame.Navigate(typeof(MainPage));
}
private async void SaveProperties(Windows.Storage.FileProperties.MusicProperties prop , string Name) {
await selectedFile.Properties.SavePropertiesAsync().AsTask().ContinueWith((t)=>selectedFile.RenameAsync(Name));;
}