I was trying to code a simple word quizz application for my students, with 20 years old and extremely rusty coding knowledge. But the more I coded, the more stuff I aspired to add my application. In the end, I found myself trying to list mp3 files for pronounciation purposes and trying to use WMPLib to let them listen to some educational songs. This was not intended but once you start, it's hard to refrain.
So I am having a series of problems with this process.
1- I am trying to populate a combobox with the mp3 files. My problem is, combobox also sees the albumart, folder.art or any kind of embedded or hidden files that are actually not in that folder. If there is an mp3 file with an embedded album art, that is also added to the combobox as an item, naturally not only results in an ugly list but also crashes the player unless I put a handler.
2- The method I used might be amateur, or plainly wrong. But I couldn't imagine how to show the player the file from a combobox, because I used getfilenames method to prevent long and ugly names in the combobox list. So I used an arraylist and matched the indexes of the combobox with the arrarlist indexes. So I keep the directory path in the array list, pick the mp3 file from the combobox then compare the indexes and get the path from the arraylist item with the same index. Yeah I can hear you, it sounds dumb but also was the only method I could really consider. If there is a more elegant way, please let me know.
Can anyone help me to get an idea about these?
Thanks in advance
Public Class frmPlayer
Dim list As ArrayList
Dim Player As WindowsMediaPlayer = New WindowsMediaPlayer
Private Sub FrmPlayer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim cb As ComboBox = New ComboBox
list = New ArrayList
For Each s As String In System.IO.Directory.GetFiles(Application.StartupPath & "\music\")
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Player = New WindowsMediaPlayer
If Player.playState = WMPPlayState.wmppsPlaying Then
Player.URL = Player.currentMedia.name
Player.URL = list.Item(ComboBox1.SelectedIndex)
What I have tried:
I tried linq method to pick only mp3 files but it got things much more complicated as I am using both an arraylist and a combobox.