Cách tạo Playlist trên Windows 10

Liên hệ QC

ndu96081631

Huyền thoại GPE
Thành viên BQT
Super Moderator
Tham gia
5/6/08
Bài viết
30,703
Được thích
53,924
Chào các bạn!
Các bạn ai đang dùng Windows 10, có ai biết cách tạo playlist (để chơi các files mp3) không?
Hỏi vậy là vì tôi thấy chương trình chơi nhạc trên Windows 10 là Groove Music không có chức năng tạo Playlist từ một folder, vậy chúng ta phải làm sao?
 
Chào các bạn!
Các bạn ai đang dùng Windows 10, có ai biết cách tạo playlist (để chơi các files mp3) không?
Hỏi vậy là vì tôi thấy chương trình chơi nhạc trên Windows 10 là Groove Music không có chức năng tạo Playlist từ một folder, vậy chúng ta phải làm sao?
Trên Windows 10 vẫn có Windows Media Player mà anh.
 
Em thấy ngay trên màn hình đầu tiên là có tạo playlist rồi mà anh:

1577374102875.png
 
Khác phiên bản chăng?

Sau khi tạo tên playlist,
bấm goto albums để thêm bài hát vào nè
1577384394403.png

Chọn và cho vào playlist,
1577384437768.png
 
Chắc là phải chọn Folder để phần mềm tìm kiếm nhạc, sau đó tạo Playlist, rồi mới thêm nhạc vào Playlist được.
Và không có chức năng tạo danh mục Folder

Music on this PC
Choose where we look for music

--------------------
Capture.JPG
 
Trên Windows 10 vẫn có Windows Media Player mà anh.
Windows Media tôi biết. Vấn đề là tôi dùng Groove Music và nó không có chức năng tạo Playlist từ folder nên hơi khó chịu
Mấu chốt ở chỗ này.
Tôi dùng Groove Music khá lâu rồi (từ ngày mới ra Windows 10) và tôi biết chỗ này không ăn thua. Vì nếu ta chỉ đến thư mục chứa nhiều thư mục con (nhiều thể loại nhạc) thì ta sẽ nhận được một đống hằm bà lằng các thể loại trong mục My Music
Tóm lại: tôi muốn chia ra từng playlist riêng link đến từng folder
---------------------------------------------------------------------
Nhờ gợi ý về WMP của bạn mà tôi có cách này:
1> Tạo playlist trên WMP
2> Save playlist
3> Dùng playlist đó để chơi trên Groove Music
Hơi lằng nhằng nhưng còn hơn là phải cài app thứ ba
 
Windows Media tôi biết. Vấn đề là tôi dùng Groove Music và nó không có chức năng tạo Playlist từ folder nên hơi khó chịu

Tôi dùng Groove Music khá lâu rồi (từ ngày mới ra Windows 10) và tôi biết chỗ này không ăn thua. Vì nếu ta chỉ đến thư mục chứa nhiều thư mục con (nhiều thể loại nhạc) thì ta sẽ nhận được một đống hằm bà lằng các thể loại trong mục My Music
Tóm lại: tôi muốn chia ra từng playlist riêng link đến từng folder
---------------------------------------------------------------------
Nhờ gợi ý về WMP của bạn mà tôi có cách này:
1> Tạo playlist trên WMP
2> Save playlist
3> Dùng playlist đó để chơi trên Groove Music
Hơi lằng nhằng nhưng còn hơn là phải cài app thứ ba
Sau người không dùng VBA tạo Playlist

Chọn thư mục trong Groove Music
Sau đó tạo một file .wpl hoặc .zpl với mã xml lưu vào Thư mục Playlists trong thư mục kia
 
Sau người không dùng VBA tạo Playlist

Chọn thư mục trong Groove Music
Sau đó tạo một file .wpl hoặc .zpl với mã xml lưu vào Thư mục Playlists trong thư mục kia
Chính xác là tôi đang có ý này. Để rảnh sẽ viết thử xem
 
Lỡ tay viết vội cái Macro tạo playlist để thực hiện với Rainmeter, nên chia sẽ luôn ở đây, để mọi người sử dụng và chỉnh sửa
( Vẫn chưa Debug hết các lỗi có thể)

Macro Gồm 8 tham số:

