10/10/2018, 00:24

Xin code Javascript để điều khiển windows media

Mình tạo 1 đối tượng windows media bằng mã Javascripit và mình muốn xin đoạn code để khi windows media chơi xong 1 bản nhạc nó sẽ hiện lên thông báo"Đã chơi xong bản nhạc".Thanks các bạn đã đọc
s.code viết 02:37 ngày 10/10/2018
<OBJECT id="media" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" width="490" height="395">
<PARAM name="uimode" value="none">
<PARAM NAME="stretchToFit" VALUE="1">
<param name="playCount" value="10">
<param name="URL" value="">
<PARAM name="EnableContextMenu" value="0">
<param name="enableErrorDialogs" value="0">
</OBJECT>

[=========> Bổ sung bài viết <=========]

<script for ='media' event='playStateChange(NewPlayState)'>
//Trang thai media thay doi se dc gan vao bien NewPlayState ( 1-->15 ) dua vao gia tri ma su li
try
{
document.control.SetVariable('mediastate', NewPlayState);
}
catch(e){}
if(NewPlayState == 8)
{
PlayNextSong();
}
</script>

[=========> Bổ sung bài viết <=========]

Híc ngày xưa mình đã làm cái này. Dùng control flash điều khiển media và ngược lại. Nhưng mà bỏ 4 năm ko sờ tới.

Giờ tặng bạn nè.

Code:
<?
require_once("library.php");
require_once("config.php");
session_start();
$se_id=session_id();//Lay session_id cua trinh duyet
$time=time();
if(!get_session("visit"))
{
	create_session("visit","index.php");
	//Them 1 luot truy cap
	$str="UPDATE counter SET Counter = Counter + 1 WHERE id=1";
	mysql_query($str);
	//END
	//So nguoi Online
	$str="INSERT INTO online VALUES('', '$se_id', $time)";
	mysql_query($str);//Chen them anh moi vao
	//END
	mysql_close();
}
//END
?>
<HTML>
<HEAD>
<TITLE>Sincos Media Player</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="vi">
<meta name="keywords" content="Ca nhac, Nhac tre, Nhac vang, Truyen hinh, Radio">
<meta name="description" content="Ca nhạc, Truyền hình, Radio, Phim truyện">

