Older Version
Newer Version
StPendl
Jun 3, 2009
=HTML Music= The automatically creates a web page Tune List.htm of links to up to 5000 MID, MP3, and WMA files in a folder to be uploaded to a site. Though there are of course copyright restrictions of even allowing others to play MP3 etc music tracks online let alone download copies, there appear to no such restrictions on the many thousands of MID file available on the Internet. You can see an example of some of my favourite MIDis using a Tune List.htm from the PC Music Page at [[http://www.sigord.co.uk/]] The code below is mostly straightforward, much based on kind help provided over the years by such as Alyce and Stefan. You will notice it can safely be compacted into a single file with Windows Iexpress wherever that is kept, as when first run it needs to locate the folder with all the sound files in order to save the HTML Heads.txt holding the headings, and Tune List.htm for uploading. Notice there are Error traps such as warning if you are not logged onto the folder with the sound files, also preventing anyone using more than 10 headings, or 5000 sound files. Likewise the main window #h is closed when notepad is used. Those like me with even a limited knowledge of HTML should be able to change such as the colours or font size created with Tune List.htm. Gordon'[[code format="vbnet"]] ' Auto music web page for MID, MP3, WMA onlynomainwin dimnomainwin dim head$(20) : dim file$(5000)dimdim info$(1,1) : dim dir$(10,3) : File$ = "" [start]WindowWidthWindowWidth = 800 : WindowHeight = 600buttonbutton #h, "Set the Headings", [heads], LL 30, 20buttonbutton #h, "Load Music files", [music], LL 180, 20buttonbutton #h, "Create Web Page ", [create], LL 330, 20buttonbutton #h, " Test Web Page ", [test], LL 480, 20buttonbutton #h, " Show HTML code ", [html], LL 630, 20openopen "HTML Music Page" for graphics as #h#h#h "trapclose [quit]; down; fill white" : gosub [notes]hfile$hfile$ = "HTML Heads.txt" : page$ = "Tune List.htm"#h#h "place 240 300 ; color red"ifif File$ <> "" then#h#h "place 10 300; color black"forfor d = 1 to nheadtbtb = 80 - len(head$(d))#h#h "\";space$(tb);d;" ";head$(d)nextnext dendend if#h#h "flush" : playwave "ping" : wait [notes]#h#h "font arial 24 bold; color darkgreen; place 240 50"#h#h "\Music Web Page coder" : #h "font arial 14 bold; place 250 80"#h#h "\Ver 1.2 Produced with Liberty Basic" : #h "place 100 120"#h#h "\This will automatically create a web page as tune list.htm listing all"#h#h "\music files in the same folder as active links. You may be aware"#h#h "\though there appears to be no copyright restrictions on using MID"#h#h "\keyboard files, there are on MP3, WMA recorded music tracks etc."'#h#h "\Remove any spaces in filenames to avoid poor format layouts."#h#h "[[file://\\You|\\You]] will first be asked to locate the folder with all the Music Files"#h#h "color black" : return [files]filedialogfiledialog "To locate the folder Select sample music file", "*.mid;*.mp3;wma", File$ifif File$ = "" then [quit]File$File$ = upper$(File$)sFile$sFile$ = noPath$(File$)plenplen = len(File$)-len(sFile$)path$path$ = left$(File$,plen) : DefaultDir$ = path$filesfiles DefaultDir$,hfile$ , info$(test$test$ = DefaultDir$ + hfile$ifif val(info$(0, 0)) = 0 thenn$n$ = test$+"being created !" : notice n$openopen hfile$ for output as #1#1#1 "DUMMY HEADING" : close #1File$File$ = ""endend ifreturnreturn [heads]ifif File$ = "" then gosub [files]closeclose #hop$op$ = "notepad.exe " + DefaultDir$ + hfile$ : run op$noticenotice "Any changes will now display"openopen hfile$ for input as #2nheadnhead = 0: ok = 0whilewhile ok = 0ifif eof(#2) = 0 thennheadnhead = nhead + 1ifif nhead > 10 thennoticenotice "Reduce number of headings to limit of 10"closeclose #2 : goto [start]endend iflineline input #2, i$: head$(nhead)=i$else okelse ok = 1endend ifwend closewend close #2gotogoto [start] [music]ifif File$ = "" then gosub [files]ext$ext$ = "*.*"filesfiles path$, ext$, dir$()qtyFilesqtyFiles = val(dir$(0, 0))'reformat'reformat the file informationforfor x = 1 to qtyFilesdir$(x,dir$(x, 1) = right$(" " + dir$(x, 1), 9)nextnext xsortingsorting =int(rnd(1)*4)sortsort dir$(), qtyFiles, 1, sorting : nfile = 0forfor x = 1 to qtyFilestemp$temp$ = dir$(x, 0) : chk$ = upper$(right$(temp$,3))ifif chk$ = "MID" or temp$ = "MP3" or temp$ = "WMA" thennfilenfile = nfile + 1ifif nfile > 5000 thennoticenotice "Reduce number of files to limit of 5000"exitexit for : goto [quit]endend iffile$(nfile)file$(nfile) = temp$endend ifnextnext xifif nfile < 5 then notice "FEW MUSIC FILES ??" : File$ = "" : waittx$tx$ = "\"#h#h "cls; place 20 20; font fixedsys 9; color black; fill white"forfor s = 1 to nfiletx$tx$ = tx$ + file$(s) + " "ifif len(tx$) > 75 then #h tx$ : tx$ = "\"nextnext s#h#h "[[file://\\";space$(35);"Total|\\";space$(35);"Total]] Music Files = ";nfile#h#h "flush" : wait [create]ifif nfile < 5 then notice "NO MUSIC FILES" : waitifif File$ = "" then gosub [files]openopen "Tune List.htm" for output as #1#1#1 "<html><head><title>tunes</title></head>"#1#1 "<body><body bgcolor=66ff33>"#1#1 "<font face=arial><font size=5><font color=ff0080>"#1#1 "<b><center>"forfor t = 1 to nheadt$t$ ="<br>" + head$(t) : #1 t$nextnext t#1#1 "</center><font face=arial><font size=2><font color=000000>"#1#1 "<blockquote>"t$t$ =""forfor n = 1 to nfiletlentlen = len(file$(n))-4 : tune$ = left$(file$(n),tlen)t$t$ = "  <a href="+file$(n)+">"+tune$+"</a>"#1#1 t$nextnext n#1#1 "</blockquote>"t$t$ = "<center>Total music files = " + str$(nfile) + "</center></b>"#1#1 t$#1#1 "</body><html>"closeclose #1#h#h "[[file://\\";space$(30);"Test|\\";space$(30);"Test]] the page or display the HTML code ?"waitwait [test]ifif File$ = "" then gosub [files]CALLCALL ShellExecute hWnd, page$waitwait [html]ifif File$ = "" then gosub [files]closeclose #hop$op$ = "notepad.exe " + DefaultDir$ + page$ : run op$confirmconfirm "Continue ?";c$ifif c$ = "yes" then goto [start] else end [quit] close #h : end function noPath$(t$)whilewhile instr(t$, "\")t$t$ = mid$(t$, 2)wend noPath$wend noPath$ = t$ end function Sub ShellExecute hWnd, cf$parameterparameter = _SW_SHOWNORMAL ' set up for viewinglpszOp$lpszOp$ = "open" + Chr$(0) ' "open" or "play" or "print"lpszFile$lpszFile$ = cf$ + Chr$(0)lpszDir$lpszDir$ = DefaultDir$ + Chr$(0)lpszParams$=""lpszParams$="" + Chr$(0)CallDLLCallDLL #shell32, "ShellExecuteA", hWnd As long,lpszOp$ As ptr,lpszFile$ As ptr,_lpszParams$lpszParams$ As ptr,lpszDir$ As ptr,parameter As long, result As long End Sub [[code]]