View Full Version : embed .pls

12-29-2010, 06:03 PM
Is it possible to embed a pls link in javascript?

I tried this but doesnt seem to work, what can i do?

function Play () {
var path = '<embed src="http://www.link.com/music.pls" autostart="true" loop="false" hidden="true" height="0" width="0">';
document.getElementById (file).innerHTML = path + '<img src="images/stop.gif" style="cursor:pointer;" onclick="Stop(' + "'" + file + "'" + ')">';
function Stop (file) {
document.getElementById (file).innerHTML = '<img src="images/play.gif" style="cursor:pointer;" onclick="Play(' + "'" + file + "'" + ')">';

12-29-2010, 07:42 PM
Think its impossible, but it should be possible to play .pls or .asx, any ideas?

rnd me
12-29-2010, 08:07 PM
you can use <audio> tags, or a an existing player like jPlayer.
you have to load the pls file with ajax, parse out the media locations, and build a playlist that feeds the audio player.

12-29-2010, 08:32 PM
thats what i cant find, a tutorial of even better an example to work off? not experienced in that

12-29-2010, 08:51 PM
Cross Browser Media Player with Select List and .wax Playlist

<title>Cross Browser Media Player with Select List and .wax Playlist</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">

// Local folder was used for testing
// Change to the media files path on your site, or local machine;
var mediaPath = "c:/Documents and Settings/ABC.SELF-C18DAAD6BD/Desktop/My Site/media/";

/* ********* Do not edit below this line ************* */

var mediaFileName = "";
var playerEmbedStr = '\<embed type="application\/x-mplayer2" width="325" height="52" showstatusbar="1" enablecontextmenu="false" src="mediaFileName"\>\<\/embed>';

function swapMedia(nSong,nContainer){

var activePlayerStr = playerEmbedStr.replace("mediaFileName", mediaPath + nSong);
nContainer.innerHTML = activePlayerStr;

function init(){

document.forms[0]['songList'].onchange = function()
if (this.value != "")

navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);

<style type="text/css">

body {background-color: #fffacd; margin-top: 60px;}
form {width: 350px; margin-left: auto; margin-right: auto; margin-top: 25px;}
select {width: 325px;}
#playerContainer {width: 350px; margin-left: auto; margin-right: auto;}

<div id="playerContainer">
<embed type="application/x-mplayer2" width="325" height="45">

<form action="">

<select name="songList">
<option value=""> Choose a Song </option>
<option value="play_list_1.wax"> Play All </option>
<option value="song1.mp3"> Don Henley - Heart of the Matter </option>
<option value="song2.mp3"> Jackson Browne - The Pretender </option>
<option value="song3.mp3"> Lucinda Williams - World Without Tears </option>



<asx version = "3.0">
<ref href = "c:/Documents and Settings/MJH.SELF-C18DAAD6BD/Desktop/My Site/media/song1.mp3"/>
<ref href = "c:/Documents and Settings/MJH.SELF-C18DAAD6BD/Desktop/My Site/media/song2.mp3"/>
<ref href = "c:/Documents and Settings/MJH.SELF-C18DAAD6BD/Desktop/My Site/media/song3.mp3"/>

12-29-2010, 09:19 PM
doesnt really work since you need the windows media plugin for other browsers. Im trying to play things like this: http://listen.di.fm/public3/trance.pls
in the browser?

rnd me
12-30-2010, 12:29 AM
doesnt really work since you need the windows media plugin for other browsers. Im trying to play things like this: http://listen.di.fm/public3/trance.pls
in the browser?

do you want the songs to play one at a time in the browser,
do you want to build a playlist that opens on a desktop player like itunes or winamp?

both are possible, but i'm not sure exactly what you want to do here...

checkout http://www.happyworm.com/jquery/jplayer/latest/demo-02.htm for an easy way to accomplish the first option.

12-30-2010, 08:50 AM
The first option is what im trying to accomplish. So like i click play and it plays http://listen.di.fm/public3/trance.pls

Looked at your first solution but I think that needs the songs and doesnt accept pls or asx