Guest User

Untitled

a guest
Jul 14th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.66 KB | None | 0 0
  1.  Public Sub LoadMusic()
  2.         Dim files As String() = IO.Directory.GetFiles("C:\Users\Public\Music\Sample Music")
  3.         For Each s As String In files
  4.             Dim mfcntl As New MusicFile
  5.             If s.EndsWith(".mp3" Or ".mp2" Or ".mp1") Then
  6.  
  7.                 Dim inf As New TID3InfoEx
  8.                 mfcntl.Dock = DockStyle.Top
  9.                 player.LoadFileID3Ex(s, TStreamFormat.sfAutodetect, inf, True)
  10.                 Try
  11.                     Dim img As Image = ResizeImage(Image.FromHbitmap(inf.Picture.Bitmap.GetHbitmap), New Size(64, 64), True)
  12.                     mfcntl.AlbumPhoto.Image = img
  13.                 Catch ex As Exception
  14.                     mfcntl.AlbumPhoto.Image = My.Resources.music
  15.                 End Try
  16.                 If inf.Artist IsNot "" Then
  17.                     mfcntl.ArtistLbl.Text = inf.Artist
  18.                 Else
  19.                     mfcntl.ArtistLbl.Text = "Unknown Artist"
  20.                 End If
  21.                 If inf.Title IsNot "" Then
  22.                     mfcntl.TrackLabel.Text = inf.Title
  23.                 Else
  24.                     mfcntl.TrackLabel.Text = FileIO.FileSystem.GetName(s)
  25.                 End If
  26.  
  27.                 mfcntl.PathLbl.Text = s
  28.                 MusicTabPanel.Controls.Add(mfcntl)
  29.  
  30.             ElseIf s.EndsWith(".ogg" Or ".oga" Or ".flac" Or ".wav" Or ".ac3" Or ".aac") Then
  31.                 mfcntl.Dock = DockStyle.Top
  32.                 mfcntl.ArtistLbl.Text = "Unknown artist"
  33.                 mfcntl.TrackLabel.Text = FileIO.FileSystem.GetName(s)
  34.                 mfcntl.PathLbl.Text = s
  35.                 MusicTabPanel.Controls.Add(mfcntl)
  36.  
  37.             End If
  38.  
  39.  
  40.         Next
  41.     End Sub
Add Comment
Please, Sign In to add comment