Results 1 to 8 of 8

Thread: Playlist

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    70

    Question Playlist

    -I have also made a playlist to the player. But I am only able to add one file at a time... This takes very long time when you have got 500+ files!

    -Does anyone know how to browse/open an entire directory in a playlist, and/or how to browse/add all the files at once?!

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    are you using the common dialog control?

    if so, you can use multiselect in order for the user to select more than one file at the time.

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim sArr() As String
    3.     Dim i As Integer
    4.     CommonDialog1.Flags = cdlOFNAllowMultiselect + cdlOFNExplorer
    5.     CommonDialog1.ShowOpen
    6.     sArr = Split(CommonDialog1.FileName, Chr(0))
    7.     For i = 0 To UBound(sArr())
    8.         Debug.Print sArr(i)
    9.     Next i
    10. End Sub
    -= a peet post =-

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    if you want the user to be able to browse for a folder, this is how:

    VB Code:
    1. Option Explicit
    2.  
    3. Public Type BrowseInfo
    4.      hwndOwner As Long
    5.      pIDLRoot As Long
    6.      pszDisplayName As Long
    7.      lpszTitle As Long
    8.      ulFlags As Long
    9.      lpfnCallback As Long
    10.      lParam As Long
    11.      iImage As Long
    12. End Type
    13.  
    14. Public Const BIF_RETURNONLYFSDIRS = 1
    15. Public Const BIF_NEWDIALOGSTYLE = &H40
    16.  
    17. Public Const MAX_PATH = 260
    18. Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    19. Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    20. Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    21. Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    22.  
    23. Public Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String
    24.      
    25.     'declare variables to be used
    26.      Dim iNull As Integer
    27.      Dim lpIDList As Long
    28.      Dim lResult As Long
    29.      Dim sPath As String
    30.      Dim udtBI As BrowseInfo
    31.  
    32.     'initialise variables
    33.      With udtBI
    34.         .hwndOwner = hwndOwner
    35.         .lpszTitle = lstrcat(sPrompt, "")
    36.         .ulFlags = BIF_RETURNONLYFSDIRS + BIF_NEWDIALOGSTYLE
    37.      End With
    38.  
    39.     'Call the browse for folder API
    40.      lpIDList = SHBrowseForFolder(udtBI)
    41.      
    42.     'get the resulting string path
    43.      If lpIDList Then
    44.         sPath = String$(MAX_PATH, 0)
    45.         lResult = SHGetPathFromIDList(lpIDList, sPath)
    46.         Call CoTaskMemFree(lpIDList)
    47.         iNull = InStr(sPath, vbNullChar)
    48.         If iNull Then sPath = Left$(sPath, iNull - 1)
    49.      End If
    50.  
    51.     'If cancel was pressed, sPath = ""
    52.      BrowseForFolder = sPath
    53.  
    54. End Function
    55.  
    56.  
    57. 'usage :
    58. Private Sub Form_Click()
    59.     MsgBox BrowseForFolder(Me.hWnd, "select folder")
    60. End Sub

    now all you have to do is make a routine to list all the files in the
    selected folder mathcing .mp3 to the playlist
    -= a peet post =-

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    70

    Thumbs up

    -Wow! Thanks for the info peet!

    -You are the man!

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    hehe alt for en nordmann

    hvor i norge er du fra ?
    -= a peet post =-

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    70

    Wink

    -Hehe, for et sammentreff! Jeg bor i Nord-Norge på et sted som heter Saltdal. Det er 10 mil unna Bodø, hvis du vet hvor det er hen!? Du?

    -Jobber du med programmering eller? Jeg ser du har mange poster!

    -Lurte på om du kunne hjelpe meg litt til? Jeg fikk ikke helt den multi-funksjonen til å virke...

    -Slik har jeg gjort det for å få til å åpne ei fil:

    _________________________________________
    On Error Resume Next
    cd1.Filter = "Music(*.mp3;*.wav)|*.mp3;*.wav"
    cd1.ShowOpen
    If cd1.Filename = "" Then Exit Sub
    lstfavs.AddItem cd1.Filename
    _________________________________________

  7. #7
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    hehe vet hvor bodø er, aldri vært der.

    vi får fortsette på engelsk, så de andre ikke blir snurt

    This will make it possible for the user to select more than one file
    using standard procedure (Ctrl + Click or Shift + Click when selecting files.)

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim sArr() As String
    3.     Dim i As Integer
    4.    
    5.     On Error Resume Next
    6.    
    7.     cd1.Flags = cdlOFNAllowMultiselect + cdlOFNExplorer
    8.     cd1.Filter = "Music(*.mp3;*.wav)|*.mp3;*.wav"
    9.     cd1.ShowOpen
    10.     If cd1.FileName = "" Then Exit Sub
    11.     sArr = Split(cd1.FileName, Chr(0))
    12.     For i = 1 To UBound(sArr())
    13.         lstfavs.AddItem sArr(i)
    14.     Next i
    15.     cd1.FileName = ""
    16. End Sub

    -= a peet post =-

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jun 2002
    Posts
    70

    Exclamation

    -Wow! You sure know programming!

    -I hope you don`t mind I put you on my buddy list - It could be nice to know an expert!

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