source: trunk/mediafolder/Skripte_eng/Create ~M3U playlist

Last change on this file was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 2.9 KB
Line 
1/* Create an *.m3u playlist from all selected tracks */
2
3/* Load Rexxutil functions */
4call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
5call SysLoadFuncs
6
7QC_FIRST=0
8QC_NEXT=1
9QC_LAST=2
10
11/* Check if we are executing */
12if ARG(1)\='/EXECUTE' THEN EXIT
13
14/* The media folder running this skript */
15mFldr=ARG(2)
16/* And the frame handle */
17frameHandle=ARG(3)
18
19/*Get the container handle */
20container=WPSWizCallWinFunc( "winQueryContainerHWND", frameHandle)
21
22if container=0 THEN DO
23 rc=RxMessageBox("Cannot get container handle!", "",'OK', "Information")
24 EXIT
25END
26
27pRec=WPSWizCallWinFunc( "winQueryContRecEmphasis", container, 16 , 1)
28
29a=0
30tracks.0=0
31DO 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
43END
44
45if tracks.0=0 THEN DO
46 rc=RxMessageBox("No audio tracks selected.", "Information",'OK')
47 EXIT
48END
49
50/* Try to find the desktop folder */
51
52/* Get the persistent object handle */
53hObject=WPSWizCallWinFunc( "winQueryObject" ,"<WP_DESKTOP>")
54
55if 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)
67END
68
69if desktop\='' THEN
70 desktop=desktop||'\new.m3u'
71
72filedlg:
73
74/* Get a name for the new folder from the user */
75theName=WPSWizCallWinFunc( "winFileDlg", 1, "Name for play list", desktop)
76
77/* No name, so quit */
78if thename="" THEN exit
79
80/* Check if an error occurred */
81if thename="ERROR:" THEN DO
82 rc=RxMessageBox("File dialog returned an error!", "Error",'OK', "ERROR")
83 EXIT
84END
85
86/* Check if file exists */
87IF 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")
90IF rc=7 then signal filedlg
91END
92
93/* Get the path */
94thePath=FILESPEC('drive', thename)||FILESPEC('path', thename)
95thePath=LEFT(thePath,LENGTH(thePath)-1)
96
97
98/* Now put names into the playlist file */
99DO a=1 to tracks.0
100 objName=MFldrCallFunc( "cwQueryRealName", tracks.a._obj, 1)
101call lineout thename, objname
102END
103
104call stream thename, 'C', 'close'
105
106/* Open the folder */
107rc=SysSetObjectData(theName, "OPEN=DEFAULT")
108
109rc=0
110
111exit
112
113
Note: See TracBrowser for help on using the repository browser.