reset and begin
7/06/2010

nghe nhạc đơn giản xml + php

file xml co tên data.xml<?xml version="1.0" encoding="iso-8859-1"?>
<music>
<song id="1" name="bai 1 " url="a.mp3" author="tac gia 1" ></song>
<song id="2" name="bai 2" url="b.mp3" author="tac gia 2" ></song>
<song id="3" name="bai 3" url="3.mp3" author="tac gia 3" ></song>
<song id="4" name="bai 4" url="4.mp3" author="tac gia 4" ></song>
<song id="5" name="bai 5" url="5.mp3" author="tac gia 5" ></song>

</music>

file index.php

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

</head>
<body>
<script type="text/javascript">
function loadnhac(obj) {
alert('ban dang nghe bai'+obj);
var flash;
var media=document.getElementById('media');
var browser=navigator.appName;
if(browser=="Microsoft Internet Explorer")
{ flash = '<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95″>';
flash += '<param name="src" value="' + obj+ '">';
flash += '<param name="autoStart" value="True"></object>';
media.innerHTML = flash;
}
else{
flash = '<embed type="video/x-ms-wmv" heigth="300px" width="230px" wmode="tranparent" src="' +obj + '"></embed>';
media.innerHTML = flash;
}
}
</script>



<div id="media">

</div>
</br>

<?php
$xmls= simplexml_load_file("data.xml");
$i=0;
for($i=0;$i<4;$i++){
$he=$xmls->song[$i]->attributes() ;
?>
<a onclick="loadnhac('<?php echo $he['url']; ?>')"><?php echo $he['name']; ?></a>
<?php
}

?>
</body>

Bloger Comments
G+ Comments
Comments FaceBook

No comments:

List

Profiles Information


About me : Nothing is 1 vài thứ - 1985

Places I've Lived : I Hà Nội

Home Page : http://www.shimivn.blogspot.com/

Think : 1:1000000000

Languages spoken : Vietnamese,English.

Mobile : sony C2305

dell : i3-Ram 3GB- HDD 250GB .