/    Sign up×
Community /Pin to ProfileBookmark

PHP….Dynamic asx file

Hello,
I wish to create a dynamic asx file which lists all the mp3 files in a directory…
This is then used in a html file as the source of an “<embed>” tag…
The html file does not open the asx playlist at all and I dont know what the problem is…. I have altered my http.conf file to add .asx as a php extension..
Here is the content of my asx files
Thanks

[code=php]<?php
header(“Content-Type: video/x-ms-asf;”);

// setting the directory to search for mp3 files

// reading the directory and inserting the mp3 files in the playlist array
$playlist = array();
$fdir = scandir(‘.’);
foreach($fdir as $i){

// if a .mp3 string is found, add the file to the array

if (strpos(strtolower($i),”.mp3″) !== false){
$playlist[] = $i;}

#sort() or shuffle()

}

echo “<asx version=”3.0″>”;
foreach($playlist as $i){
echo “<ENTRY>n”;
echo “<REF HREF=http://localhost/music/”.$i.” />n”;
echo “</ENTRY>nn”;
}
echo “</asx>”

?>

[/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@OctoberWindMay 25.2011 — try properly escaping your version number:

[code=php]<?php echo "<asx version="3.0">"; [/code]

should probably be:

[code=php]<?php echo "<asx version="3.0">"; [/code]

does the .asx file open in a browser by itself? ie. as the raw XML content?
Copy linkTweet thisAlerts:
@brian8765authorMay 25.2011 — it opens with a "cannot play" error

It still doesnt work with : echo "<asp version='3.0'>" ...
Copy linkTweet thisAlerts:
@criterion9May 25.2011 — You also having the same quoting problem here:

echo "<REF HREF=http://localhost/music/".$i." />n";
[/quote]
Copy linkTweet thisAlerts:
@brian8765authorMay 25.2011 — i cannot see anything wrong with it... The extra quotes is me joining a string to a variable to another string
Copy linkTweet thisAlerts:
@criterion9May 25.2011 — I'm not 100% sure...but it is usually good practice to enclose attributes with quotes.

As in:
[code=php]
echo "<REF HREF="http://localhost/music/".$i."" />n";
[/code]


Have you taken a look at what the raw output of your script is?
×

Success!

Help @brian8765 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...