<style>
BODY
{
	BGCOLOR: #FFFFFF;
	MARGIN: 0px;
}
#Song
{
	padding-left: 5px;
	padding-right: 5px;
	padding-top: 0px;
	padding-bottom: 0px;
	font-size: 14px;
}
#Song A
{
	display: block;
	cursor: auto;
	color: white;
	text-decoration: none;
}
#Song A:hover
{
	background-color: #68A5C9;
}
#Song A:Active
{
	color: #A4EB0C;
}
#Singer1
{
	font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
	font-size: 12px;
}
#Singer1 A
{
	display: block;
	padding-top: 2px;
	height: 17px;
	color: #005279;
	text-decoration: none;
}
#Singer1 A:hover
{
	background-color: #68A5C9;
}
#Singer1 A:active
{
	color: #000066;
}
#Singer2
{
	font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
	font-size: 12px;
	background-color: #C8E3F3;
}
#Singer2 A
{
	display: block;
	padding-top: 2px;
	height: 17px;
	color: #005279;
	text-decoration: none;
}
#Singer2 A:hover
{
	background-color: #68A5C9;
}
#Singer2 A:active
{
	color: #000066;
}
#Cat
{
	font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
	font-size: 12px;
}
#Cat A
{
	display: block;
	height: 20px;
	padding-top: 3px;
	color: #005279;
	text-decoration: none;
}
#Cat A:hover
{
	background-color: #C8E3F3;
}
#Cat A:active
{
	color: #000066;
}
#HeadListSongBox
{
	font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
}
#HeadListSongBox A
{
	display: block;
	color: #CCCCCC;
	text-align: center;
	text-decoration: none;
}
#HeadListSongBox A:hover
{
	color: white;
}
#DownLoadBox
{
	font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
	font-size: 10px;
}
#DownLoadBox A
{
	text-decoration: none;
	color: #CCCCCC;
}
#DownLoadBox A:hover
{
	color: white;
	text-decoration: underline;
}
#SongNameBox
{
	padding-left: 5px;
	padding-top: 3px;
	font-family: Arial;
	font-size: 14px;
	font-weight: bold;
	color: white;
}
#MiniSingerName
{
	padding-left: 5px;
	font-family:Arial;
	font-size: 12px;
	color: white;
}
#QuichSearch
{
	float: right;
	padding-right: 5px;
	padding-top: 2px;
	font-family: Tahoma;
	font-size: 12px;
	color: #CCCCCC;
}
#OnlineBox
{
	float: left;
	padding-left: 10px;
	padding-top: 7px;
	font-family: Tahoma;
	font-size: 11px;
	color: #CCCCCC;
}
</style>
</HEAD>
<BODY>
<center>
<TABLE WIDTH=744 BORDER=0 CELLPADDING=0 CELLSPACING=0>
	<TR>
		<TD COLSPAN=5>
			<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="bar" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="743" height="65">
				<param name="movie" value="images/bar.swf">
				<param name="quality" value="High">
				<param name="menu" value="false">
				<param name="allowscriptaccess" value="always">
				<embed src="images/bar.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="bar" width="743" height="65" allowScriptAccess="always"></object>
		</TD>
	</TR>
	<TR>
		<TD COLSPAN=3 background="images/Media_02.gif" width="505" height="28" align ="center" valign="top">
			<div id ="OnlineBox"></div>
			<div id ="QuichSearch">
			Tìm kiếm: 
			<input type ="text" id ="keyword" value ="Quick search" onfocus ="this.value=''" onblur ="if(this.value=='') this.value='Quick search'" style="border: 0px; background-color: #CCD9E2">
			<input type ="image" src ="images/search.gif" align=absMiddle onclick ="SearchSong();" >
			</div>
		</TD>
		<TD COLSPAN=2 background="images/Media_03.gif" width="239" height="28" valign="middle">
			<div id ="HeadListSongBox" onclick ="return false"></div>
		</TD>
	</TR>
	<TR>
		<TD>
			<IMG SRC="images/Media_04.gif" WIDTH=9 HEIGHT=437 ALT=""></TD>
		<TD width="491" height="437">
		<!--Frame1 Start-->
		<div align="center" id ="Frame1" >
			<div id ="HeadMediaBox" style ="height: 42px; background-color: black">
				<table cellpadding="0" cellspacing="0" height="42" width="100%">
					<tr>
						<td height="42">
							<div id ="SongNameBox">SongTitle</div>
							<div id ="MiniSingerName">SingerTitle</div>
						</td>
						<td height="42" width="20%" valign="middle">
							<div id ="DownLoadBox" align ="center"><a href ="#">DownLoad</a></div>
						</td>
					</tr>
				</table>
			</div>
			<div id ="MediaBox" style ="height: 395px; background-color: black">
			<OBJECT id="media" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" width="490" height="395">
			<PARAM name="uimode" value="none">
			<PARAM NAME="stretchToFit" VALUE="1">
			<param name="playCount" value="10">
			<param name="URL" value="">
			<PARAM name="EnableContextMenu" value="0">
			<param name="enableErrorDialogs" value="0">
			</OBJECT>
			</div>
		</div>
		<!--Frame1 End-->
		<!--Frame2 Start-->
		<div id ="Frame2" class ="Frame" style ="display: none; background-color: #D5EBF9; width: 491px; height: 437px">
			<table cellpadding="0" cellspacing="0" width="491">
			<tr>
				<td id ="CatListBox" height="437" width="182" style ="border-right: #006DB3 1px solid"></td>
				<td id ="SingerListBox" height="437" style ="border-left: #006DB3 1px solid"></td>
			</tr>
			</table>
		</div>
		<div id ="Frame3" style ="display: none; background-color: #D5EBF9; width: 491px; height: 437px"> Search</div>
		<div id ="Frame4" style ="display: none; background-color: #D5EBF9; width: 491px; height: 437px"> News</div>
		<!--Frame4 End-->
		<!--Frame5 Start-->
		<div id ="Frame5" style ="display: none; background-color: #D5EBF9; width: 491px; height: 437px; padding-top: 5px; padding-left: 10px; padding-right: 10px">
			<div style="text-align: center; font-weight: bold">Góp ý - Liên h***7879;</div>
			<hr size =1>
			Tên c***7911;a b***7841;n: <input type="text" id="fbTextName" size="30"><br>
			Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="text" id="fbTextEmail" size="30"><br>
			N***7897;i dung: <br>
			<textarea id="fbTextContent" rows="17" cols="56"></textarea> <br>
			<div align="center">
			<input type="button" id="fbSubmit" value="Góp ý" onclick ="PostFeedBack()">
			<input type="button" value="Hu***7927; b***7887;" onclick ="ResetValue('fbTextName'); ResetValue('fbTextEmail'); ResetValue('fbTextContent')">
			</div>
		</div>
		<!--Frame5 End-->
		<!--Frame6 Start-->
		<div id ="Frame6" style ="display: none; background-color: #D5EBF9; width: 491px; height: 437px"> About</div>
		</TD>
		<TD>
			<IMG SRC="images/Media_05.gif" WIDTH=5 HEIGHT=437 ALT=""></TD>
		<TD id="SongListBox" width="229" height="437" bgcolor="#0076C2"></TD>
		<TD>
			<IMG SRC="images/Media_06.gif" WIDTH=10 HEIGHT=437 ALT=""></TD>
	</TR>
	<TR>
		<TD COLSPAN=5>
			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,42,0" id="control" width="744" height="61">
			<param name="movie" value="images/control.swf">
  			<param name="bgcolor" value="#FFFFFF">
  			<param name="quality" value="high">
  			<param name="menu" value="false">
  			<param name="allowscriptaccess" value="always">
  			<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width="744" height="61" name="control" src="images/control.swf" bgcolor="#FFFFFF" quality="high" swLiveConnect="true" allowScriptAccess="always"></embed>
			</object>
		</TD>
	</TR>
