Older Version Newer Version

StPendl 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 only nomainwin dim nomainwin dim head$(20) : dim file$(5000) dim dim info$(1,1) : dim dir$(10,3) : File$ = "" [start] WindowWidth WindowWidth = 800 : WindowHeight = 600 button button #h, "Set the Headings", [heads], LL 30, 20 button button #h, "Load Music files", [music], LL 180, 20 button button #h, "Create Web Page ", [create], LL 330, 20 button button #h, " Test Web Page ", [test], LL 480, 20 button button #h, " Show HTML code ", [html], LL 630, 20 open open "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" if if File$ <> "" then #h #h "place 10 300; color black" for for d = 1 to nhead tb tb = 80 - len(head$(d)) #h #h "\";space$(tb);d;" ";head$(d) next next d end end 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] filedialog filedialog "To locate the folder Select sample music file", "*.mid;*.mp3;wma", File$ if if File$ = "" then [quit] File$ File$ = upper$(File$) sFile$ sFile$ = noPath$(File$) plen plen = len(File$)-len(sFile$) path$ path$ = left$(File$,plen) : DefaultDir$ = path$ files files DefaultDir$,hfile$ , info$( test$ test$ = DefaultDir$ + hfile$ if if val(info$(0, 0)) = 0 then n$ n$ = test$+"being created !" : notice n$ open open hfile$ for output as #1 #1 #1 "DUMMY HEADING" : close #1 File$ File$ = "" end end if return return [heads] if if File$ = "" then gosub [files] close close #h op$ op$ = "notepad.exe " + DefaultDir$ + hfile$ : run op$ notice notice "Any changes will now display" open open hfile$ for input as #2 nhead nhead = 0: ok = 0 while while ok = 0 if if eof(#2) = 0 then nhead nhead = nhead + 1 if if nhead > 10 then notice notice "Reduce number of headings to limit of 10" close close #2 : goto [start] end end if line line input #2, i$: head$(nhead)=i$ else ok else ok = 1 end end if wend close wend close #2 goto goto [start] [music] if if File$ = "" then gosub [files] ext$ ext$ = "*.*" files files path$, ext$, dir$() qtyFiles qtyFiles = val(dir$(0, 0)) 'reformat 'reformat the file information for for x = 1 to qtyFiles dir$(x, dir$(x, 1) = right$(" " + dir$(x, 1), 9) next next x sorting sorting =int(rnd(1)*4) sort sort dir$(), qtyFiles, 1, sorting : nfile = 0 for for x = 1 to qtyFiles temp$ temp$ = dir$(x, 0) : chk$ = upper$(right$(temp$,3)) if if chk$ = "MID" or temp$ = "MP3" or temp$ = "WMA" then nfile nfile = nfile + 1 if if nfile > 5000 then notice notice "Reduce number of files to limit of 5000" exit exit for : goto [quit] end end if file$(nfile) file$(nfile) = temp$ end end if next next x if if nfile < 5 then notice "FEW MUSIC FILES ??" : File$ = "" : wait tx$ tx$ = "\" #h #h "cls; place 20 20; font fixedsys 9; color black; fill white" for for s = 1 to nfile tx$ tx$ = tx$ + file$(s) + " " if if len(tx$) > 75 then #h tx$ : tx$ = "\" next next s #h #h "[[file://\\";space$(35);"Total|\\";space$(35);"Total]] Music Files = ";nfile #h #h "flush" : wait [create] if if nfile < 5 then notice "NO MUSIC FILES" : wait if if File$ = "" then gosub [files] open open "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>" for for t = 1 to nhead t$ t$ ="<br>" + head$(t) : #1 t$ next next t #1 #1 "</center><font face=arial><font size=2><font color=000000>" #1 #1 "<blockquote>" t$ t$ ="" for for n = 1 to nfile tlen tlen = len(file$(n))-4 : tune$ = left$(file$(n),tlen) t$ t$ = "&nbsp;&nbsp<a href="+file$(n)+">"+tune$+"</a>" #1 #1 t$ next next n #1 #1 "</blockquote>" t$ t$ = "<center>Total music files = " + str$(nfile) + "</center></b>" #1 #1 t$ #1 #1 "</body><html>" close close #1 #h #h "[[file://\\";space$(30);"Test|\\";space$(30);"Test]] the page or display the HTML code ?" wait wait [test] if if File$ = "" then gosub [files] CALL CALL ShellExecute hWnd, page$ wait wait [html] if if File$ = "" then gosub [files] close close #h op$ op$ = "notepad.exe " + DefaultDir$ + page$ : run op$ confirm confirm "Continue ?";c$ if if c$ = "yes" then goto [start] else end [quit] close #h : end function noPath$(t$) while while instr(t$, "\") t$ t$ = mid$(t$, 2) wend noPath$ wend noPath$ = t$ end function Sub ShellExecute hWnd, cf$ parameter parameter = _SW_SHOWNORMAL ' set up for viewing lpszOp$ lpszOp$ = "open" + Chr$(0) ' "open" or "play" or "print" lpszFile$ lpszFile$ = cf$ + Chr$(0) lpszDir$ lpszDir$ = DefaultDir$ + Chr$(0) lpszParams$="" lpszParams$="" + Chr$(0) CallDLL CallDLL #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]]