Advanced Stream Redirector

The educational technology and digital learning wiki
Revision as of 13:00, 30 December 2009 by Daniel K. Schneider (talk | contribs)
Jump to navigation Jump to search

Introduction

Advanced Stream Redirector (ASX) files are based on the Extensible Markup Language (XML) syntax, and are made up of various elements with their associated tags and attributes. Each element in an ASX file defines a particular setting or action to the Microsoft Windows Media Player control. Some elements must be located in a specific position in the file relative to other elements. Some elements have required tags and attributes that must be defined in the ASX file.

Important: Element names and attributes are not case-sensitive.

Media Player playlists

ASX may be used to print playlist. It was a huge surprise to me that I couldn't just print a playlist in Windows Vista. To do so, one must either install alternative "music management programs" (and risk pollution or worse) or export Media Player playlists to *.asx format and then transform the contents with XSLT.

Here is a how to:

(0) Install an XSLT processor, e.g. saxon

(1) Export with: Menu File-> Save current playlist

(2) Write the xsl. Open the *.asx files an look at the tags. Here is my working version (Vista)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:output method="html"
     doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>

<xsl:template match="Asx">
  <html>
    <head>
      <title> <xsl:value-of select="Title"/></title>
      <style type="text/css">
        body {font-family:Cambria; font-size:8px; margin-left:1cm; margin-right:0cm;}
	table {border-style: dotted;}
	td {border-bottom: dotted;}
	td {border-right: dotted;}
	th {text-align:left}
      </style>
    </head>
    <body>
      <h1><xsl:value-of select="Title"/></h1>

      <table>
	<tr>
	  <th>No</th>
	  <th>Title</th>
	  <th>Artist<br/>(Album)</th>
	  <th>Artist</th>
	  <th>Album Title</th>
	  <th>Year</th>
	  <th>Duration</th>
	</tr>
	<xsl:apply-templates select="Entry"/>
      </table>

    </body>
  </html>

</xsl:template>

<xsl:template match="Entry">
  <tr>
    <td><xsl:value-of select="position()"/></td>
    <td><xsl:value-of select="Title"/></td>
    <td><xsl:value-of select="Param[@Name='DisplayArtist']/@Value"/></td>
    <td><xsl:value-of select="Author"/></td>
    <td><xsl:value-of select="Param[@Name='WM/AlbumTitle']/@Value"/></td>
    <td><xsl:value-of select="Param[@Name='ReleaseDateYear']/@Value"/></td>
    <!-- <td><xsl:value-of select="substring-after(Duration/@value,'00:')"/></td> -->
    <td><xsl:value-of select="substring(Duration/@value,4,5)"/></td>
  </tr>
</xsl:template>
  
</xsl:stylesheet>

(3) You finally may write a batch file to produce HTML files. E.g.

@ECHO OFF
REM Check there is a parameter
IF "%1" == "" GOTO MISSING_PARAMETERS
:START
SET file=%1
IF NOT EXIST %file%.asx GOTO MISSING_FILE
:MAIN
ECHO Creating HTML...
java -jar c:\soft\saxon\saxon9.jar %file%.asx c:\bin\asx2html.xsl > %file%.html
ECHO Done
GOTO END
:MISSING_PARAMETERS
ECHO Usage: "asx2html myplaylist" to process "myplaylist.asx" and create "myplaylist.html"
GOTO END
:MISSING_FILE
ECHO Error: '%file%.asx' not found
GOTO END
:END
@ECHO ON