| 1 | /* Create an *.m3u playlist from all selected tracks */
|
|---|
| 2 |
|
|---|
| 3 | /* Load Rexxutil functions */
|
|---|
| 4 | call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
|
|---|
| 5 | call SysLoadFuncs
|
|---|
| 6 |
|
|---|
| 7 | QC_FIRST=0
|
|---|
| 8 | QC_NEXT=1
|
|---|
| 9 | QC_LAST=2
|
|---|
| 10 |
|
|---|
| 11 | /* Check if we are executing */
|
|---|
| 12 | if ARG(1)\='/EXECUTE' THEN EXIT
|
|---|
| 13 |
|
|---|
| 14 | /* The media folder running this skript */
|
|---|
| 15 | mFldr=ARG(2)
|
|---|
| 16 | /* And the frame handle */
|
|---|
| 17 | frameHandle=ARG(3)
|
|---|
| 18 |
|
|---|
| 19 | /*Get the container handle */
|
|---|
| 20 | container=WPSWizCallWinFunc( "winQueryContainerHWND", frameHandle)
|
|---|
| 21 |
|
|---|
| 22 | if container=0 THEN DO
|
|---|
| 23 | rc=RxMessageBox("Cannot get container handle!", "",'OK', "Information")
|
|---|
| 24 | EXIT
|
|---|
| 25 | END
|
|---|
| 26 |
|
|---|
| 27 | pRec=WPSWizCallWinFunc( "winQueryContRecEmphasis", container, 16 , 1)
|
|---|
| 28 |
|
|---|
| 29 | a=0
|
|---|
| 30 | tracks.0=0
|
|---|
| 31 | DO WHILE (pRec\=0 & pRec\=-1)
|
|---|
| 32 | /* Get object pointer */
|
|---|
| 33 | obj=WPSWizCallWinFunc( "winObjectFromPRec", pRec)
|
|---|
| 34 | /* Follow shadows to file system object */
|
|---|
| 35 | obj=MFldrCallFunc( "cwGetFileSystemObject", mFldr, obj)
|
|---|
| 36 | /* Check if it's an audio object */
|
|---|
| 37 | IF MFldrCallFunc( "cwIsA", obj, "CWAudio")\=0 THEN DO
|
|---|
| 38 | a=a+1
|
|---|
| 39 | tracks.a._obj=obj
|
|---|
| 40 | END
|
|---|
| 41 | pRec=WPSWizCallWinFunc( "winQueryContRecEmphasis", container, pRec , 1)
|
|---|
| 42 | tracks.0=a
|
|---|
| 43 | END
|
|---|
| 44 |
|
|---|
| 45 | if tracks.0=0 THEN DO
|
|---|
| 46 | rc=RxMessageBox("No audio tracks selected.", "Information",'OK')
|
|---|
| 47 | EXIT
|
|---|
| 48 | END
|
|---|
| 49 |
|
|---|
| 50 | /* Try to find the desktop folder */
|
|---|
| 51 |
|
|---|
| 52 | /* Get the persistent object handle */
|
|---|
| 53 | hObject=WPSWizCallWinFunc( "winQueryObject" ,"<WP_DESKTOP>")
|
|---|
| 54 |
|
|---|
| 55 | if hObject\=0 THEN DO
|
|---|
| 56 | /* Get the class object of the given object pointer */
|
|---|
| 57 | classObject=WPSWizCallWPSFunc("somGetClass",mFldr)
|
|---|
| 58 |
|
|---|
| 59 | /* Get the object pointer from the handle */
|
|---|
| 60 | theObject=WPSWizCallWPSClsFunc("wpclsQueryObject", classObject, hObject)
|
|---|
| 61 |
|
|---|
| 62 | /* Query the full path of the object */
|
|---|
| 63 | desktop=WPSWizCallFunc("cwQueryRealName", theObject, 1)
|
|---|
| 64 |
|
|---|
| 65 | /* The object was locked because of "wpclsQueryObject" */
|
|---|
| 66 | rc=WPSWizCallWPSFunc("wpUnlockObject", theObject)
|
|---|
| 67 | END
|
|---|
| 68 |
|
|---|
| 69 | if desktop\='' THEN
|
|---|
| 70 | desktop=desktop||'\new.m3u'
|
|---|
| 71 |
|
|---|
| 72 | filedlg:
|
|---|
| 73 |
|
|---|
| 74 | /* Get a name for the new folder from the user */
|
|---|
| 75 | theName=WPSWizCallWinFunc( "winFileDlg", 1, "Name for play list", desktop)
|
|---|
| 76 |
|
|---|
| 77 | /* No name, so quit */
|
|---|
| 78 | if thename="" THEN exit
|
|---|
| 79 |
|
|---|
| 80 | /* Check if an error occurred */
|
|---|
| 81 | if thename="ERROR:" THEN DO
|
|---|
| 82 | rc=RxMessageBox("File dialog returned an error!", "Error",'OK', "ERROR")
|
|---|
| 83 | EXIT
|
|---|
| 84 | END
|
|---|
| 85 |
|
|---|
| 86 | /* Check if file exists */
|
|---|
| 87 | IF STREAM(theName, 'C', 'query exists')=theName THEN DO
|
|---|
| 88 |
|
|---|
| 89 | rc=RxMessageBox("The file already exists. Do you want to add the selected tracks to the contents?", "Create *.M3U playlist",'YESNO', "QUESTION")
|
|---|
| 90 | IF rc=7 then signal filedlg
|
|---|
| 91 | END
|
|---|
| 92 |
|
|---|
| 93 | /* Get the path */
|
|---|
| 94 | thePath=FILESPEC('drive', thename)||FILESPEC('path', thename)
|
|---|
| 95 | thePath=LEFT(thePath,LENGTH(thePath)-1)
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | /* Now put names into the playlist file */
|
|---|
| 99 | DO a=1 to tracks.0
|
|---|
| 100 | objName=MFldrCallFunc( "cwQueryRealName", tracks.a._obj, 1)
|
|---|
| 101 | call lineout thename, objname
|
|---|
| 102 | END
|
|---|
| 103 |
|
|---|
| 104 | call stream thename, 'C', 'close'
|
|---|
| 105 |
|
|---|
| 106 | /* Open the folder */
|
|---|
| 107 | rc=SysSetObjectData(theName, "OPEN=DEFAULT")
|
|---|
| 108 |
|
|---|
| 109 | rc=0
|
|---|
| 110 |
|
|---|
| 111 | exit
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|