Log in

View Full Version : player mp3 on this link.



kenphan19
04-03-2008, 12:04 PM
1) Script Title: player mp3 on this link.

2) Script URL (on DD): http://www.dynamicdrive.com/forums/newthread.php?do=newthread&f=2
3) Describe problem: hi, please help me how to make .js. i want playing mp3 on this link
<a href="song.mp3">song</a> .... it same here (http://www.duesentrieb.org/2008/03/sounds-like-vocal-trip-hop-spoken-word.html).
Thanks a lot

Jas
04-03-2008, 05:33 PM
Are you saying you want the same effect as that site? All they did was link to the file so that, when a user clicks the link, the file opens in a player (such as windows media player). In other words, they did what you did with that link. The method usually works just fine.

If you want to actually embed a player in a webpage, that's a little different. The easiest way would be to have a popup window open onclick. The new window would have a player inside, and can use the URL or a cookie to figure out what song to play. You might look at this tutorial (http://www.oreillynet.com/pub/a/oreilly/digitalmedia/2006/05/31/build-a-better-web-audio-player.html?page=1).
Or this script (http://rapidweaver.indesteigers.nl/pages/popupplayer.html).

Or are you talking about music in the background of the webpage?

kenphan19
04-03-2008, 05:48 PM
thanks so much.

kenphan19
04-09-2008, 02:57 PM
this code below playing mp3 when in HTML source have code href="htttp://....song.mp3" ... however i want update it playing .wma ... please help me how to edit this script to playing wma.
Thanks so much.
Click here to see it run. (http://tutsite.com/example/)

if(typeof(p) == 'undefined') p = {}
p.m = {
x: null,
y: null,
g: function() {
var all = document.getElementsByTagName('a')
for (var i = 0, o; o = all[i]; i++) {
if(o.href.match(/\.mp3$/i)) {
var r = document.createElement('img')
r.src = 'http://localhost/test/php/player/play.gif'; r.title = 'Play'
r.height = 19
r.width = 59
r.style.padding= '0px 5px 0px 2px'
r.style.display = 'block'
r.style.marginLeft = '0'
r.style.cursor = 'pointer'
r.style.verticalAlign = 'middle'
r.style.border = '0'
r.onclick = p.m.makeToggle(r, o.href)
o.parentNode.insertBefore(r, o)
}}},
toggle: function(r, u) {
if (p.m.x == r) p.m.destroy()
else {
if (p.m.x) p.m.destroy()
var a = r.nextSibling, c=''
if (document.defaultView && document.defaultView.getComputedStyle) c = document.defaultView.getComputedStyle(a,null).getPropertyValue('color')
else if (a.currentStyle) c = a.currentStyle['color']
c = c.replace(/^rgb|[ ()]/g, '')
var hex = c.match(/^#?([a-f0-9]{6})$/), hexSm = c.match(/^#?([a-f0-9]{3})$/), rgb = c.match(/^([0-9]+),([0-9]+),([0-9]+)$/)
if (rgb) { var c16 = "0123456789abcdef", c=''; for(var i=1,d;d=rgb[i];i++) { var j=d%16; c=c+c16.charAt((d-j)/16)+c16.charAt(j) } }
else if (hex) c = hex[1]
else if (hexSm) c = hexSm[1].charAt(0) + hexSm[1].charAt(0) + hexSm[1].charAt(1) + hexSm[1].charAt(1) + hexSm[1].charAt(2) + hexSm[1].charAt(2)
else c = "000000"

r.src = 'http://localhost/test/php/player/stop.gif'; r.title = 'Stop playing'; p.m.x = r;
p.m.y = document.createElement('span')
p.m.y.innerHTML = '<object style="vertical-align:bottom; margin-top:2px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
'width="50" height="14" id="y" align="middle">' +
'<param name="wmode" value="transparent" />' +
'<param name="allowScriptAccess" value="sameDomain" />' +
'<param name="flashVars" value="theLink='+u+'&amp;fontColor='+c+'" />' +
'<param name="movie" value="http://localhost/test/php/player/mp3.swf" /><param name="quality" value="high" />' +
'<embed style="vertical-align:bottom; margin-top:5px;" src="http://localhost/test/php/player/mp3.swf" flashVars="theLink='+u+'&amp;fontColor='+c+'"'+
'quality="high" wmode="transparent" width="50" height="14" name="y"' +
'align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"' +
' pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'
r.parentNode.insertBefore(p.m.y, r.nextSibling)
}},
destroy: function() {
p.m.x.src = 'http://localhost/test/php/player/finish.gif'; p.m.x = null
p.m.y.removeChild(p.m.y.firstChild); p.m.y.parentNode.removeChild(p.m.y); p.m.y = null
},
makeToggle: function(r, u) { return function(){ p.m.toggle(r, u) }}
}

p.addLoadEvent = function(f) { var old = window.onload
if (typeof old != 'function') window.onload = f
else { window.onload = function() { old(); f() }}
}

p.addLoadEvent(p.m.g)

Jas
04-10-2008, 05:35 PM
I don't think I understand the question. Can you explain more?

kenphan19
04-11-2008, 03:38 AM
i want edit this script, it will play .wma, Click here to see it run. (http://tutsite.com/example/)