I am a quite experiences programmer and started coding a vb media player yesterday. Its basically done apart from i cant get the player to automatically load the next song. I have done a search of this forum but none of the previous responses seem to work.
Heres the code :
Private Sub WMP_StatusChange()
If WMP.playState = wmppsMediaEnded Then
If OptOn.Value = True Then
filecount = File1.ListCount
chosenfile = Int(Rnd * filecount) + 1 'generate random index
File1.Selected(chosenfile) = True
filename = Dir1.Path & "\" & File1.filename
WMP.URL = filename
Else
fileindex = File1.ListIndex
fileindex = fileindex + 1
File1.Selected(fileindex) = True 'plays next index
filename = Dir1.Path & "\" & File1.filename
WMP.URL = filename
End If
End If
End Sub
I have tried different events as well like playstatechange but no luck. The very annoying thing is that an identical piece of code works on a button click.
if you mean a pre-determined list of songs to run through that is not what i am after. Can you see any prob with the code and any suggestion why it will work onclick but not on any media event i have tried so far.
Ok I think what you should be doing is generating a temporary playlist that you can generate from your files in the selected directory. Then assign the new temp playlist as the active list and play it.
had a play but no luck. So it is possible to put all the mp3 files in one directory into a playlist on form load. If so could you maybe post some code to get me started, if you know it that is.
How to create media player with play next song automatically
Timer1.Tick
Timer1.Start()
If Me.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsStopped Then
ListBox1.SelectedIndex = (Index Mod ListBox1.Items.Count)
Index += 1
AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
AxWindowsMediaPlayer1.Ctlcontrols.play()
End If
This is the code
Codes By Sricharan
Last edited by Siddharth Rout; Nov 24th, 2013 at 05:31 AM.
This sample media player uses msdxm.ocx (included unless moderator removed it). It uses a Play list
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
@Sricharan: Welcome to the forums. I have deleted the attachment from your post as it contained an executable file. When ever you upload attachments in vbforums, please ensure that it doesn't have an executable file in it. Also this thread is for Visual Basic 6 so your code actually is of no use
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero