• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

10.9. Exhibit C: playlist.asp

<%
  Function GenerateArtistPlaylist(strArtist)
  'This function creates a playlist of all the songs by a given artist and
  'returns the playtlists filename for download.

	Dim objFSO         'File system object
	Dim strPlaylist    'Playlist filename
	Dim objPlaylist    'Playlist file object
	Dim strArtistURL    'Base URL to album
	Dim objAlbum        'ALbum folder object
	Dim objSong        'Song file object

	'Create new empty playlist in temp folder
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	strPlaylist = objFSO.GetBaseName(objFSO.GetTempName) & ".m3u"
	Set objPlaylist = objFSO.CreateTextFile(TEMP_PATH & "\" & strPlayList, True)

	'Build base path to album string to avoid redundant server variable lookup
	strArtistURL = "http://" & Request.ServerVariables("SERVER_NAME") & "/" &
MEDIA_LIBRARY_URL & "/" & strArtist

	Response.Write "playing" & strArtist
	'Create playlist from all of artist's albums
	For Each objAlbum In objFSO.GetFolder(MEDIA_LIBRARY_PATH & "\" &
strArtist).Subfolders
		For Each objSong in objAlbum.Files
		  If objFSO.GetExtensionName(objSong) = "mp3" Then
			 objPlaylist.WriteLine Replace(strArtistURL & "/" & objAlbum.Name & "/"
& objSong.Name, " ", "%20")
		  End If
		Next
	Next

	'Return playlist filename
	GenerateArtistPlaylist = "http://" & Request.ServerVariables("SERVER_NAME")
& "/" & TEMP_URL & "/" & strPlaylist

	'Clean up
	objPlaylist.Close
	Set objPlaylist = Nothing
	Set objFSO = Nothing

	End Function

Function GenerateAlbumPlaylist(strArtist, strAlbum)
'This function creates a playlist from all the audio files in an album
'folder and returns the name of the playlist for download

	Dim objFSO         'File system object
	Dim strPlaylist     'Playlist filename
	Dim objPlaylist     'Playlist file object
	Dim strAlbumURL        'Base URL to album
	Dim objAlbum       'ALbum folder object
	Dim objSong      'Song file object

	'Create new empty playlist in temp folder
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	strPlaylist = objFSO.GetBaseName(objFSO.GetTempName) & ".m3u"
	Set objPlaylist = objFSO.CreateTextFile(TEMP_PATH & "\" & strPlayList, True)

	'Build base path to album string to avoid redundant server variable lookup
	strAlbumURL = "http://" & Request.ServerVariables("SERVER_NAME") & "/" &
MEDIA_LIBRARY_URL & "/" & strArtist & "/" & strAlbum

	'Create playlist from complete album
	Set objAlbum = objFSO.GetFolder(MEDIA_LIBRARY_PATH & "\" & strArtist &
"\" & strAlbum)
	For Each objSong in objAlbum.Files
	  If objFSO.GetExtensionName(objSong) = "mp3" Then
		 objPlaylist.WriteLine Replace(strAlbumURL & "/" & objSong.Name, " ",
 "%20")
	  End If
	Next

	'Return playlist filename
	GenerateAlbumPlaylist = "http://" & Request.ServerVariables("SERVER_NAME")
& "/" & TEMP_URL & "/" & strPlaylist

	'Clean up
	objPlaylist.Close
	Set objPlaylist = Nothing
	Set objFSO = Nothing
  End Function

  Function GenerateSongPlaylist(strArtist, strAlbum, strSongFilespec)
  'This function takes a single song file and adds it to a playlist. Then it returns
  'the playlist filename for download

	Dim objFSO         'file system object
	Dim strPlaylist   'playlist filename
	Dim objPlaylist   'playlist file object
	Dim strAlbumURL     'Base URL to album

	'Create new empty playlist in temp folder
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	strPlaylist = objFSO.GetBaseName(objFSO.GetTempName) & ".m3u"
	Set objPlaylist = objFSO.CreateTextFile(TEMP_PATH & "\" & strPlayList, True)

	'Build base path to album string to avoid redundant server variable lookup
	strAlbumURL = "http://" & Request.ServerVariables("SERVER_NAME") & "/" &
MEDIA_LIBRARY_URL & "/" & strArtist & "/" & strAlbum

	'Create playlist for single song

	objPlaylist.WriteLine Replace(strAlbumURL & "/" & strSongFilespec, " ", "%20")

	'Return playlist filename
	GenerateSongPlaylist = "http://" & Request.ServerVariables("SERVER_NAME")
& "/" & TEMP_URL & "/" & strPlaylist

	'Clean up
	objPlaylist.Close
	Set objPlaylist = Nothing
	Set objFSO = Nothing
  End Function

  Function GenerateSelectionPlaylist(strArtist, strAlbum, arrSongFilespecs)
  'This function takes a selection of song files and adds it to a playlist. Then it 
returns
  'the playlist filename for download

	Dim objFSO             'file system object
	Dim strPlaylist       'playlist filename
	Dim objPlaylist       'playlist file object
	Dim strAlbumURL         'Base URL to album

	'Create new empty playlist in temp folder
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	strPlaylist = objFSO.GetBaseName(objFSO.GetTempName) & ".m3u"
	Set objPlaylist = objFSO.CreateTextFile(TEMP_PATH & "\" & strPlayList, True)

	'Build base path to album string to avoid redundant server variable lookup
	strAlbumURL = "http://" & Request.ServerVariables("SERVER_NAME") & "/" &
MEDIA_LIBRARY_URL & "/" & strArtist & "/" & strAlbum

	'Create playlist from selected songs
	For Each objFile in arrSongFilespecs
	If objFSO.GetExtensionName(objFile) = "mp3" Then
	   objPlaylist.WriteLine Replace(strAlbumURL & "/" & objFile.Name, " ",
"%20")
	  End If
	Next

	'Return playlist filename
	GenerateSongPlaylist = objPlaylist.Size

	'Clean up
	objPlaylist.Close
	Set objPlaylist = Nothing
	Set objFSO = Nothing
  End Function
%>


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint