Results 1 to 4 of 4

Thread: Audio and RTB

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Audio and RTB

    Hi

    I'm looking for a way to be able to import audio information into a rich text box.

    Whether this is by drag and drop, or by an "import" menu/ button doesn't matter.

    I'd like the name of the file to be inserted into the rich text box, along with the duration of the file. But I'd like it to be formatted like this:

    [NAME:
    DURATION: ]

    Obviously, with the correct info inserted after the colons.

    Is anyone able to advise?

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Audio and RTB

    What are you actually asking for? Do you have a method for obtaining the duration already? Where do these files come from - a directory, a playlist, a media player? It's pointless trying to advise you with such limited information to work with!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Re: Audio and RTB

    Don't have a method, but since with files like mp3s the duration is a property I imagine there is one somewhere?

    The files will be coming from a directory, eg the desktop.

    let me know if you need any more info

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Audio and RTB

    This snippet provides what you need to garner the metadata from just one file so you can see the potential problems with this. It returns a lot of information and you'll have to find a way to filter it for the specific info you want and apply that to a multi file scenario.

    vb.net Code:
    1. Sub Main()
    2.         Dim FileName As String
    3.         FileName = "C:\somefiles\somefile.mp3"
    4.         Dim Properties As Dictionary(Of Integer, KeyValuePair(Of String, String)) = GetFileProperties(FileName)
    5.         For Each FileProperty As KeyValuePair(Of Integer, KeyValuePair(Of String, String)) In Properties
    6.             ListBox1.Items.Add(FileProperty.Value.Key & ": " & FileProperty.Value.Value)
    7.         Next
    8.     End Sub
    9.  
    10.     Public Function GetFileProperties(ByVal FileName As String) As Dictionary(Of Integer, KeyValuePair(Of String, String))
    11.         Dim Shell As New Shell
    12.         Dim Folder As Folder = Shell.[NameSpace](Path.GetDirectoryName(FileName))
    13.         Dim File As FolderItem = Folder.ParseName(Path.GetFileName(FileName))
    14.         Dim Properties As New Dictionary(Of Integer, KeyValuePair(Of String, String))()
    15.         Dim Index As Integer
    16.         Dim Keys As Integer = Folder.GetDetailsOf(File, 0).Count
    17.         For Index = 0 To Keys - 1
    18.             Dim CurrentKey As String = Folder.GetDetailsOf(Nothing, Index)
    19.             Dim CurrentValue As String = Folder.GetDetailsOf(File, Index)
    20.             If CurrentValue <> "" Then
    21.                 Properties.Add(Index, New KeyValuePair(Of String, String)(CurrentKey, CurrentValue))
    22.             End If
    23.         Next
    24.         Return Properties
    25.     End Function
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width