Results 1 to 14 of 14

Thread: [RESOLVED] how to play random mp3 files in a folder via VB6

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2013
    Posts
    9

    Resolved [RESOLVED] how to play random mp3 files in a folder via VB6

    Hello

    Suppose I have an app with Command Button ( Command1)

    and I have a folder have a lot of songs for example , (Audio)

    I want a code when I click on command the songs in folder (Audio) play random ( shuffle )

    i tried to make a random play list in windows media player and run it via VB6 using this code , but every time it opens , no shuffle

    Code:
    WindowsMediaPlayer1.settings.mute = False
    WindowsMediaPlayer1.URL = App.Path & "\songs.wpl"
    all what I need is playing random play list in VB

    Thanks

  2. #2
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: how to play random mp3 files in a folder via VB6

    Code:
    Private Sub Command1_Click()
    WindowsMediaPlayer1.URL = App.Path & "\tst.wpl"
    WindowsMediaPlayer1.settings.setMode "shuffle", True
    End Sub
    Or
    Code:
    Private Sub Form_Load()
    WindowsMediaPlayer1.settings.mute = False
    WindowsMediaPlayer1.URL = App.Path & "\tst.wpl"
    WindowsMediaPlayer1.settings.setMode "shuffle", True
    End Sub
    Last edited by Rattled_Cage; Sep 21st, 2013 at 04:23 PM. Reason: mistakes . . .

  3. #3
    Lively Member
    Join Date
    Sep 2013
    Posts
    127

    Re: how to play random mp3 files in a folder via VB6

    That's assuming you're wanting to use the WindowsMediaPlayer's playlist, but if you want to make your own, here's some Randomize code:

    Randomize
    Dice = Int(6 * Rnd + 1) '6 being the maximum number to maximize to




    Want a random number between two numbers? Here that is, too:

    Randomize
    RandomNumber = Int((1000 - 100 + 1) * Rnd) + 100 'Max=1000, Min=100

  4. #4
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: how to play random mp3 files in a folder via VB6

    You can shuffle like this
    1- Add File1 control, set Pattern property to *.mp3 and Path to your folder
    2- Create random number x range from 0 to File1.ListCount - 1
    3- Pass the file at File1.ListItem(x) to WindowsMediaPlayer1
    4- Wait until WindowsMediaPlayer1 finish playing the current file then repeat steps 2, 3 and 4.



  5. #5
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: how to play random mp3 files in a folder via VB6

    Checkout the MP3 Player I made. Here is the Windows Media Player version.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2013
    Posts
    9

    Re: how to play random mp3 files in a folder via VB6

    Quote Originally Posted by Rattled_Cage View Post
    Code:
    Private Sub Command1_Click()
    WindowsMediaPlayer1.URL = App.Path & "\tst.wpl"
    WindowsMediaPlayer1.settings.setMode "shuffle", True
    End Sub
    Or
    Code:
    Private Sub Form_Load()
    WindowsMediaPlayer1.settings.mute = False
    WindowsMediaPlayer1.URL = App.Path & "\tst.wpl"
    WindowsMediaPlayer1.settings.setMode "shuffle", True
    End Sub

    Thanks so much ,, that's what I need

    It works well

    Thank You

  7. #7

    Thread Starter
    New Member
    Join Date
    Aug 2013
    Posts
    9

    Re: [RESOLVED] how to play random mp3 files in a folder via VB6

    Many Thanks for every one

  8. #8
    Member
    Join Date
    Jan 2011
    Posts
    61

    Re: [RESOLVED] how to play random mp3 files in a folder via VB6

    I'm also haveing similar issues with my shuffle function. I have tried the method that Rattled_Cage showed however its not workin with mine (the same function works as loop with repeat function but isn't working with shuffle). I am using WMP version 9. will this make a difference or is there a different way with version 9? I have tried many different methods all have failed. (also the EndOfStream event never occurs either)

  9. #9
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: [RESOLVED] how to play random mp3 files in a folder via VB6

    Future_FireFighter
    this might help in some way !
    set the folder to your mp3 in the code and create a play list
    Attached Files Attached Files
    Last edited by Rattled_Cage; Oct 17th, 2013 at 08:03 AM. Reason: tags

  10. #10
    Member
    Join Date
    Jan 2011
    Posts
    61

    Re: [RESOLVED] how to play random mp3 files in a folder via VB6

    After I unzipped this file. it wouldn't open in vb. no form to open. Not sure what the deal is here?

  11. #11
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: [RESOLVED] how to play random mp3 files in a folder via VB6

    Quote Originally Posted by Future_FireFighter View Post
    After I unzipped this file. it wouldn't open in vb. no form to open. Not sure what the deal is here?
    That is because Rattled_Cage forgot to include the form, etc in the zip file, you can't do much with just a vbw and a vbp file.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  12. #12
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: [RESOLVED] how to play random mp3 files in a folder via VB6

    Quote Originally Posted by Nightwalker83 View Post
    That is because Rattled_Cage forgot to include the form, etc in the zip file, you can't do much with just a vbw and a vbp file.
    whoops !

    Fixed
    Attached Files Attached Files

  13. #13
    Member
    Join Date
    Jan 2011
    Posts
    61

    Re: [RESOLVED] how to play random mp3 files in a folder via VB6

    thanx bro.

  14. #14
    Member
    Join Date
    Jan 2011
    Posts
    61

    Re: [RESOLVED] how to play random mp3 files in a folder via VB6

    yea the code
    Code:
    WindowsMediaPlayer1.settings.setMode "shuffle", True
    doesn't seem to work with wmp9.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width