- Home
·
- Sound/MP3
·
- A Tutorial for Writing to / READING FROM An ASX playlist (the ones that Windows Media Player uses)
A Tutorial for Writing to / READING FROM An ASX playlist (the ones that Windows Media Player uses)
You can use the following code to read from, and write to ASX playlists, the type that can be read and created by Windows Media Player,
and generally most other music programs. This may not be the easyest code in the world to understand, so i would recommend you have a good knowlage of string manipulation before reading this (see my other uploads)
For the following code you work correctly, YOU MUST HAVE, ON THE FORM:
2 x Listboxes, name List1 and List2
1 x Textboxes, name Text1
tHe_cLeanER
Rate A Tutorial for Writing to / READING FROM An ASX playlist (the ones that Windows Media Player uses)
(6(6 Vote))
'For the following code you work correctly, YOU MUST HAVE, ON THE FORM:
' 2 x Listboxes, name List1 and List2
' 1 x Textboxes, name Text1
'--------------------------------------------------------------------
'
'To use the code, you call it similar to calling another other Sub or Function;
'
'(anywhere in your code)
'Call WriteToASX("C:\windows\newasx.asx") ' THIS WOULD WRITE TO THE FILENAME SPECIFIED
'
'or:
'
'(anywhere in your code)
'Call PullFromASX("C:\windows\newasx.asx") ' THIS WOULD READ FROM THE ASX FILE SPECIFIED
'
'------------------------ Creating an ASX file -----------------------
Sub WriteToASX(Path As String)
On Local Error GoTo WriteError ' ERROR HANDLING
Open Path For Output As #1 ' OPEN A NEW ASX FILE FOR WRITING TO
Print #1, "" 'THE FOLLOWING CODE WRITE THE GENERAL HEADER INFO, SO THAT MEDIA PLAYER ACCEPTS IT
Print #1, ""
Print #1, "" 'SET THE FORMAT... AND CREDITS :)
Print #1, "" 'INFO ABOUT THE PLAYLIST (REQUIRED)
Print #1, ""
For i = 0 To List1.ListCount - 1 'LOOP WRITING THE FILENAMES UNTIL ALL ARE DONE
Print #1, ""
Print #1, "" 'ONLY THE NAME OF THE SONG ETC, NOT PATH OR FILENAME
Print #1, "" 'WRITES THE FULL PATH, AND FILENAME THAT ARE READ TO PLAY THE SONG
Print #1, ""
Print #1, ""
Next i
Print #1, "" ' CLOSE THE ASX FILE
Close #1 'PHYSICALLY CLOSE THE OPEN FILE
Exit Sub
WriteError: ' AN ERROR HAS OCCURED; TELL THE USER, AND SAY WHAT THE ERROR IS
MsgBox "There was an error writing to the playlist: " & Err.Description
End Sub
'---------------------------------------------------------------------
'
'This above code will write an ASX file that can be read by Windows Media Player. It uses List1 for the complete filenames for files you wish to be
'in the playlist, and reads from List2 the song names, or whatever you wish the filenames to be identified by.
'
'------------------------ Reading from a created ASX -----------------
Sub PullFromASX(Path As String)
Dim SStart, Getname As Long
Dim Part2 As Long ' DECLARE THE VARIBLES
Dim FullFilename, CosmeticName As String
On Local Error GoTo errorasx 'BASIC ERROR HANDLING
SStart = 1 'WHERE TO START LOOKING FOR THE SONG
Getname = 1 'A TEMPORY INTEGER VALUE CONTAINING THE START OF THE SONG FILENAME
Open Path For Input As #1
Text1.Text = Input(LOF(1), 1) ' OPEN THE EXISTING ASX FILE, AND EXTRACT THE CONTENTS TO TEXT1
Close #1
Do Until Getname = "0"
Getname = InStr(SStart, Text1.Text, "[
]
A Tutorial for Writing to / READING FROM An ASX playlist (the ones that Windows Media Player uses) Comments
No comments yet — be the first to post one!
Post a Comment