0

I'm basically making a audio player in vb.net, where users can upload files using openfiledialog, and then play them later on. Im wanting to gather some meta data from my uploaded songs such as the album and artist to be displayed.

I've looked around but cant seem to find anything on this problem, if anyone has any ideas it would be greatly appreciated.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button_Upload.Click
    OpenFileDialog1.InitialDirectory = "C:\"
    OpenFileDialog1.Title = "Upload A Song"
    OpenFileDialog1.Filter = "Audio Files|*.mp3; *.wav"
    OpenFileDialog1.Multiselect = False




    If OpenFileDialog1.ShowDialog = DialogResult.OK Then

        Dim Upload_Path As String = IO.Path.Combine(Application.StartupPath, "Resources")

        If IO.Directory.Exists(Upload_Path) Then

            IO.File.Copy(OpenFileDialog1.FileName, IO.Path.Combine(Upload_Path, IO.Path.GetFileName(OpenFileDialog1.FileName)))
        Else
            System.IO.Directory.CreateDirectory(Upload_Path)
            IO.File.Copy(OpenFileDialog1.FileName, IO.Path.Combine(Upload_Path, IO.Path.GetFileName(OpenFileDialog1.FileName)))
        End If


    Else
        MsgBox("Invalid Selection")
    End If

End Sub
Filburt
  • 17,626
  • 12
  • 64
  • 115
Lupe_99
  • 31
  • 1
  • 6
  • You can extract the information from the file itself, i.e. you need to get the file object. If you actually want to display this information while selecting the file to *upload*, you could check [Open File Dialog display folder in Detail view](https://social.msdn.microsoft.com/Forums/en-US/25e61992-b81b-41f3-8c11-0cb6dc62025b/open-file-dialog-display-folder-in-detail-view?forum=Vsexpressvb) – Filburt Nov 15 '18 at 12:32
  • Check this: https://stackoverflow.com/questions/6505870/how-to-get-the-properties-of-a-mp3-file-in-c-sharp – SE1986 Nov 15 '18 at 12:36
  • Side note: Why do you need to create copies of files instead of just creating a playlist containing the file path (and meta data) like any existing player does? – Filburt Nov 15 '18 at 12:36
  • 1
    Possible duplicate of [How to get the Properties of a \*.mp3 File in C#](https://stackoverflow.com/questions/6505870/how-to-get-the-properties-of-a-mp3-file-in-c-sharp) – Blackwood Nov 16 '18 at 04:45

1 Answers1

0

Check out taglib-sharp. It supports reading the information from a number of formats.

Dim tfile = TagLib.File.Create("C:\My audio.mp3");
Dim title As String = tfile.Tag.Title;
Dim duration As TimeSpan = tfile.Properties.Duration;
Console.WriteLine("Title: {0}, duration: {1}", title, duration);
viking_grll
  • 131
  • 8