Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello i'm making Music player with clean look and great design and i'm about to finish it but i want to add a cool smart feature is when there is an internet connection and there isn't album cover in the mp3 file ('The song) then the program should download and get the cover by name of the mp3 file and if there is cover in the mp3 file use it (i already done that). all i wan't knew is to knew what i done wrong in this code. The problem is Msgbox appearing and says error in downloading song cover BUT why. Is there is something wrong in my code? and thanks for you time and helping me :)


What I have tried:

If My.Computer.Network.IsAvailable Then

       Label13.Text = Label5.Text
       Dim Clint As New WebClient()
       Dim photolink As String = Nothing

       Application.DoEvents()
       Dim sourceCollection As String = Clint.DownloadString(New Uri("https://www.amazon.com/s?k=" + Label13.Text + "&i=digital-music&ref=nb_sb_noss"))
       Dim Weber As New WebBrowser With {.ScriptErrorsSuppressed = True}
       Weber.DocumentText = sourceCollection
       Dim htmlColl As HtmlDocument = Weber.Document.OpenNew(True)
       htmlColl.Write(sourceCollection)
       If htmlColl.GetElementById("mp3StoreShovelerCell0") IsNot Nothing Then
           Dim theHtmlElementCollection As HtmlElementCollection = htmlColl.GetElementById("mp3StoreShovelerCell0").GetElementsByTagName("img")
           For Each curElement As HtmlElement In theHtmlElementCollection
               photolink = curElement.GetAttribute("src")
           Next
           If photolink IsNot Nothing Then
               photolink = photolink.ToString.Replace("._SL500_SS110_.jpg", "._SS500_.jpg")
               BunifuImageButton2.ImageLocation = photolink



           End If
       Else
           BunifuImageButton2.Image = My.Resources.clipart536736

           MsgBox("Error in Downloading Song Cover")

       End If

   Else
       Dim file As TagLib.File = TagLib.File.Create(AxWindowsMediaPlayer1.URL.ToString())
       If (file.Tag.Pictures.Length > 0) Then
           Dim bin = CType(file.Tag.Pictures(0).Data.Data, Byte())
           BunifuImageButton2.Image = Image.FromStream(New MemoryStream(bin)).GetThumbnailImage(600, 600, Nothing, IntPtr.Zero)

           BunifuImageButton7.Image = Image.FromStream(New MemoryStream(bin)).GetThumbnailImage(600, 600, Nothing, IntPtr.Zero)
       Else
           BunifuImageButton7.Image = My.Resources.clipart536736

       End If
   End If
   BunifuImageButton7.Image = BunifuImageButton2.Image
   ''end of code cover
Posted
Comments
Richard MacCutchan 31-Mar-19 3:41am    
You need to use your debugger to see why the download is failing.
Member 14205173 3-Apr-19 10:36am    
okay. but is there is something wrong in my code or everything is good? and thanks.
Richard MacCutchan 3-Apr-19 10:49am    
How can we know? You are the only person who can test it.

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