</TABLE>
</center>
<script for ='media' event='playStateChange(NewPlayState)'>
//Trang thai media thay doi se dc gan vao bien NewPlayState ( 1-->15 ) dua vao gia tri ma su li
	try
	{
		document.control.SetVariable('mediastate', NewPlayState);
	}
	catch(e){}
	if(NewPlayState == 8)
	{
		PlayNextSong();
	}
</script>

<script>
//----------------------------------------------
//         Cac ham su li media - flash         |
//----------------------------------------------
function MediaMute()//Thiet lap trang thai mute cho media theo lenh cua control
{
	try
	{
		x= document.control.GetVariable('mute');
		media.settings.mute = x;
	}
	catch(e){}
	setTimeout("MediaMute();",500);
}
MediaMute();
//----------------------------------------------
function MediaVolume()//Thiet lap volume cua media theo lenh cua control flash
{
	try
	{
		volume=document.control.GetVariable('vol');
		if(media.settings.mute ==0)
		{
		media.settings.volume = volume;
		}
	}
	catch(e){}
	setTimeout("MediaVolume();", 100);
}
MediaVolume();
//----------------------------------------------
function SongLong(st) // Chuyen chuoi thoi gian cua media thanh so giay
{
	var x=new Array();
	var y;
	x=st.split(':');
	for(i=0; i<x.length; i++)
	{
		if(x[i]=='08')
		x[i]='8';
		if(x[i]=='09')
		x[i]='9';
	}
	if(x.length==2)
	{
		return parseInt(x[0])*60 + parseInt(x[1]);
	}
	else if(x.length==3)
	{
		return parseInt(x[0])*60*60 + parseInt(x[1])*60 + parseInt(x[2]);
	}
	else
	{
		return 0;
	}
}
//----------------------------------------------
function SetSeek()//Thiet lap vi tri seek cua ban nhac dang choi vao control
{
	try
	{
		var percent, x, y;
		x=SongLong(media.controls.currentPositionString);
		y=SongLong(media.currentMedia.durationString);
		document.control.SetVariable('_root.getseekvar',Math.round((x/y)*1000));
	}
	catch(e){}
	setTimeout("SetSeek();",10);
}
SetSeek();
//----------------------------------------------
function GetSeek() //Seek ban nhac dang choi theo lenh cua control flash
{
	try
	{
	var x;
	x=document.control.GetVariable('_root.setseekvar');
	x=parseInt(x);
	if(x>=0)
	{
		media.controls.currentPosition=Math.round((x*SongLong(media.currentMedia.durationString))/1000);
		document.control.SetVariable('_root.setseekvar',-1)
	}
	}
	catch(e){}
	setTimeout('GetSeek();',10);
}
GetSeek();
//----------------------------------------------
function SetFlashTimePlayed() // Hien thi thoi gian da choi ban nhac tren control flash
{
	try
	{
		document.control.SetVariable('_root.timeplay',media.controls.currentPositionString + ' - ' + media.currentMedia.durationString);
	}
	catch(e){}
	setTimeout("SetFlashTimePlayed();",500);
}
SetFlashTimePlayed();
//----------------------------------------------
function SetRate()//Thiet lap toc do tai nghac biRate cho control
{
	try
	{
		document.control.SetVariable('mediarate',Math.round(media.network.bitRate/1024));
	}
	catch(e){}
	setTimeout("SetRate();",10);
}
SetRate();
//----------------------------------------------
function SetBuffer()//Thiet lap phan tram da tai buffer cho control
{
	try
	{
		document.control.SetVariable('mediabuffer',media.network.bufferingProgress);
	}
	catch(e){}
	setTimeout("SetBuffer();",10);
}
SetBuffer();
//----------------------------------------------
function SetMediaStop()//Thiet lap stop cho media theo lenh cua control flash
{
	try
	{
		cmd = document.control.GetVariable('stopsong');
		if (cmd == 1)
		{
			media.controls.stop();
			document.control.SetVariable('stopsong',0);
		}
	}
	catch(e){}
	setTimeout("SetMediaStop();",100);
}
SetMediaStop();
//----------------------------------------------
function SetMediaPlayPause() //Thiet lap play/pause cho media theo lenh cua control flash
{
	try
	{
		cmd = document.control.GetVariable('playpausecmd');
		if (cmd == 1)
			{
			media.controls.play();
			document.control.SetVariable('playpausecmd',0);
			}
		if (cmd == 2)
			{
			media.controls.pause();
			document.control.SetVariable('playpausecmd',0);
			}
	}
	catch(e){}
	setTimeout("SetMediaPlayPause();",100);
}
SetMediaPlayPause();
//----------------------------------------------
function SetMediaNext()//Nhan lenh cua control de choi bai tiep
{
	try
	{
		cmd=document.control.GetVariable('_root.nextsong');
		if(cmd == 1)
		{
			PlayNextSong();
			document.control.SetVariable('nextsong',0);
		}
	}
	catch(e){}
	setTimeout("SetMediaNext();",100)
}
SetMediaNext();
//----------------------------------------------
function SetMediaPre()//Nhan lenh cua control de choi bai truoc do
{
	try
	{
		cmd=document.control.GetVariable('presong');
		if(cmd == 1)
		{
			PlayPreSong();
			document.control.SetVariable('presong',0);
		}
	}
	catch(e){}
	setTimeout('SetMediaPre();',100)
}
SetMediaPre();
//----------------------------------------------
// Ket thuc cac ham su li control
//----------------------------------------------
function ResetFrame()
{
	for(i=1; i<=6; i++)
	{
		document.getElementById('Frame'+i).style.display ='none';
	}
}
function DisplayFrame(name)
{
	document.getElementById(name).style.display ='';
}
//Cac ham su li Flash Bar
var TabClicked=1;
function GetTabClick()
{
	try
	{
		var ButtonClick=parseInt(document.bar.GetVariable('buttonclick'));
		if(ButtonClick != TabClicked)
		{
			ResetFrame();
			DisplayFrame('Frame'+ButtonClick);
			TabClicked=ButtonClick;
			switch(ButtonClick)
			{
				case 1:
					
					break;
				case 2:
					{
					LoadCatList();
					LoadSingerList(1);
					break;
					}
				case 3:
			
				case 4:
				
				case 5:
				
				case 6:
				
				default:
					break;
			}
		}
	}
	catch(e){}
	setTimeout("GetTabClick();",10);
}
GetTabClick();
function DisplayLoading(mode)
{
	try
	{
		if(mode)
			document.bar.SetVariable('load',1);
		else
			document.bar.SetVariable('load',0);
	}
	catch(e){}
}

