Hello all,
I have a question I have a list view in eg and there are songs in it now I want when I click on a button that he plays all the music in succession but I can't get that done can someone send me an example?
Thank you
Hello all,
I have a question I have a list view in eg and there are songs in it now I want when I click on a button that he plays all the music in succession but I can't get that done can someone send me an example?
Thank you
For : the simplest, reliable WinForms approach is to use the Windows Media Player ActiveX control (AxWindowsMediaPlayer). It supports MP3 and can build a playlist from your ListView so a single button press plays every item in order. As noted, there are other libraries and examples online, but the built-in WMP control avoids extra dependencies and works well for basic "play all" behavior.
' Assumes: AxWindowsMediaPlayer named axPlayer, ListView named lvSongs,
' and each ListViewItem.Tag contains the full file path.
Private Sub btnPlayAll_Click(sender As Object, e As EventArgs) Handles btnPlayAll.Click
If lvSongs.Items.Count = 0 Then Return
Dim pl As WMPLib.IWMPPlaylist = axPlayer.playlistCollection.newPlaylist("allSongs")
For Each it As ListViewItem In lvSongs.Items
Dim path = TryCast(it.Tag, String)
If Not String.IsNullOrEmpty(path) AndAlso IO.File.Exists(path) Then
pl.appendItem(axPlayer.newMedia(path))
End If
Next
axPlayer.currentPlaylist = pl
axPlayer.Ctlcontrols.play()
End Sub Notes and troubleshooting: add the Windows Media Player control from the toolbox (this adds AxWMPLib/WMPLib references). Ensure ListView items store full, accessible file paths (use the Tag property). If you prefer not to use a playlist, set axPlayer.URL = path and handle axPlayer.PlayStateChange (media-ended state) to advance an index. Expect WAV-only behavior if using System.Media.SoundPlayer (it does not play MP3). Check file access and installed codecs if a file does not play.
I have doubt that the c tag is correct here. But for visual basic the code will likely change as you change which of the dozen versions of visual basic are out now. OK, a MP3 player in VB.net? Let's find a few: https://www.google.com/search?client=daniweb&q=mp3+player+in+vb.net
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.