source: titan/plugins/mc/mc_pictureplayer.h @ 16354

Last change on this file since 16354 was 16354, checked in by obi, 12 years ago

fix mc

File size: 11.9 KB
Line 
1#ifndef MC_PICTUREPLAYER_H
2#define MC_PICTUREPLAYER_H
3
4extern struct skin* skin;
5extern struct screensaver* screensaver;
6
7void screenmc_pictureplayer()
8{
9        char* filename = NULL;
10        char* currentdirectory = NULL;
11        int nextpic = 0, rcret = 0, rcwait = 1000, playerret = 0, flag = 3, skip = 0, eof = 0, playinfobarcount = 0, playinfobarstatus = 1, tmpview = 0, playlist = 0, playertype = 0;
12        // workaround for grey background mvi
13        struct skin* blackscreen = getscreen("blackscreen");
14        drawscreen(blackscreen, 0);
15
16        // main screen
17        struct skin* apskin = getscreen("mc_pictureplayer");
18        struct skin* filelistpath = getscreennode(apskin, "filelistpath");
19        struct skin* filelist = getscreennode(apskin, "filelist");
20        struct skin* listbox = getscreennode(apskin, "listbox");
21        struct skin* b2 = getscreennode(apskin, "b2");
22        struct skin* b3 = getscreennode(apskin, "b3");
23        struct skin* b4 = getscreennode(apskin, "b4");
24
25        // pic screen
26        struct skin* picscreen = getscreen("picscreen");
27        struct skin* picture = getscreennode(picscreen, "picture");
28        struct skin* picname = getscreennode(picscreen, "picname");
29
30        currentdirectory = ostrcat(currentdirectory, getconfig("mc_pp_path", NULL), 1, 0);
31
32        // enable listbox and set hidden
33        listbox->aktpage = -1;
34        listbox->aktline = 0;
35        listbox->hidden = YES;
36
37        // read configs
38        int view = getconfigint("mc_pp_view", NULL);
39        char* sound = getconfig("mc_pp_sound", NULL);
40
41        // set allowed filemask
42        char* filemask = "*.jpg *.png";
43       
44        // disable global transparent/hangtime
45        setfbtransparent(255);
46        status.hangtime = 99999;
47        status.playspeed = 0, status.play = 0, status.pause = 0, status.random = 0;
48
49        debug(50, "start screenmc_pictureplayer view=%d", view);
50
51        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
52
53        if(getconfigint("screensaver", NULL) == 1)
54                initscreensaver();
55
56        tmpview = view;
57        mc_changeview(view, filelist);
58        getfilelist(apskin, filelistpath, filelist, currentdirectory, filemask, tmpview, NULL);
59        addscreenrc(apskin, filelist);
60
61        // start radio musik on pictureplayer
62        char* track = NULL;
63        track = ostrcat(track, sound, 1, 0);
64
65        if(ostrcmp(sound, "off") != 0){
66                playerret = playerstart(track);
67                playwritevfd(track);
68
69                #ifndef SIMULATE
70                        if(playerret != 0)
71                        {
72                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
73                                playerstop();
74                                playerret = 0;
75                        }
76                #endif
77        }
78       
79        while(1)
80        {
81                rcret = waitrc(apskin, rcwait, 0);
82                debug(50, "while status play=%d", status.play);
83                nextpic = 0;
84                if(playinfobarcount < getconfigint("mc_pp_interval", NULL) && status.play == 1)
85                        playinfobarcount ++;
86                else if(status.play == 1)
87                {
88//                      picplayer(picscreen, picture, picname, NULL, 0);       
89                        nextpic = 1;
90                }
91
92                if(rcret == getrcconfigint("rcplay", NULL))
93                {
94                        if((status.play == 1) || (status.playspeed != 0))
95                                playrcplay(filename, &playinfobarstatus, &playinfobarcount, playertype, flag);
96                }
97                else if(rcret == getrcconfigint("rcpause", NULL))
98                {
99                        if((status.play == 1) || (status.pause == 1))
100                                playrcpause(filename, &playinfobarstatus, &playinfobarcount, playertype, flag);
101                }
102                else if((rcret == getrcconfigint("rcchdown", NULL)) || (rcret == getrcconfigint("rcprev", NULL)))
103                {
104                        if(status.play == 1)
105                                eof = 1;
106                }
107                else if((rcret == getrcconfigint("rcchup", NULL)) || (rcret == getrcconfigint("rcnext", NULL)))
108                {
109                        if(status.play == 1)
110                                eof = 2;
111                }
112                else if(rcret == getrcconfigint("rcblue", NULL))
113                {
114                        if(status.repeat == 0)
115                        {
116                                changetext(b4, _("Repeat-On"));
117                                drawscreen(apskin, 0);
118                                status.repeat = 1;
119                        }
120                        else
121                        {
122                                status.repeat = 0;
123                                changetext(b4, _("Repeat"));
124                                drawscreen(apskin, 0);
125                        }
126                }
127                else if(rcret == getrcconfigint("rcyellow", NULL))
128                {
129                        playerrandom(apskin, filelist, listbox, b3, playlist, flag);
130                }
131                else if(rcret == getrcconfigint("rcred", NULL))
132                {
133                        if(status.play == 1)
134                                playrcred(filename, playinfobarstatus, playertype, flag);
135                        else
136                        {
137                                if(playlist == 0)
138                                {
139                                        int sort = screenmc_sort();
140                                        debug(50, "rcred: tmpsort=%d", sort);
141                                        addconfiginttmp("dirsort", sort);
142
143                                        mc_changeview(view, filelist);
144                                        delownerrc(apskin);
145                                        getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->text);
146                                        addscreenrc(apskin, filelist);
147                                        drawscreen(apskin, 0);
148                                }
149                        }
150                }
151                else if(rcret == getrcconfigint("rcgreen", NULL))
152                {
153                        if(status.play == 1)
154                                playrcgreen(filename, playinfobarstatus, playertype, flag);
155                        else
156                        {
157                                showplaylist(apskin, filelistpath, filelist, listbox, b2, 0, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
158                                drawscreen(apskin, 0);
159                        }
160
161                }
162                else if(rcret == getrcconfigint("rctext", NULL))
163                {               
164                        if(status.play == 1)
165                                playrctext(filename, playinfobarstatus, playertype, flag);     
166                }
167                else if(rcret == getrcconfigint("rcmenu", NULL))
168                {
169                        if(status.play == 0 && status.pause == 0)
170                        {
171                                debug(50, "rcmenu: settings");
172
173                                view = getconfigint("mc_pp_view", NULL);
174                                screenmc_pictureplayer_settings();
175                                if(view != getconfigint("mc_pp_view", NULL))
176                                {
177                                        printf("view changed > change tmpview\n");
178                                        tmpview = getconfigint("mc_pp_view", NULL);
179                                }
180
181                                sound = getconfig("mc_pp_sound", NULL);
182
183                                // start radio musik on pictureplayer
184                                playerstop();
185                                free(track), track = NULL;
186                                track = ostrcat("", sound, 0, 0);
187
188                                if(ostrcmp(sound, "off") != 0){
189                                        playerret = playerstart(track);
190                                        playwritevfd(filename);
191
192                                        #ifndef SIMULATE
193                                                if(playerret != 0)
194                                                        textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
195                                        #endif
196                                }
197                                else
198                                        playerstop();
199
200                                mc_changeview(tmpview, filelist);
201
202                                delownerrc(apskin);     
203                                getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->text);
204                                addscreenrc(apskin, filelist);
205
206                                drawscreen(apskin, 0);
207                        }
208                }
209                else if(rcret == getrcconfigint("rcstop", NULL))
210                {
211                        debug(50, "rcstop: stopplayback");
212
213                        picplayer(picscreen, picture, picname, NULL, 0);
214                        clearscreen(picscreen);
215                        eof = 0;
216
217                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
218       
219                        apskin->hidden = NO;
220                        filelist->hidden = NO;
221                        listbox->hidden = YES;
222                        changetext(filelistpath, _(getconfig("mc_pp_path", NULL)));
223                        changetext(b2, _("Filelist-Mode"));
224
225                        // switch filelist
226                        delownerrc(apskin);
227                        addscreenrc(apskin, filelist);
228                        setfbtransparent(255);
229                        drawscreen(apskin, 0);
230
231                        sleep(1);
232
233                        playinfobarcount = 0;
234                        playinfobarstatus = 1;
235                        status.playspeed = 0;
236                        status.pause = 0;
237                        status.play = 0;
238                        playlist = 0;
239                        playinfobarcount = 0;
240                        writevfd("pictureplayer Filelist-Mode");
241                }
242                else if(rcret == getrcconfigint("rcexit", NULL))
243                {
244                        debug(50, "exit - save mc_pp_path: %s", filelistpath->text);
245                        if(playlist == 0)
246                        {
247                                if(ostrcmp(getconfig("mc_pp_path", NULL), filelistpath->text) != 0)
248                                        addconfig("mc_pp_path", filelistpath->text);
249                        }
250
251                        playerstop();
252                        picplayer(picscreen, picture, picname, NULL, 0);
253
254                        eof = 0;
255
256                        setfbtransparent(255);
257                        sleep(1);
258                        apskin->hidden = NO;
259                        filelist->hidden = NO;
260                        listbox->hidden = YES;
261                        changetext(b2, _("Filelist-Mode"));
262                        changetext(b3, _("Random"));
263                        changetext(b4, _("Repeat"));                                                                           
264                        status.playspeed = 0;
265                        status.pause = 0;
266                        status.play = 0;
267                        status.random = 0;
268                        status.repeat = 0;
269                        playlist = 0;
270                        writevfd("Mediacenter");
271                        playinfobarcount = 0;
272
273                        printf("exit: view=%d tmpview=%d\n", view, tmpview);                   
274                        status.filelistextend = 0;
275                        break;
276                }
277                else if(rcret == getrcconfigint("rcok", NULL))
278                {
279                        if(playlist == 1 && listbox->select != NULL)
280                        {
281                                filename = ostrcat("", listbox->select->name, 0, 0);
282
283                                changetext(b2, _("Playlist-Mode"));
284                       
285                                debug(50, "screensaver title: %s", listbox->select->text);
286                                if(screensaver != NULL && screensaver->type == 0)
287                                        screensaver->value = listbox->select->text;
288
289                                debug(50, "playerstop");
290                                playerstop();
291
292                                debug(50, "playerstart: %s", filename);
293                                eof = 0;
294
295                                delownerrc(apskin);
296                                setfbtransparent(255);
297
298                                if(ostrcmp(sound, "off") != 0){
299                                        playerret = playerstart(filename);
300                                        playwritevfd(filename);
301
302                                        #ifndef SIMULATE
303                                                if(playerret != 0)
304                                                {
305                                                        writevfd("pictureplayer Filelist-Mode");
306                                                        status.play = 0;
307                                                        playlist = 0;
308                                                        status.playspeed = 0;
309                                                        textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
310
311                                                        changetext(filelistpath, _(getconfig("mc_pp_path", NULL)));
312                                                        filelist->hidden = NO;
313                                                        listbox->hidden = YES;
314       
315                                                        addscreenrc(apskin, filelist);
316                                                        drawscreen(apskin, 0);
317                                                        continue;
318                                                }
319                                        #endif
320                                }
321
322                                screenplayinfobar(filename, 0, playertype, 0);                 
323                                status.play = 1;
324                        }
325                        else if(filelist->select != NULL && filelist->select->input != NULL)
326                        {
327                                // workaround dont open folder on rcchup
328                                if(skip == 1)
329                                {
330                                        drawscreen(apskin, 0);
331                                        writerc(getrcconfigint("rcok", NULL));
332                                        skip = 0;
333                                }
334                                else
335                                {
336                                        debug(50, "mc_mounter_chk start");
337                                        mc_mounter_chk(filelistpath);
338                                        debug(50, "mc_mounter_chk done");
339                                }
340                        }
341                        else if(filelist->select != NULL && filelist->select->input == NULL)
342                        {
343                                if(ostrcmp(getconfig("mc_pp_path", NULL), filelistpath->text) != 0)
344                                        addconfig("mc_pp_path", filelistpath->text);
345
346                                debug(50, "filelist->select->text: %s", filelist->select->text);
347                                filename = createpath(filelistpath->text, filelist->select->text);
348
349                                if(!strncmp(".rar",filename+strlen(filename)-4,4) || !strncmp(".iso",filename+strlen(filename)-4,4) || !strncmp(".img",filename+strlen(filename)-4,4))
350                                {
351                                        debug(50, "mc_mounter_main filename: %s", filename);
352                                        //addconfig("mc_pp_path", filelistpath->text);
353                                        currentdirectory = ostrcat("", getconfig("mc_pp_path", NULL), 0, 0);
354
355                                        mc_mounter_main(0,filename,filelistpath,filelist,apskin,filemask,tmpview,currentdirectory);
356                                        debug(50, "mc_mounter_main done");
357       
358                                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
359                                        continue;
360                                }
361                                else if(!strncmp(".m3u",filename+strlen(filename)-4,4) || !strncmp(".pls",filename+strlen(filename)-4,4))
362                                {
363                                        showplaylist(apskin, filelistpath, filelist, listbox, b2, 1, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
364                                        continue;
365                                }
366
367                                changetext(b2, _("Filelist-Mode"));
368                       
369                                if(screensaver != NULL && screensaver->type == 0)
370                                        screensaver->value = (void*)filelist->select->text;
371
372                                delownerrc(apskin);
373//                              setfbtransparent(255);
374
375                                debug(50, "playerstart: %s", filename);
376                                eof = 0;
377
378                                playinfobarcount = 0, playinfobarstatus = 1;
379                                picplayer(picscreen, picture, picname, filename, 1);
380                                servicestop(status.aktservice, 1, 1);
381
382                                status.play = 1;
383                        }
384                }
385               
386                if(playerisplaying() == 0)
387                {
388                        playerstop();
389
390                        if(ostrcmp(sound, "off") != 0){
391                                playerret = playerstart(track);
392                                playwritevfd(filename);
393
394                                #ifndef SIMULATE
395                                        if(playerret != 0)
396                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
397                                #endif
398                        }
399                }
400
401                if((eof >= 1) || (nextpic == 1))
402                {
403                        if(status.play == 1)
404                        {
405//                              setfbtransparent(0);
406//                              apskin->hidden = NO;
407//                              drawscreen(skin, 0);
408                                playereof(apskin, filelist, listbox, filelistpath, picscreen, picture, picname, b2, &skip, &eof, &playlist, playertype, flag);
409                        }
410                }
411        }
412
413        deinitscreensaver();
414        status.hangtime = getconfigint("hangtime", NULL);
415        delconfigtmp("dirsort");
416
417        delmarkedscreennodes(apskin, FILELISTDELMARK);
418        delownerrc(apskin);
419        clearscreen(apskin);
420        clearscreen(picscreen);
421
422        free(track), track = NULL;
423        free(filename), filename = NULL;
424        free(currentdirectory), currentdirectory = NULL;
425
426        writevfd("Mediacenter");
427        debug(50, "closed");
428}
429
430#endif
Note: See TracBrowser for help on using the repository browser.