//----------------------------------------------

//Cong nghe Ajax bat dau
function CreateRequest() //Ham tao doi tuong HTTP
{
	var xmlhttpObject=null;
	if(window.XMLHttpRequest)//IE
	{
		xmlhttpObject=new XMLHttpRequest();
	}
	else if(window.ActiveXObject)//Not IE
	{
		xmlhttpObject=new ActiveXObject('microsoft.XMLHTTP');
	}
	return xmlhttpObject;
}
//Load Category
function LoadCatList()
{
	DisplayLoading(true);
	var CatHttp=CreateRequest();
	if(CatHttp == null)
	{
		alert('This Browse does not support HTTP. CatHttp=null');
		return 0; //Exit function
	}
	CatHttp.onreadystatechange= function ()
		{
			if(CatHttp.readystate ==4 || CatHttp.readystate =='complete')
			{
			st=CatHttp.ResponseText;
			cut=st.split('<||>');
			document.getElementById('CatListBox').innerHTML ='<div style ="overflow-Y: auto; padding-left: 3px; height: 420px">' + cut[0] + '</div><div style="height: 17px; padding-left: 3px; padding-top: 2px; background-color: #0076C2; font-family: Arial; font-size: 10px; color: white">Category: ' + cut[1] + ' Item(s)</div>';
			DisplayLoading(false);
			}
		}
	CatHttp.open('GET', 'data.php?act=Cats&Random='+100*Math.random(), true);
	CatHttp.send(null);
}
//END load Cat------------------------------------------

