Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 :


C#
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            var file = e.NavigationParameter as Windows.Storage.StorageFile;
            selectedFile = file;
            FillTable();
        }
        private void FillTable() {
            //property = selectedFile.Properties.GetMusicPropertiesAsync().AsTask().Result;
            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

C#
private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            //property = await selectedFile.Properties.GetMusicPropertiesAsync();
            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 property.SavePropertiesAsync().AsTask().ContinueWith((t)=>selectedFile.RenameAsync(Name));
            await selectedFile.Properties.SavePropertiesAsync().AsTask().ContinueWith((t)=>selectedFile.RenameAsync(Name));;
               //await selectedFile.RenameAsync(txtFileName.Text);
        }
Posted
Updated 4-Jun-14 23:24pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900