Как получить/скачать обложку альбома из интернета для проекта music player
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 :)
Что я уже пробовал:
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
Richard MacCutchan
Вам нужно использовать свой отладчик, чтобы понять, почему загрузка завершается неудачно.
Member 14205173
окей. но есть ли что-то неправильное в моем коде или все хорошо? и спасибо.
Richard MacCutchan
Откуда нам знать? Вы-единственный человек, который может это проверить.