//Load Singer List
function LoadSingerList(CatID)
{
	DisplayLoading(true);
	var SingerHttp=CreateRequest();
	if(SingerHttp == null)
	{
		alert('This Browse does not support HTTP. SingerHttp=null');
		return 0; //Exit function
	}
	SingerHttp.onreadystatechange= function ()
		{
			if(SingerHttp.readystate == 4 || SingerHttp.readystate == 'complete')
			{
			st=SingerHttp.ResponseText;
			cut=st.split('<||>');
			document.getElementById('SingerListBox').innerHTML = '<div style ="overflow-Y: auto; padding-left: 3px; padding-right: 3px; height: 420px">' + cut[0] +'</div><div style="height: 17px; padding-left: 3px; padding-top: 2px; background-color: #0076C2; font-family: Arial; font-size: 10px; color: white">' + cut[1] + ': ' + cut[2] + ' Item(s)</div>';
			DisplayLoading(false);
			}
		}
	SingerHttp.open('GET','data.php?act=Singer&CatID='+CatID+'&Random='+100*Math.random(),true);
	SingerHttp.send(null);
}
//END load singer list

//Load song list
function LoadSongList(SingerID)
{
	DisplayLoading(true);
	var SongHttp=CreateRequest();
	if(SongHttp == null)
	{
		alert('This Browse does not support HTTP. SongHttp=null');
		return 0; //Exit function
	}
	SongHttp.onreadystatechange= function ()
		{
			if(SongHttp.readystate == 4 || SongHttp.readystate == 'complete')
			{
			st=SongHttp.ResponseText;
			cut=st.split('<||>');
			document.getElementById('SongListBox').innerHTML ='<div  style ="overflow-Y: auto; height: 420px">' + cut[0] + '</div><div id="SongCountBox" style ="padding-top: 2px; padding-right: 5px; height: 17px; color: white; float: right; font-family: Arial; font-size: 10px; color: white">Total: ' + cut[2] + ' Item(s)</div>';
			document.getElementById('HeadListSongBox').innerHTML ='<a href="">' + cut[1] + '</a>';
			DisplayLoading(false);
			}
		}
	SongHttp.open('GET','data.php?act=SongList&SingerID='+SingerID+'&Random='+100*Math.random(),true);
	SongHttp.send(null);
}
//End load song list