Paths - Đường dẫn (Chuỗi hoặc mảng)
ParentFolder - Tên folder chính để tạo một Playlist có chủ đề chính.
(Nếu Folder con không tên chỉ là các số thì nên thêm ParentFolder là đường dẫn chính)
FSO - Đối tượng FSO (có hoặc không)
Playlists - Trả lại mảng các tên Playlist đã tạo
IncludeSubfolders - Bao gồm các Folder chứa bên trong Folder
Types - cách nhận dạng đuôi file (Ví dụ: "*.mp3" hoặc "*.mp3, *.wav" )
NameTypes - Cách nhận dạng chung đuôi file (Ví dụ: "Mp3 File" (có thể nhận biết ở mục Type trong Explorer))
PlaylistPath - Nơi lưu các file playlist đã tạo.

--------------------
JavaScript:
Private Sub PlaylistWPL_test()
  Dim Path As String, PlaylistPath As String
  Path = "D:\Sounds\"
  PlaylistPath = VBA.Environ("USERPROFILE") & "\Music\Playlist\Sounds\"
  Call PlaylistWPL(Path, Path, , Playlists, 1, "*.mp3", PlaylistPath:=PlaylistPath)
End Sub
Private Sub PlaylistWPL(ByVal Paths, _
               Optional ByVal ParentFolder As String, _
               Optional ByRef FSO As Object, _
               Optional ByRef Playlists As Variant, _
               Optional ByVal IncludeSubfolders As Boolean = False, _
               Optional ByVal Types = "*.*", _
               Optional ByVal NameTypes = "", _
               Optional ByVal PlaylistPath As String = "")
  '----------------------------------
  Call CreateFolder(PlaylistPath)
  Dim title$
  Dim author$
  Dim totalDuration&
  Dim Subtitle$
  Dim ContentPartnerName$
  Dim ContentPartnerNameType$
  Dim ContentPartnerListID$
  Dim IsFavorite$
  Dim ItemCount&
  Dim Generator$
  '----------------------------------
  If VBA.TypeName(Paths) = "String" Then Paths = Array(Paths)
  Dim I&, J&, k&, T$, T2$
  Dim aTypes(), Arr(), dArr()
  Dim SF, Folder
  Dim Item As Object 'Scripting.File
  Dim oFolder As Object 'Scripting.Folder
  I = -1
  If VBA.TypeName(NameTypes) = "String" Then
    If NameTypes <> vbNullString Then ReDim aTypes(0): aTypes(0) = VBA.LCase(NameTypes)
  Else
    ReDim aTypes(UBound(NameTypes))
    For I = LBound(Playlists) To UBound(Playlists): Arr(I) = VBA.LCase(NameTypes(I)): Next I
  End If
  If VBA.TypeName(Types) = "String" Then
    ReDim aTypes(I + 1)
    aTypes(I + 1) = "*" & VBA.LCase(Types)
  Else
    ReDim aTypes(UBound(Types) + VBA.IIf(I = -1, 0, I))
    For k = LBound(Types) To UBound(Types): aTypes(k + VBA.IIf(I = -1, 0, I)) = "*" & VBA.LCase(Types(k)): Next k
  End If
  If FSO Is Nothing Then Set FSO = VBA.CreateObject("Scripting.FileSystemObject")
  I = 0
  If VBA.IsArray(Playlists) Then
    ReDim Arr(1 To UBound(Playlists) - LBound(Playlists) + 1)
    For I = LBound(Playlists) To UBound(Playlists) - LBound(Playlists) + 1: Arr(I) = Playlists(I): Next I
    I = I - 1
  End If
  k = 0
  '-----------------------------
  Dim Tmp$, tTime$, PlaylistFile$, medias$
  Dim ItemName, Attr$, NodeValue$, src$, albumTitle$, albumArtist$, trackTitle$, trackArtist$
  Dim duration&, S$, Elem, NewElem
  Dim Shl As Object, ShellFolder As Object
  Set Shl = VBA.CreateObject("Shell.Application")
  '-----------------------------
  For Each Folder In Paths
    If FSO.FolderExists(Folder) Then
      Set oFolder = FSO.GetFolder(Folder)
      title = VBA.Replace(VBA.Replace(Folder, ParentFolder, ""), "\", " ~ ")
      If Not title Like "*" & oFolder.Name Then
        title = title & oFolder.Name
      End If
      title = VBA.Right(title, 250)
      I = I + 1: ReDim Preserve Arr(1 To I): Arr(I) = title
      ItemCount = 0: totalDuration = 0: Tmp = VBA.vbNullString: medias = VBA.vbNullString
      For Each Item In oFolder.Files
        T = vbNullString: T = VBA.LCase(Item.Name)
        T2 = vbNullString: T2 = VBA.LCase(Item.Type)
        For Each SF In aTypes
          If VBA.Left(T, 1) <> "~" And (T Like SF Or T2 = SF) Then
            Set ShellFolder = Shl.Namespace(CVar(VBA.Replace(Item.Path, Item.Name, "")))
            Set ItemName = ShellFolder.ParseName(Item.Name)
            tTime = ShellFolder.GetDetailsOf(ItemName, 27)
            If tTime <> "" Then
              src = Item.Path
              albumTitle = ShellFolder.GetDetailsOf(ItemName, 14)
              albumArtist = ShellFolder.GetDetailsOf(ItemName, 204)
              trackTitle = ShellFolder.GetDetailsOf(ItemName, 21)
              trackArtist = ShellFolder.GetDetailsOf(ItemName, 13)
              duration = VBA.CDec(VBA.Left(tTime, 2)) * 3600 + VBA.CDec(VBA.MID(tTime, 4, 2)) * 60 + VBA.CDec(VBA.Right(tTime, 2))
              totalDuration = VBA.CDec(duration) + totalDuration
              ItemCount = ItemCount + 1
              GoSub AddSong
            End If
            Exit For
          End If
          DoEvents
        Next SF
      Next Item
      '-----------------------------------
      If ItemCount > 0 Then GoSub Save
      '-----------------------------------
      If IncludeSubfolders Then
        For Each SF In oFolder.SubFolders
          k = k + 1: ReDim Preserve dArr(1 To k): dArr(k) = SF.Path
        Next SF
      End If
      '-----------------------------
    End If
  Next Folder
  '-----------------------------
  If I > 0 Then Playlists = Arr
  If IncludeSubfolders And k > 0 Then
    PlaylistWPL dArr, ParentFolder, FSO, Playlists, True, Types, NameTypes, PlaylistPath
  End If
Exit Sub:
AddSong:
  medias = medias & VBA.IIf(medias = "", "", VBA.Chr(10)) & "<media src=""" & src & """" & _
         " albumTitle=""" & albumTitle & """" & _
         " albumArtist=""" & albumArtist & """" & _
         " trackTitle=""" & trackTitle & """" & _
         " trackArtist=""" & trackArtist & """" & _
         " duration=""" & duration & """ />"
Return
'---------------------------------------
Save:
  S = "<?wpl version=""1.0"" encoding=""utf-8"" ?>"
  S = S & "<smil>"
  S = S & "  <head>"
  S = S & "    <author content=""" & author & """ />"
  S = S & "    <guid>{CFF37028-F641-4708-ABB4-D63E359ABC70}</guid>"
  S = S & "    <meta name=""totalDuration"" content=""" & totalDuration & """ />"
  S = S & "    <meta name=""Subtitle"" content=""" & Subtitle & """ />"
  S = S & "    <meta name=""ContentPartnerName"" content=""" & ContentPartnerName & """ />"
  S = S & "    <meta name=""ContentPartnerNameType"" content=""" & ContentPartnerNameType & """ />"
  S = S & "    <meta name=""ContentPartnerListID"" content=""" & ContentPartnerListID & """ />"
  S = S & "    <meta name=""IsFavorite"" content=""" & IsFavorite & """ />"
  S = S & "    <meta name=""ItemCount"" content=""" & ItemCount & """ />"
  S = S & "    <meta name=""Generator"" content=""Entertainment Platform -- 10.18111.1731.0"" />"
  S = S & "    <title>" & title & "</title>"
  S = S & "  </head>"
  S = S & "  <body><seq>" & medias
  S = S & VBA.Chr(10) & "   </seq>     "
  S = S & VBA.Chr(10) & "   </body>   "
  S = S & VBA.Chr(10) & "</smil>   "
  Dim objDom As Object
  Set objDom = VBA.CreateObject("MSXML2.DOMDocument")
  objDom.LoadXML (S)
  objDom.Save (PlaylistPath & title & ".wpl")
  Set objDom = Nothing
Return
End Sub
Function CreateFolder(ByVal FolderPath$) As Boolean
  Dim FolderArray, Tmp$, Item, tFolder$
  tFolder = FolderPath
  If VBA.Right(tFolder, 1) = "\" Then tFolder = VBA.Left(tFolder, VBA.Len(tFolder) - 1)
  If tFolder Like "\\*\*" Then tFolder = VBA.Strings.Replace(tFolder, "\", "@", 1, 3)
  FolderArray = VBA.Split(tFolder, "\")
  FolderArray(0) = VBA.Strings.Replace(FolderArray(0), "@", "\", 1, 3)
  On Error GoTo Ends
  With VBA.CreateObject("Scripting.FileSystemObject")
    For Each Item In FolderArray
      Tmp = Tmp & Item & "\"
      If Not .FolderExists(Tmp) Then .CreateFolder (Tmp)
    Next
  End With
  CreateFolder = True
Ends:
End Function
 
Lần chỉnh sửa cuối:
Lỡ tay viết vội cái Macro tạo playlist để thực hiện với Rainmeter, nên chia sẽ luôn ở đây, để mọi người sử dụng và chỉnh sửa
( Vẫn chưa Debug hết các lỗi có thể)

Macro Gồm 8 tham số:

Paths - Đường dẫn (Chuỗi hoặc mảng)
ParentFolder - Tên folder chính để tạo một Playlist có chủ đề chính.
(Nếu Folder con không tên chỉ là các số thì nên thêm ParentFolder là đường dẫn chính)
FSO - Đối tượng FSO (có hoặc không)
Playlists - Trả lại mảng các tên Playlist đã tạo
IncludeSubfolders - Bao gồm các Folder chứa bên trong Folder
Types - cách nhận dạng đuôi file (Ví dụ: "*.mp3" hoặc "*.mp3, *.wav" )
NameTypes - Cách nhận dạng chung đuôi file (Ví dụ: "Mp3 File" (có thể nhận biết ở mục Type trong Explorer))
PlaylistPath - Nơi lưu các file playlist đã tạo.

--------------------
JavaScript:
Private Sub PlaylistWPL_test()
  Dim Path As String, PlaylistPath As String
  Path = "D:\Sounds\"
  PlaylistPath = VBA.Environ("USERPROFILE") & "\Music\Playlist\Sounds\"
  Call PlaylistWPL(Path, Path, , Playlists, 1, "*.mp3", PlaylistPath:=PlaylistPath)
End Sub
Private Sub PlaylistWPL(ByVal Paths, _
               Optional ByVal ParentFolder As String, _
               Optional ByRef FSO As Object, _
               Optional ByRef Playlists As Variant, _
               Optional ByVal IncludeSubfolders As Boolean = False, _
               Optional ByVal Types = "*.*", _
               Optional ByVal NameTypes = "", _
               Optional ByVal PlaylistPath As String = "")
  ''----------------------------------
  Call CreateFolder(PlaylistPath)
  Dim title$
  Dim author$
  Dim totalDuration&
  Dim Subtitle$
  Dim ContentPartnerName$
  Dim ContentPartnerNameType$
  Dim ContentPartnerListID$
  Dim IsFavorite$
  Dim ItemCount&
  Dim Generator$
  Dim objDom As Object
  Dim objMemberElem As Object
  Dim objMemberRel As Object
  ''----------------------------------
  If VBA.TypeName(Paths) = "String" Then Paths = Array(Paths)
  Dim I&, J&, k&, T$, T2$
  Dim aTypes(), Arr(), dArr()
  Dim SF, Item As Object, Folder, oFolder As Object
  I = -1
  If VBA.TypeName(NameTypes) = "String" Then
    If NameTypes <> vbNullString Then ReDim aTypes(0): aTypes(0) = VBA.LCase(NameTypes)
  Else
    ReDim aTypes(UBound(NameTypes))
    For I = LBound(Playlists) To UBound(Playlists): Arr(I) = VBA.LCase(NameTypes(I)): Next I
  End If
  If VBA.TypeName(Types) = "String" Then
    ReDim aTypes(I + 1)
    aTypes(I + 1) = "*" & VBA.LCase(Types)
  Else
    ReDim aTypes(UBound(Types) + VBA.IIf(I = -1, 0, I))
    For k = LBound(Types) To UBound(Types): aTypes(k + VBA.IIf(I = -1, 0, I)) = "*" & VBA.LCase(Types(k)): Next k
  End If
  If FSO Is Nothing Then Set FSO = VBA.CreateObject("Scripting.FileSystemObject")
  I = 0
  If VBA.IsArray(Playlists) Then
    ReDim Arr(1 To UBound(Playlists) - LBound(Playlists) + 1)
    For I = LBound(Playlists) To UBound(Playlists) - LBound(Playlists) + 1: Arr(I) = Playlists(I): Next I
    I = I - 1
  End If
  k = 0
  Dim Tmp$, tTime$, PlaylistFile$
  Dim Attr$, NodeValue$, src$, albumTitle$, albumArtist$, trackTitle$, trackArtist$
  Dim duration&, S$, Elem, NewElem
  Dim ItemName, Shl As Object, ShellFolder As Object
  Set Shl = VBA.CreateObject("Shell.Application")
  For Each Folder In Paths
    If FSO.FolderExists(Folder) Then
      Set oFolder = FSO.GetFolder(Folder)
      title = VBA.Replace(VBA.Replace(Folder, ParentFolder, ""), "\", " ~ ")
      If Not title Like "*" & oFolder.Name Then
        title = title & oFolder.Name
      End If
      title = VBA.Right(title, 250): GoSub SetTitle
      I = I + 1: ReDim Preserve Arr(1 To I): Arr(I) = title
      ItemCount = 0: Tmp = VBA.vbNullString
      totalDuration = 0
      For Each Item In oFolder.Files
        T = vbNullString: T = VBA.LCase(Item.Name)
        T2 = vbNullString: T2 = VBA.LCase(Item.Type)
        For Each SF In aTypes
          If VBA.Left(T, 1) <> "~" And (T Like SF Or T2 = SF) Then
            Set ShellFolder = Shl.Namespace(CVar(VBA.Replace(Item.Path, Item.Name, "")))
            Set ItemName = ShellFolder.ParseName(Item.Name)
            tTime = ShellFolder.GetDetailsOf(ItemName, 27)
            If tTime <> "" Then
              src = Item.Path
              albumTitle = ShellFolder.GetDetailsOf(ItemName, 17)
              albumArtist = ShellFolder.GetDetailsOf(ItemName, 16)
              trackTitle = ShellFolder.GetDetailsOf(ItemName, 10)
              trackArtist = ShellFolder.GetDetailsOf(ItemName, 16)
              duration = VBA.CDec(VBA.Left(tTime, 2)) * 3600 + VBA.CDec(VBA.MID(tTime, 4, 2)) * 60 + VBA.CDec(VBA.Right(tTime, 2))
              totalDuration = VBA.CDec(duration) + totalDuration
              ItemCount = ItemCount + 1
              GoSub AddSong
            End If
            Exit For
          End If
          DoEvents
        Next SF
      Next Item
      ''-----------------------------------
      If ItemCount > 0 Then GoSub PlaylistInfo: GoSub Save
      ''-----------------------------------
      If IncludeSubfolders Then
        For Each SF In oFolder.SubFolders
          k = k + 1: ReDim Preserve dArr(1 To k): dArr(k) = SF.Path
        Next SF
      End If
    End If
  Next Folder
  If I > 0 Then Playlists = Arr
  If IncludeSubfolders And k > 0 Then
    PlaylistWPL dArr, ParentFolder, FSO, Playlists, True, Types, NameTypes, PlaylistPath
  End If
Exit Sub:
Save: objDom.Save (PlaylistPath & title & ".wpl"): Return
AddSong:
  ''-------------------------------------------------
  '' New media ------------------------------------------
  Set NewElem = objDom.createElement("media")
  Elem.appendChild NewElem
  Attr = "src": NodeValue = src: GoSub Attr
  Attr = "albumTitle": NodeValue = albumTitle: GoSub Attr
  Attr = "albumArtist": NodeValue = albumArtist: GoSub Attr
  Attr = "trackTitle": NodeValue = trackTitle: GoSub Attr
  Attr = "trackArtist": NodeValue = trackArtist: GoSub Attr
  Attr = "duration": NodeValue = duration: GoSub Attr
  ''---------------------------------------
Return
PlaylistInfo:
  Dim meta
  Set meta = objDom.getElementsByTagName("head")(0)
  Set meta = meta.getElementsByTagName("meta")
totalDuration: meta(0).Attributes.getNamedItem("content").Text = totalDuration
Subtitle: meta(1).Attributes.getNamedItem("content").Text = Subtitle
ContentPartnerName: meta(2).Attributes.getNamedItem("content").Text = ContentPartnerName
ContentPartnerNameType: meta(3).Attributes.getNamedItem("content").Text = ContentPartnerNameType
ContentPartnerListID: meta(4).Attributes.getNamedItem("content").Text = ContentPartnerListID
IsFavorite: meta(5).Attributes.getNamedItem("content").Text = IsFavorite
ItemCount: meta(6).Attributes.getNamedItem("content").Text = ItemCount
Generator: meta(7).Attributes.getNamedItem("content").Text = Generator
''---------------------------------------
Return
SetTitle:
  S =  "<?wpl version=""1.0"" encoding=""utf-8"" ?>"
  S = S & "<smil>"
  S = S & "  <head>"
  S = S & "    <author content="""" />"
  S = S & "    <guid>{CFF37028-F641-4708-ABB4-D63E359ABC70}</guid>"
  S = S & "    <meta name=""totalDuration"" content="""" />"
  S = S & "    <meta name=""Subtitle"" content="""" />"
  S = S & "    <meta name=""ContentPartnerName"" content="""" />"
  S = S & "    <meta name=""ContentPartnerNameType"" content="""" />"
  S = S & "    <meta name=""ContentPartnerListID"" content="""" />"
  S = S & "    <meta name=""IsFavorite"" content="""" />"
  S = S & "    <meta name=""ItemCount"" content="""" />"
  S = S & "    <meta name=""Generator"" content=""Entertainment Platform -- 10.18111.1731.0"" />"
  S = S & "    <title>" & title & "</title>"
  S = S & "  </head>"
  S = S & "  <body>"
  S = S & "     <seq>"
  S = S & "     </seq>" & vbNewLine
  S = S & "  </body>" & vbNewLine
  S = S & "</smil>"
  Set objDom = VBA.CreateObject("MSXML2.DOMDocument")
  objDom.LoadXML (S)
  Set Elem = objDom.getElementsByTagName("body")(0)
  Set Elem = Elem.getElementsByTagName("seq")(0)
Return
Attr:
  Set objMemberRel = objDom.createAttribute(Attr)
  objMemberRel.NodeValue = NodeValue
  NewElem.setAttributeNode objMemberRel
Return
End Sub
Function CreateFolder(ByVal FolderPath$) As Boolean
  Dim FolderArray, Tmp$, Item, tFolder$
  tFolder = FolderPath
  If VBA.Right(tFolder, 1) = "\" Then tFolder = VBA.Left(tFolder, VBA.Len(tFolder) - 1)
  If tFolder Like "\\*\*" Then tFolder = VBA.Strings.Replace(tFolder, "\", "@", 1, 3)
  FolderArray = VBA.Split(tFolder, "\")
  FolderArray(0) = VBA.Strings.Replace(FolderArray(0), "@", "\", 1, 3)
  On Error GoTo Ends
  With VBA.CreateObject("Scripting.FileSystemObject")
    For Each Item In FolderArray
      Tmp = Tmp & Item & "\"
      If Not .FolderExists(Tmp) Then .CreateFolder (Tmp)
    Next
  End With
  CreateFolder = True
Ends:
End Function
Cái này:
Mã:
VBA.Environ("USERPROFILE") & "\Music\Playlist\Sounds\"
Chưa chắc chính xác khi thư mục Music bị người dùng dời đi chỗ khác
Ngoài ra tui còn vướng chỗ: làm sao chọn nhiều thư mục để có thể tạo nhiều playlists cùng lúc?
 
Chưa chắc chính xác khi thư mục Music bị người dùng dời đi chỗ khác
----------------------

Thủ tục CreateFolder sẽ thực hiện tạo thư mục dù cho thư mục đó không tồn tại


----------------------
Ngoài ra tui còn vướng chỗ: làm sao chọn nhiều thư mục để có thể tạo nhiều playlists cùng lúc?
----------------------

Mặc dù không hiểu lắm ý này, nhưng Thầy làm thế này xem:

Dim Paths As Variant
Paths = Array("\path1", "\path2")
Call PlaylistWPL(Paths, , , , 1, "*.mp3", PlaylistPath:=PlaylistPath)

Hoặc dùng Dialog để Browser Folder đưa vào mảng.
 
----------------------

Thủ tục CreateFolder sẽ thực hiện tạo thư mục dù cho thư mục đó không tồn tại


----------------------

----------------------

Mặc dù không hiểu lắm ý này, nhưng Thầy làm thế này xem:

Dim Paths As Variant
Paths = Array("\path1", "\path2")
Call PlaylistWPL(Paths, , , , 1, "*.mp3", PlaylistPath:=PlaylistPath)

Hoặc dùng Dialog để Browser Folder đưa vào mảng.
1> Tôi đang nói đến thư mục Music chứ không phải thư mục do bạn tạo ra. Nó phải là Music của hệ thống thì mới có tác dụng với Groove Music
2> Ý tôi là tôi dùng Application.FileDialog và không biết cách nào để chọn từ 2 thư mục trở lên cùng lúc
 
1> Tôi đang nói đến thư mục Music chứ không phải thư mục do bạn tạo ra. Nó phải là Music của hệ thống thì mới có tác dụng với Groove Music
----------------

Nếu ta đã vào Groove thêm thư mục tìm kiếm: Choose where we look for music
là "D:\Sounds\" thì thư mục Playlist của nó sẽ là "D:\Sounds\Playlists"

Hoặc ta có thể thêm trực tiếp D:\Sounds\Playlists cho Groove tự động tìm kiếm Playlist.

----------------
2> Ý tôi là tôi dùng Application.FileDialog và không biết cách nào để chọn từ 2 thư mục trở lên cùng lúc
----------------

Chắc là phải tạo Form sử dụng TreeView Folder
 
----------------

Nếu ta đã vào Groove thêm thư mục tìm kiếm: Choose where we look for music
là "D:\Sounds\" thì thư mục Playlist của nó sẽ là "D:\Sounds\Playlists"

Hoặc ta có thể thêm trực tiếp D:\Sounds\Playlists cho Groove tự động tìm kiếm Playlist.

----------------

----------------

Chắc là phải tạo Form sử dụng TreeView Folder
Để thuận tiện cho người dùng giúp họ không cần phải làm gì cả, tui viết code tìm folder music thế này:
Mã:
Private Const MY_MUSIC As String = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music"

Private Function GetMyMusicPath() As String
  Dim sTmp      As String
  Dim oWsh      As Object
  Set oWsh = CreateObject("Wscript.Shell")
  
  On Error Resume Next
  sTmp = oWsh.RegRead(MY_MUSIC)
  On Error GoTo 0
  GetMyMusicPath = sTmp
  Set oWsh = Nothing
End Function
Cho dù folder Music có bị người dùng dời đi nơi khác thì code cũng tìm được
 
Để thuận tiện cho người dùng giúp họ không cần phải làm gì cả, tui viết code tìm folder music thế này:
Mã:
Private Const MY_MUSIC As String = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music"

Private Function GetMyMusicPath() As String
  Dim sTmp      As String
  Dim oWsh      As Object
  Set oWsh = CreateObject("Wscript.Shell")
 
  On Error Resume Next
  sTmp = oWsh.RegRead(MY_MUSIC)
  On Error GoTo 0
  GetMyMusicPath = sTmp
  Set oWsh = Nothing
End Function
Cho dù folder Music có bị người dùng dời đi nơi khác thì code cũng tìm được
Anh thử cái này xem sao ... hên thì trúng trật bỏ qua
Mã:
MsgBox CreateObject("Shell.Application").Namespace(13).Self.Path
Còn API hình như nó là vầy đại ý thế :D:p
Mã:
CSIDL_COMMON_MUSIC = 0x0035,
 
Web KT
Back
Top Bottom