Jump to content

How to do a Java Music System?


The Sea King

Recommended Posts

Remember, the Java in JavaScript is only due to a marketing deal done between Netscape Communcations and Sun Microsystems, but the actual languages are very different. Are you thinking of a applet control or a JavaScript script?

Link to comment
Share on other sites

Do you already have something set up that you're trying to modify? I guess I would have an embedded object that would play the song in the user's player and use Javascript to change the source of the file to play. It would be better to use a Flash music player though, there are several of them available online to use.

Link to comment
Share on other sites

Do you want to use a javascript to open files to play?I have this cool javascript to play music files in a separate blank window of desired size. Users can download music file currently playing or you can even disable this feature. here is the code of script:======================var UniqueID = 314 // Make each link open in a new window.var newWinOffset = 0 // Position of first pop-upfunction PlayerOpen(soundfiledesc,soundfilepath) {PlayWin = window.open('',UniqueID,'width=320,height=200,top=' + newWinOffset +',left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');PlayWin.focus(); var winContent = "<HTML><HEAD><TITLE>" + soundfiledesc + "</TITLE></HEAD><BODY bgcolor='#FFFFFF'>";winContent += "<B style='font-size:18px;font-family:Verdana,sans-serif;line-height:1.5'>" + soundfiledesc + "</B>";winContent += "<OBJECT width='300' height='42'>";winContent += "<param name='SRC' value='" + soundfilepath + "'>";winContent += "<param name='AUTOPLAY' VALUE='true'>";winContent += "<param name='CONTROLLER' VALUE='true'>";winContent += "<param name='BGCOLOR' VALUE='#FFFFFF'>";winContent += "<EMBED SRC='" + soundfilepath + "' AUTOSTART='TRUE' LOOP='TRUE' WIDTH='300' HEIGHT='42' CONTROLLER='TRUE' BGCOLOR='#FFFFFF'></EMBED>";winContent += "</OBJECT>";winContent += "<p style='font-size:12px;font-family:Verdana,sans-serif;text-align:center'><a href='"+soundfilepath+"'>Download this file</a> <SPAN style='font-size:10px'>(Right click to download)</SPAN></p>";winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window' onClick='java script:window.close();'></DIV></FORM>";winContent += "</BODY></HTML>";PlayWin.document.write(winContent);PlayWin.document.close(); // "Finalizes" new windowUniqueID = UniqueID + 1// newWinOffset = newWinOffset + 20 // subsequent pop-ups will be this many pixels lower.}===========================Now you can save this script as music.js and add link to your html website head. like this, <script language="JavaScript" type="text/JavaScript" src="http://www.site.com/music.js"></script> make sure the JS file path is exactly as on your server.And now you can display files on your site as thiscode: <a href="example.mp3" target="_blank" onClick="java script:PlayerOpen('My Music',this.href); return false"> And when u click on it, it will play in a separatre window and you can select other file to open without closing the window.Hope this script helps ya all. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...