PDA

View Full Version : asx playlist loaded dynamically, but links won't work.



matheusgrafix
Feb 12th, 2011, 03:48 PM
I currently found a script that loads an ASX playlist dinamically, allowing the user to choose the item that he wants to watch in Windows media player embedded.
The trouble is that once the user click on the link in the playlist it wont work.
Take a look here http://tv.mghospedagem.com/wmp-pl3.html

Works only on IE.



<head>
<script language="javascript1.2">

playListLoaded=false;


function loadPlayItems() {
df=document.getElementById("playItem");
dp=document.getElementById("playlist");
WMP9=document.getElementById("MediaPlayer1");

WMP9.url="http://tv.mghospedagem.com/play.asx";
WMP9.controls.play();

}

function showPlayItems() {
WMP9=document.getElementById("MediaPlayer1");
playlistItems=WMP9.currentPlaylist.count;
for (i=0; i<playlistItems; i++) {
playitem=document.createElement("a");
playnext=document.createElement("br");
playitem.setAttribute("href","#");
playitem.setAttribute("onclick","playItem("+i+")");
playitem.innerText=WMP9.currentPlaylist.item(i).name;
dp.appendChild(playitem);
dp.appendChild(playnext);
}
playListLoaded=true;
WMP9.controls.play();

}



function setPlayItem(index) {
WMP9=document.getElementById("MediaPlayer1");
playlistItems=WMP9.currentPlaylist.count;
if (playlistItems > 0) {

WMP9.controls.currentItem=WMP9.currentPlaylist.item(index);
WMP9.controls.play();
}
}

</script></head>

<body onLoad="loadPlayItems()">
<object id="MediaPlayer1"
classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"
type="application/x-oleobject" width="600" height="400">
<param name="autostart" value="1">
<param name="showcontrols" value="1">
<param name="uimode" value="full">
<param name="stretchtofit" value="1">
<param name="enablecontextmenu" value="0">
</object>

<div id="playlist" style="position: absolute; top: 10px; left:
640px; visibility: visible; z-index: 999999999999999;">
<h2>Playlist</h2></div>

<script language="javascript1.2" for="MediaPlayer1"
event="playStateChange">
WMP9=document.getElementById("MediaPlayer1");
if (WMP9.playState==3 && ! playListLoaded) {
showPlayItems();
}






</script>