//Load Script
var ArraySongID;
var ItemPlaying=0;
function LoadSongScript(SingerID)
{
	DisplayLoading(true);
	var ScriptHttp=CreateRequest();
	if(ScriptHttp == null)
	{
		alert('This Browse does not support HTTP. ScriptHttp=null');
		return 0; //Exit function
	}
	ScriptHttp.onreadystatechange= function ()
		{
			ArraySongID=new Array();
			ItemPlaying=0;
			if(ScriptHttp.readystate == 4 || ScriptHttp.readystate == 'complete')
			{
			eval(ScriptHttp.ResponseText);
			DisplayLoading(false);
			}
		}
	ScriptHttp.open('GET','data.php?act=SongScript&SingerID='+SingerID+'&Random='+100*Math.random(),true);
	ScriptHttp.send(null);
}
//END load Script

//Ham load song full
function LoadSongFull(SingerID)
{
	LoadSongList(SingerID);
	LoadSongScript(SingerID);
}
//Ham load Top Hit - 20 bai nghe nhieu nhat
function LoadTopHitList()
{
	DisplayLoading(true);
	var TopHitHttp=CreateRequest();
	if(TopHitHttp == null)
	{
		alert('This Browse does not support HTTP. TopHitHtt=null');
		return 0; //Exit function
	}
	TopHitHttp.onreadystatechange= function ()
		{
			if(TopHitHttp.readystate == 4 || TopHitHttp.readystate == 'complete')
			{
			st=TopHitHttp.ResponseText;
			cut=st.split('<||>');
			document.getElementById('SongListBox').innerHTML ='<div  style ="overflow: auto; height: 420px">' + cut[0] + '</div><div id="SongCountBox" style ="padding-top: 2px; padding-right: 5px; height: 17px; color: white; float: right; font-family: Arial; font-size: 10px; color: white">Total: ' + cut[2] + ' Item(s)</div>';
			document.getElementById('HeadListSongBox').innerHTML ='<a href="">' + cut[1] + '</a>';
			DisplayLoading(false);
			}
		}
	TopHitHttp.open('GET','data.php?act=TopHitList',true);
	TopHitHttp.send(null);
}
function LoadTopHitScript()
{
	DisplayLoading(true);
	var TopHitScriptHttp=CreateRequest();
	if(TopHitScriptHttp == null)
	{
		alert('This Browse does not support HTTP. TopHitScriptHttp=null');
		return 0; //Exit function
	}
	TopHitScriptHttp.onreadystatechange= function ()
		{
			ArraySongID=new Array();
			ItemPlaying=0;
			if(TopHitScriptHttp.readystate == 4 || TopHitScriptHttp.readystate == 'complete')
			{
			eval(TopHitScriptHttp.ResponseText);
			DisplayLoading(false);
			}
		}
	TopHitScriptHttp.open('GET','data.php?act=TopHitScript',true);	
	TopHitScriptHttp.send(null);
}
function LoadTopFull()
{
	LoadTopHitScript();
	LoadTopHitList();
}
LoadTopFull(); //Onload window
//Cac ham su li thong tin bai hat va choi bai hat
function ReplaceSpace(st)//Ham thay Space thanh _
{
	try
	{
		var x=st;
		for(i=0; i<=20; i++)
		{
			x=x.replace(' ','_');//Dit me cai ham replace cua java nhu cac ! lam ong phai dung ha sach nhu the nay
		}
	}
	catch(e){}
	return x;
}
//Ham choi nhac
function PlaySong(ID)
{
	DisplayLoading(true);
	if(PlayOne == false)
	{
		ItemPlaying=ID;
	}
	var SongInfoHttp=CreateRequest();
	if(SongInfoHttp == null)
	{
		alert('This Browse does not support HTTP. SongInfoHttp=null');
		return 0;
	}
		document.getElementById('media').controls.stop();
		if(PlayOne)
		{
			SongInfoHttp.open('GET','play.php?id='+ID,true);
			PlayOne=false;
		}
		else
		{
			SongInfoHttp.open('GET','play.php?id='+ArraySongID[ID]+'&Random='+100*Math.random(),true);
		}
		SongInfoHttp.onreadystatechange= function ()
			{
			if(SongInfoHttp.readystate == 4 || SongInfoHttp.readystate == 'complete')
			{
			var st=SongInfoHttp.ResponseText;
			var cut=st.split('<||>');
			document.getElementById('DownLoadBox').innerHTML ='<a target="_blank" href="download.php?id=' + cut[0] + '">Download</a>';
			document.getElementById('MiniSingerName').innerHTML = cut[1];
			document.getElementById('SongNameBox').innerHTML = cut[2];
			document.getElementById('media').URL=cut[3];
			document.getElementById('media').controls.play();
			top.location ='#id=' + cut[0] + '-' + ReplaceSpace(cut[2]) + '-' + ReplaceSpace(cut[1]);
			document.title ='sincos Media Player - ' + cut[2] + ' | ' + cut[1];
			DisplayLoading(false);
			}
			}
		SongInfoHttp.send(null);
}
function PlayNextSong()
{
var PlayMode=1;
	try
	{
		PlayMode=parseInt(document.control.GetVariable('modeplay'));
	}
	catch(e){}
	if(PlayMode == 2)
	{
		return 0;
	}
	if(ItemPlaying == 0)
	{
		return 0;
	}
	if(ItemPlaying == ArraySongID.length -1)
	{
		PlaySong(1);
		return 0;
	}
	PlaySong(ItemPlaying+1);
}
function PlayPreSong()
{
	var PlayMode=1;
	try
	{
		PlayMode=parseInt(document.control.GetVariable('modeplay'));
	}
	catch(e){}
	if(PlayMode == 2)
	{
		return 0;
	}
	if(ItemPlaying == 0)
	{
		return 0;
	}
	if(ItemPlaying == 1)
	{
		PlaySong(ArraySongID.length - 1);
		return 0;
	}
	PlaySong(ItemPlaying-1);
}
//Ham su li co link request play - truong hop khach vieng tham voi 1 duong dan dc gui tu nguoi khac
var PlayOne=false;//Bien danh dau
function CheckLocation()
{
	var link=window.location.hash;
	if(link.length < 4)
	{
		return 0;
	}
	link=parseInt(link.substr(4));
	if(link > 0)
	{
		PlayOne=true;
		PlaySong(link);
	}
}
CheckLocation();
//Ham Tim kiem bai hat
function SearchSong()
{
	alert('Xin lỗi phần này chưa hoàn thành');
}
//Load Counter
function LoadCounter()
{
	window.status = 'Load Counter';
	var CounterHttp=CreateRequest();
	CounterHttp.onreadystatechange = function ()
		{
			if(CounterHttp.readystate == 4 || CounterHttp.readystate == 'complete')
			{
				document.getElementById('OnlineBox').innerHTML = CounterHttp.ResponseText;
				window.status = 'Done';
			}
		}
	CounterHttp.open('GET','data.php?act=Counter&Random='+100*Math.random(), true);
	CounterHttp.send(null);
	setTimeout('LoadCounter();', 120000);
}
LoadCounter();
//Mot so ham su lu Form
function ResetValue(id)
{
	try
	{
		document.getElementById(id).value='';
	}
	catch(e) {}
}
function Disable(id, mode)
{
	try
	{
		document.getElementById(id).disabled=mode;
	}
	catch(e) {}
}
function GetValue(ID)
{
	try
	{
		return document.getElementById(ID).value;
	}
	catch(e)
	{
		return false;
	}
}
function URLencode(Name, Value)
{
	return Name + '=' + encodeURI(Value);
}
//POST FeedBack
function PostFeedBack()
{
	DisplayLoading(true);
	Disable('fbSubmit', true);
	var Value=URLencode('Name', GetValue('fbTextName')) + '&' + URLencode('Email', GetValue('fbTextEmail')) + '&' + URLencode('Content', GetValue('fbTextContent'));
	var fbHttp= CreateRequest();
	if(fbHttp == null)
	{
		alert('This browse does not support Method Http Request. Error at function PostFeedBack');
		return 0;
	}
	fbHttp.onreadystatechange = function ()
		{
			if(fbHttp.readystate == 4 || fbHttp.readystate == 'complete')
			{
				var Text= fbHttp.ResponseText;
				if(Text.substr(0, 5) != 'Error')
				{
					ResetValue('fbTextName');
					ResetValue('fbTextEmail');
					ResetValue('fbTextContent');
				}
				alert(Text);
				Disable('fbSubmit', false);
				DisplayLoading(false);
			}
		}
	fbHttp.open('POST', 'data.php?act=FeedBack&Random='+ 100*Math.random(), true);
	fbHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	fbHttp.setRequestHeader("Content-length", Value.length);
	fbHttp.setRequestHeader("Connection", "close");
	fbHttp.send(Value);
}
</script>
</BODY>
</HTML>

[=========> Bổ sung bài viết <=========]

Lọc ra. Có mấy cái thuộc tính điều khiển control của media đó.
bka viết 02:28 ngày 10/10/2018
tốt nhất là nên dùng flash ( chỉ hỗ trợ chơi mỗi mp3 nên cũng chán) can thiệp vào mấy cái control ấy. chứ code bác s.code Trên FF nó không bắt được mấy cái đó đâu.. may ra còn dùng mấy bảg control stop và play thui. nó không bắt lỗi các sự kiện và không lấy được thời gian. hồi bé hay dùng web nhạc mình cũng đã tìm hiểu rùi
s.code viết 02:32 ngày 10/10/2018
Được gửi bởi bka
hồi bé hay dùng web nhạc mình cũng đã tìm hiểu rùi
Gớm thật. Bé thế nào vậy. Mấy tuổi
conan1212 viết 02:31 ngày 10/10/2018
@bka mỗi lần thấy ông post bài lại nhớ lại cái thời ở KTX. Buồn vui lẫn lộn
bka viết 02:38 ngày 10/10/2018
Được gửi bởi conan1212
@bka mỗi lần thấy ông post bài lại nhớ lại cái thời ở KTX. Buồn vui lẫn lộn
trời ..
@conan1212 : sao nhìu cảm xúc vậy trời.. định bảo tui bỏ nghề chuyển sang viết văn àh
SweetLoveFC viết 02:35 ngày 10/10/2018
require_once("library.php");
require_once("config.php");
Sao bạn require cho người ta mà không cho người ta 2 file đó gì hết vậy . ^^
s.code viết 02:30 ngày 10/10/2018
Sory. Hôm sau mình cho cả bộ source. Nhưng báo trước chỉ chạy good trên IE thôi. FF thì ko dám chắc.
hackson viết 02:24 ngày 10/10/2018
Đau đầu FF thiệt .
s.code viết 02:35 ngày 10/10/2018
Đây:

http://xongngay.net/s.music.rar

Đó là bộ code mình viết hồi tập tành làm web (cách đây 3 năm). Test trên IE 6 còn bây giờ thế nào chả biết. Bác nào mang về mò dc chút nào hay chút đó. Không có tem bảo hành chất lượng đâu.
Bài liên quan
0