My ASP code create a M3U file with the session.sessionID as part of the name
I then created a Button to open that file
But When I click on the Playlist button Windows Media Play says it can not open the file
When I go to the folder and double click on the file it plays no problem
I believe the session.sessionID might be changing before the playlist button try's to retrieve it.
My code is as follows:
<%if request.form<>"" thendim fs,fnameset fs=Server.CreateObject("Scripting.FileSystemObject")set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)strSongs=request.form("selectItem")arraySongs=split(strSongs,",")response.write "<ul>"for each song in arraySongs response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" fname.WriteLine "<a href=""" &server.URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a>" nextresponse.write "</ul>" fname.Closeelseresponse.write "You did not post any data yet<br>"end ifset fname=nothingset fs=nothing%><input type="button" value="BACK!"onClick="history.back();"><button value="Playlist" onclick="window.location = '<%="/Playlist/myplaylist_"&Session.SessionID&".m3u"%>'"> Playlist </button>
Try and create a new button using an actual value saved.
If your domain is mydomain.com, does the file exist in mydomain.com/playlist/myplaylist_1234.m3u? In other words, what happens if you place that full url in the browser?
I wonder if your files are not located inside of your domain?
Since this is an ASP area, what is your intention to do with this play list once generated? Play it through the website? Play it locally? Have a user on a different machine select the files to play and then play them?
0
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Thomas GrassiSystems AdministratorAuthor Commented:
Dave
I have playlist that are in different folders and on different drives and always have worked
Where are you getting this information from?
What is the #EXTM3U #EXITINF:132,Song Name Filename.mp3 mean ?
My playlist simply contains the filename of the mp3 song
To answer your questions
1. I want users to play the playlist on there Computer, MAC, tablet or smart phone
2. Play it thru the Website using what ever media player they have
3. Yes anyone can do a search and select which songs they wish to play they can play them from the search results page or click on the playlist and it will play all the songs they selected.
Windows Media player cannot connect to the server the server name might not be correct the server might not be available or your proxy settings might not be correct
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
The links work if you click on them, they play. But the m3u file does not work.
This is what it looks like
<a href="%2Fmp3%5CMP3MusicAlbums%5CBruce+Chandler%5CBillboard+Top+100+%2D+1962%5C01%2DBillboard+Top+100+%2D+1962%2D13+Duke+Of+Earl%2Emp3">M:\Music\MP3MusicAlbums\Bruce Chandler\Billboard Top 100 - 1962\01-Billboard Top 100 - 1962-13 Duke Of Earl.mp3</a><a href="+%2Fmp3%5CMP3MusicAlbums%5CBruce+Springsteen%5CThe+Wild+The+Innocent+%26+The+E+Street+Shuffle%5C07%2DThe+Wild+The+Innocent+%26+The+E+Street+Shuffle%2DNew+York+City+Serenade%2Emp3"> M:\Music\MP3MusicAlbums\Bruce Springsteen\The Wild The Innocent & The E Street Shuffle\07-The Wild The Innocent & The E Street Shuffle-New York City Serenade.mp3</a><a href="+%2Fmp3%5CMP3MusicAlbums%5CVarious+Artists%5CDeadicated%5C02%2DDeadicated%2DJack+Straw+%2D+Bruce+Hornsby+%26+the+Range%2Emp3"> M:\Music\MP3MusicAlbums\Various Artists\Deadicated\02-Deadicated-Jack Straw - Bruce Hornsby & the Range.mp3</a><a href="+%2Fmp3%5CMP3MusicAlbums%5CVarious+Artists%5CPhiladelphia%5C10%2DPhiladelphia%2DStreets+Of+Philadelphia+%2D+Bruce+Springsteen%2Emp3"> M:\Music\MP3MusicAlbums\Various Artists\Philadelphia\10-Philadelphia-Streets Of Philadelphia - Bruce Springsteen.mp3</a>
#EXTM3U#EXTINF:419,Alice In Chains - Rotten AppleAlice In Chains_Jar Of Flies_01_Rotten Apple.mp3#EXTINF:260,Alice In Chains - NutshellAlice In Chains_Jar Of Flies_02_Nutshell.mp3#EXTINF:255,Alice In Chains - I Stay AwayAlice In Chains_Jar Of Flies_03_I Stay Away.mp3#EXTINF:256,Alice In Chains - No ExcusesAlice In Chains_Jar Of Flies_04_No Excuses.mp3#EXTINF:157,Alice In Chains - Whale And WaspAlice In Chains_Jar Of Flies_05_Whale And Wasp.mp3#EXTINF:263,Alice In Chains - Don't FollowAlice In Chains_Jar Of Flies_06_Don't Follow.mp3#EXTINF:245,Alice In Chains - Swing On ThisAlice In Chains_Jar Of Flies_07_Swing On This.mp3
Try and hard code the same format manually, post that to your site and try. Once we know you have a good working file, we can back in the classic asp / vbs
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I don't know enough about the file type. Try and leave it out and see what happens. You will need to find several audio files and just hard code them. Forget about the database for now, just make an m3u file work first.
When you want to create a playlist for someone using their session id just create a file that has the songe and the location you can then send this list to your player.
I want to warn you that playing music over the internet has a lot of restrictions, unless you are willing to send a minimum of $340 to ASCAP and get a license you will get a lot of DMCA takedown notices and possibly a copyright infringement case
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
David, we already have him creating the m3u file with the session id. See line 5 http:#a40026214
Can't this be done just by sending to the browser? My suggestion was to use a player and javascript or just html5 audio tag.
If you use this type of file that has to be written to disk, it means you also need a way to clean up.
Good point on licensing.
@trgrassijr55, once you do have all of this working, your next step should be to not store your music inside of your domain. You would use FileSystemObject to call up what you need or better yet, stream it. Otherwise you will just open up your self for easy downloading of your music.
What you are doing will be fine for very small usage. If your plan is to have a lot of people stream or download music, you should have all of your files on a CDN and off your server.
What you are doing will be fine for very small usage. If your plan is to have a lot of people stream or download music, you should have all of your files on a CDN and off your server. Only as long as you are licensed. all he needs is a session cookie that the song # is stored and have a lookup of the song # to the filename a database or even an xml file will be good here.
#EXTM3U
#EXTING:000, Led Zeppelin - The Song Remains the Same
M:\Music\MP3MusicAlbums\Led Zeppelin\Houses of the Holy\01-Houses of the Holy-The Song Remains the Same.mp3
#EXTING:000, Led Zeppelin - Dancing Days
M:\Music\MP3MusicAlbums\Led Zeppelin\How the West Was Won\How the West Was Won Disc 2\03-How the West Was Won Disc 2-Dancing Days.mp3
#EXTING:000, Bob Dylan - Oh Sister
M:\Music\MP3MusicAlbums\Bob Dylan\Desire\05-Desire-Oh Sister.mp3
My current code
<%if request.form<>"" thendim fs,fname, pathToPlayListset fs=Server.CreateObject("Scripting.FileSystemObject")set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"strSongs=request.form("selectItem")arraySongs=split(strSongs,",")response.write "<ul>"for each song in arraySongs response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" fname.WriteLine "<a href=""" &server.URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a>" nextresponse.write "</ul>" fname.Closeelseresponse.write "You did not post any data yet<br>"end ifset fname=nothingset fs=nothing%><input type="button" value="BACK!"onClick="history.back();"><button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
if you replace
fname.WriteLine "<a href=""" &server.URLEncode(replace(song,"M:\Music","/mp3")) & """>" & song & "</a>"
with
fname.WriteLine "<a href=""" &replace(song,"M:\Music","/mp3") & """>" & song & "</a>"
does that create the playlist properly? when i clicked the link to the m3u file and tried to play it, it didnt work, but gave an error saying the files couldnt be found
Thomas GrassiSystems AdministratorAuthor Commented:
Big Monty
Yes I tried it on another machine and it does not play
I just tried this one
#EXTM3U
#EXTING:000, Black Sabbath - Behind The Wall Of Sleep
<a href="%2Fmp3%5CMP3MusicAlbums%5CBlack+Sabbath%5CCollection+of+Hits%5C01%2DCollection+of+Hits%2DBehind+The+Wall+Of+Sleep%2Emp3">M:\Music\MP3MusicAlbums\Black Sabbath\Collection of Hits\01-Collection of Hits-Behind The Wall Of Sleep.mp3</a>
#EXTING:000,Black Sabbath - Dazed And Confused Paranoid
<a href="+%2Fmp3%5CMP3MusicAlbums%5CBlack+Sabbath%5CCollection+of+Hits%5C05%2DCollection+of+Hits%2DDazed+And+Confused++Paranoid%2Emp3"> M:\Music\MP3MusicAlbums\Black Sabbath\Collection of Hits\05-Collection of Hits-Dazed And Confused Paranoid.mp3</a>
#EXTING:000, Black Sabbath - Ironman
<a href="+%2Fmp3%5CMP3MusicAlbums%5CBlack+Sabbath%5CCollection+of+Hits%5C09%2DCollection+of+Hits%2DIronman%2Emp3"> M:\Music\MP3MusicAlbums\Black Sabbath\Collection of Hits\09-Collection of Hits-Ironman.mp3</a>
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
>Here is the M3U file output
The slashes look nice. But how does this look like what worked for you. The code below works only on your machine but we need to make it work by using urls and not mapping to your drive.
#EXTM3U#EXTING:000, Led Zeppelin - The Song Remains the SameM:\Music\MP3MusicAlbums\Led Zeppelin\Houses of the Holy\01-Houses of the Holy-The Song Remains the Same.mp3#EXTING:000, Led Zeppelin - Dancing DaysM:\Music\MP3MusicAlbums\Led Zeppelin\How the West Was Won\How the West Was Won Disc 2\03-How the West Was Won Disc 2-Dancing Days.mp3#EXTING:000, Bob Dylan - Oh SisterM:\Music\MP3MusicAlbums\Bob Dylan\Desire\05-Desire-Oh Sister.mp3
<!-- *********** You said this works **********#EXTM3U#EXTING:000, Led Zeppelin - The Song Remains the SameM:\Music\MP3MusicAlbums\Led Zeppelin\Houses of the Holy\01-Houses of the Holy-The Song Remains the Same.mp3#EXTING:000, Led Zeppelin - Dancing DaysM:\Music\MP3MusicAlbums\Led Zeppelin\How the West Was Won\How the West Was Won Disc 2\03-How the West Was Won Disc 2-Dancing Days.mp3#EXTING:000, Bob Dylan - Oh SisterM:\Music\MP3MusicAlbums\Bob Dylan\Desire\05-Desire-Oh Sister.mp3*********** should be **********#EXTM3U#EXTING:000, Led Zeppelin - The Song Remains the Samehttp://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/Houses of the Holy/01-Houses of the Holy-The Song Remains the Same.mp3#EXTING:000, Led Zeppelin - Dancing Dayshttp://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/How the West Was Won/How the West Was Won Disc 2/03-How the West Was Won Disc 2-Dancing Days.mp3#EXTING:000, Bob Dylan - Oh Sisterhttp://www.tomsmp3.com/mp3/MP3MusicAlbums/Bob Dylan/Desire/05-Desire-Oh Sister.mp3--><%if request.form<>"" thendim fs,fname, pathToPlayListset fs=Server.CreateObject("Scripting.FileSystemObject")set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"strSongs=request.form("selectItem")arraySongs=split(strSongs,",")response.write "<ul>"fname.WriteLine "#EXTM3U" '** M3U'for each song in arraySongs response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" fname.WriteLine "#EXTING:000, "&song fname.WriteLine "http://www.tomsmp3.com"&replace(replace(song,"M:\Music","/mp3"),"\","/") 'fname.WriteLine "<a href=""http://www.tomsmp3.com" &replace(song,"M:\Music","/mp3") & """>" & song & "</a>" nextresponse.write "</ul>" fname.Closeelseresponse.write "You did not post any data yet<br>"end ifset fname=nothingset fs=nothing%><input type="button" value="BACK!"onClick="history.back();"><button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
try this
#<!-- *********** Current file missing %20 for space ********************* Clean up song name **********#EXTM3U#EXTING:000, Led Zeppelin - The Song Remains the Samehttp://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/Houses of the Holy/01-Houses of the Holy-The Song Remains the Same.mp3#EXTING:000, Led Zeppelin - Dancing Dayshttp://www.tomsmp3.com/mp3/MP3MusicAlbums/Led Zeppelin/How the West Was Won/How the West Was Won Disc 2/03-How the West Was Won Disc 2-Dancing Days.mp3#EXTING:000, Bob Dylan - Oh Sisterhttp://www.tomsmp3.com/mp3/MP3MusicAlbums/Bob Dylan/Desire/05-Desire-Oh Sister.mp3--><%if request.form<>"" thendim fs,fname, pathToPlayListset fs=Server.CreateObject("Scripting.FileSystemObject")set fname=fs.CreateTextFile("m:\playlist\myplaylist_"&Session.SessionID&".m3u",true)pathToPlayList="/playlist/myplaylist_"&Session.SessionID&".m3u"strSongs=request.form("selectItem")arraySongs=split(strSongs,",")response.write "<ul>"fname.WriteLine "#EXTM3U" '** M3U'for each song in arraySongs response.write "<li><a href=""" & replace(song,"M:\Music","/mp3") & """>" & song & "</a></li>" fname.WriteLine "#EXTING:000, "& makeSongName(song) fname.WriteLine "http://www.tomsmp3.com"&replace(replace(replace(song,"M:\Music","/mp3"),"\","/")," ","%20") 'fname.WriteLine "<a href=""http://www.tomsmp3.com" &replace(song,"M:\Music","/mp3") & """>" & song & "</a>" nextresponse.write "</ul>" fname.Closeelseresponse.write "You did not post any data yet<br>"end ifset fname=nothingset fs=nothingfunction makeSongName(song) p = InStrRev(song,"\",-1) makeSongName = mid(song,p,len(song)-p)end function%><input type="button" value="BACK!"onClick="history.back();"><button value="Playlist" onclick="window.location = '<%=pathToPlayList%>'"> Playlist </button>
If it were me, I would probably have mass updated all my file names and get rid of any spaces by possibly closing the gap or replace with hyphens. I would also remove any single or double quotes that may be in the file names. I saw single quotes in some.
Actually, I would probably store each song as a number that perhaps matches an id number in the database. Then leave the title etc in the db.
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
No spaces in folder or file names. I don't like underscores for things you need to see in a browser because it is too hard to tell if it is there or not.
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Open in new window
Try and create a new button using an actual value saved.
If your domain is mydomain.com, does the file exist in mydomain.com/playlist/mypl
I wonder if your files are not located inside of your domain?