Link | serve_m3u |
Author | Jason Huck |
Category | File |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 29 Nov 2005 |
Updated | 16 Jan 2006 |
More by this author... |
Serves an m3u playlist from an array of maps. Each map should contain the following keys:
time - The length of the track, a string in the format H:M:S.
artist - The artist.
track_number - The track number.
track_title - The name of the track.
album_title - The name of the album.
url - An HTTP url where the track can be downloaded.
Note: The format of the EXTINF field is fairly loose. It's track time (any format), comma, description (any format). The format used here is one that works well for sorting in iTunes if the file isn't properly tagged. See the unofficial m3u specification for more info.
// create a playlist of 15 random songs from an SQLTunes database var('connection') = array( -username='xxxxxx', -password='xxxxxx', -database='music', -maxrecords='all' ); var('sql' = ' SELECT track_time, artist, track_number, title, album, location FROM itunes ORDER BY RAND() LIMIT 15 '); var('testData' = array); inline( $connection, -sql=$sql ); rows; $testData->insert( map( 'time' = field('track_time'), 'artist' = field('artist'), 'track_number' = field('track_number'), 'track_title' = field('title'), 'album_title' = field('album'), 'url' = field('location') ) ); /rows; /inline; serve_m3u($testData);
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag( 'm3u', -namespace='serve_', -priority='replace', -required='playlist', -type='array', -optional='filename', -type='string', -description='Serves an M3U playlist from an array of maps.' ); local('out' = '#EXTM3U\n'); iterate(#playlist, local('i')); #out += '#EXTINF:' + #i->find('time') + ',' + #i->find('artist') + ' - "' + #i->find('track_number') + ' ' + #i->find('track_title') + '"/' + #i->find('album_title') + '\n' + #i->find('url') + '\n'; /iterate; file_serve( #out, -file=(local_defined('filename') ? #filename | 'playlist.m3u'), -type='audio/mpegurl' ); /define_tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft