Play a track on Selection from Media player on Userform

arjunat

New Member
Joined
Apr 17, 2021
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
Hi, I have created a Media player on a userform in the following way.
Using a MP3 Filelister procedure ( available on the web), I populate a sheet with all the details from a music folder containing the tracks. Then I open a userform that creates a playlist for WMP, by looping through the column containing the individual paths of the tracks and when done, plays them. I also created a Listbox that lists the tracks (using a named range formula).
Since the Playlist always starts from the beginning, I would like to be able to "Double Click" on a track and have WMP play from that location on.
Is there a way to get the playlist reordered, so that all track above selected track are removed from playlist? thereby my selection becomes the first song of said Playlist?
code for playing selection;

Private Sub cmdPlay_Click()
Dim Text1 As String
Dim NewFile As Variant
Dim Playlist As IWMPPlaylist

Set Playlist = WindowsMediaPlayer1.newPlaylist("MyNewPlayList", "")
Range("J2").Select
WindowsMediaPlayer1.playlistCollection.getByName ("MyNewPlaylist")
WindowsMediaPlayer1.currentPlaylist.Clear
Do While Not IsEmpty(ActiveCell)
Text1 = ActiveCell.Value
'NewFile = WindowsMediaPlayer1.newMedia(Text1)
Set NewFile = WindowsMediaPlayer1.mediaCollection.Add(Text1)
WindowsMediaPlayer1.currentPlaylist.insertItem (WindowsMediaPlayer1.currentPlaylist.Count), NewFile
Selection.Offset(1, 0).Select
Loop
'the playlist is created, play it
WindowsMediaPlayer1.Controls.Play
End Sub
 

Attachments

  • Capture.JPG
    Capture.JPG
    126.2 KB · Views: 78

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top