| 1 | /* rexx -  Parse the contents of an M3U file | 
|---|
| 2 | and insert for every trackname a CWAudioShadow | 
|---|
| 3 | in the given media folder. After doing that start | 
|---|
| 4 | playing. | 
|---|
| 5 |  | 
|---|
| 6 | This script is part of the media folder package. | 
|---|
| 7 |  | 
|---|
| 8 | (c) Chris Wohlgemuth 2002-2003 | 
|---|
| 9 |  | 
|---|
| 10 | http://www.os2world.com/cdwriting | 
|---|
| 11 | http://www.geocities.com/SiliconValley/Sector/5785/ | 
|---|
| 12 |  | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' | 
|---|
| 16 | call SysLoadFuncs | 
|---|
| 17 |  | 
|---|
| 18 |  | 
|---|
| 19 | theFilepath=ARG(1) | 
|---|
| 20 | theFolderPath=ARG(2) | 
|---|
| 21 |  | 
|---|
| 22 | a=0 | 
|---|
| 23 | DO WHILE lines(theFilePath) | 
|---|
| 24 | theLine=STRIP(LINEIN(theFilePath)) | 
|---|
| 25 | if checkTheLine()=1 THEN DO | 
|---|
| 26 | a=a+1 | 
|---|
| 27 | theTracks.a._name=theLine | 
|---|
| 28 | END | 
|---|
| 29 | END | 
|---|
| 30 | theTracks.0=a | 
|---|
| 31 | call stream thefilepath, 'C','close' | 
|---|
| 32 |  | 
|---|
| 33 | DO a=theTracks.0 to 1 by -1 | 
|---|
| 34 | rc=SysCreateObject(CWAudioShadow, " ", theFolderPath,"SHADOWID="theTracks.a._name) | 
|---|
| 35 | END | 
|---|
| 36 | rc=SysSetObjectData(theFolderPath,"MEDIAFLDRPLAYFIRST=1") | 
|---|
| 37 |  | 
|---|
| 38 | rc=0 | 
|---|
| 39 | EXIT | 
|---|
| 40 |  | 
|---|
| 41 |  | 
|---|
| 42 | checkTheLine: | 
|---|
| 43 |  | 
|---|
| 44 | if LENGTH(theLine)=0 then | 
|---|
| 45 | return 0; /* Empty line */ | 
|---|
| 46 |  | 
|---|
| 47 | if SUBSTR(theLine, 1, 1)='#' then | 
|---|
| 48 | return 0; /* Comment */ | 
|---|
| 49 |  | 
|---|
| 50 | if SUBSTR(theLine, 2, 1)\=':' THEN DO | 
|---|
| 51 | /* relative path. Prepend path of M3U file */ | 
|---|
| 52 | if SUBSTR(theLine, 1, 1)\='\' &  SUBSTR(theLine, 1, 1)\='/' THEN DO | 
|---|
| 53 | theLine=FILESPEC('drive', theFilePath)||FILESPEC('path', theFilePath)||theLine | 
|---|
| 54 | END | 
|---|
| 55 | ELSE | 
|---|
| 56 | theLine=FILESPEC('drive', theFilePath)||FILESPEC('path', theFilePath)||SUBSTR(theLine,2) | 
|---|
| 57 |  | 
|---|
| 58 | END | 
|---|
| 59 | /* Rockbox for the ArchosJukebox uses '/' as path separators in M3U lists. | 
|---|
| 60 | Change them to backslashes */ | 
|---|
| 61 | theLine=TRANSLATE(theLine, '\', '/') | 
|---|
| 62 | return 1; | 
|---|
| 63 |  | 
|---|
| 64 |  | 
|---|