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

Last change on this file since 15243 was 15243, checked in by obi, 11 years ago

[titan] update grid fix changing view modes

File size: 12.1 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, "mc_filelistpath");
19        struct skin* filelist = getscreennode(apskin, "mc_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_pictureplayerpath", 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 style = getconfigint("style", NULL);
39        int view = getconfigint("view", NULL);
40        char* sound = getconfig("sound", NULL);
41
42        // set allowed filemask
43        char* filemask = "*.jpg *.png";
44       
45        // disable global transparent/hangtime
46        setfbtransparent(255);
47        status.hangtime = 99999;
48        status.playspeed = 0, status.play = 0, status.pause = 0, status.random = 0;
49
50        debug(50, "start screenmc_pictureplayer style=%d, view=%d", style, view);
51
52        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
53
54        if(getconfigint("screensaver", NULL) == 1)
55                initscreensaver();
56
57//      mc_changeview(view, filelist);
58        tmpview = view;
59
60        getfilelist(apskin, filelistpath, filelist, currentdirectory, filemask, tmpview, NULL);
61        mc_changeview(view, filelist);
62        addscreenrc(apskin, filelist);
63
64        // start radio musik on pictureplayer
65        char* track = NULL;
66        track = ostrcat(track, sound, 1, 0);
67
68        if(ostrcmp(sound, "off") != 0){
69                playerret = playerstart(track);
70                playwritevfd(track);
71
72                #ifndef SIMULATE
73                        if(playerret != 0)
74                        {
75                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
76                                playerstop();
77                                playerret = 0;
78                        }
79                #endif
80        }
81       
82        while(1)
83        {
84                rcret = waitrc(apskin, rcwait, 0);
85                debug(50, "while status play=%d", status.play);
86                nextpic = 0;
87                if(playinfobarcount < getconfigint("pp_interval", NULL) && status.play == 1)
88                        playinfobarcount ++;
89                else if(status.play == 1)
90                {
91//                      picplayer(picscreen, picture, picname, NULL, 0);       
92                        nextpic = 1;
93                }
94
95                if(rcret == getrcconfigint("rcplay", NULL))
96                {
97                        if((status.play == 1) || (status.playspeed != 0))
98                                playrcplay(filename, &playinfobarstatus, &playinfobarcount, playertype, flag);
99                }
100                else if(rcret == getrcconfigint("rcpause", NULL))
101                {
102                        if((status.play == 1) || (status.pause == 1))
103                                playrcpause(filename, &playinfobarstatus, &playinfobarcount, playertype, flag);
104                }
105                else if((rcret == getrcconfigint("rcchdown", NULL)) || (rcret == getrcconfigint("rcprev", NULL)))
106                {
107                        if(status.play == 1)
108                                eof = 1;
109                }
110                else if((rcret == getrcconfigint("rcchup", NULL)) || (rcret == getrcconfigint("rcnext", NULL)))
111                {
112                        if(status.play == 1)
113                                eof = 2;
114                }
115                else if(rcret == getrcconfigint("rcblue", NULL))
116                {
117                        if(status.repeat == 0)
118                        {
119                                changetext(b4, _("Repeat-On"));
120                                drawscreen(apskin, 0);
121                                status.repeat = 1;
122                        }
123                        else
124                        {
125                                status.repeat = 0;
126                                changetext(b4, _("Repeat"));
127                                drawscreen(apskin, 0);
128                        }
129                }
130                else if(rcret == getrcconfigint("rcyellow", NULL))
131                {
132                        playerrandom(apskin, filelist, listbox, b3, playlist, flag);
133                }
134                else if(rcret == getrcconfigint("rcred", NULL))
135                {
136                        if(status.play == 1)
137                                playrcred(filename, playinfobarstatus, playertype, flag);
138                        else
139                        {
140                                if(playlist == 0)
141                                {
142                                        int sort = screenmc_sort();
143                                        debug(50, "rcred: tmpsort=%d", sort);
144
145                                        addconfiginttmp("dirsort", sort);
146                                        mc_changeview(view, filelist);
147                                        getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->text);
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("view", NULL);
174                                screenmc_pictureplayer_settings();
175                               
176                                if(view != getconfigint("view", NULL))
177                                {
178                                        printf("view changed > change tmpview\n");
179                                        tmpview = getconfigint("view", NULL);
180                                }
181//                              mc_changeview(view, filelist);
182
183                                sound = getconfig("sound", NULL);
184
185                                // start radio musik on pictureplayer
186                                playerstop();
187                                free(track), track = NULL;
188                                track = ostrcat("", sound, 0, 0);
189
190                                if(ostrcmp(sound, "off") != 0){
191                                        playerret = playerstart(track);
192                                        playwritevfd(filename);
193
194                                        #ifndef SIMULATE
195                                                if(playerret != 0)
196                                                        textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
197                                        #endif
198                                }
199                                else
200                                        playerstop();
201
202                                delownerrc(apskin);     
203                                drawscreen(skin, 0);
204                                getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->text);
205                                mc_changeview(view, filelist);
206                                addscreenrc(apskin, filelist);
207                                                       
208                                drawscreen(apskin, 0);
209                        }
210                }
211                else if(rcret == getrcconfigint("rcstop", NULL))
212                {
213                        debug(50, "rcstop: stopplayback");
214
215                        picplayer(picscreen, picture, picname, NULL, 0);
216                        clearscreen(picscreen);
217                        eof = 0;
218
219                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
220       
221                        apskin->hidden = NO;
222                        filelist->hidden = NO;
223                        listbox->hidden = YES;
224                        changetext(filelistpath, _(getconfig("mc_pictureplayerpath", NULL)));
225                        changetext(b2, _("Filelist-Mode"));
226
227                        // switch filelist
228                        delownerrc(apskin);
229                        addscreenrc(apskin, filelist);
230                        setfbtransparent(255);
231                        drawscreen(apskin, 0);
232
233                        sleep(1);
234
235                        playinfobarcount = 0;
236                        playinfobarstatus = 1;
237                        status.playspeed = 0;
238                        status.pause = 0;
239                        status.play = 0;
240                        playlist = 0;
241                        playinfobarcount = 0;
242                        writevfd("pictureplayer Filelist-Mode");
243                }
244                else if(rcret == getrcconfigint("rcexit", NULL))
245                {
246                        debug(50, "exit - save mc_pictureplayerpath: %s", filelistpath->text);
247                        if(playlist == 0)
248                        {
249                                if(ostrcmp(getconfig("mc_pictureplayerpath", NULL), filelistpath->text) != 0)
250                                        addconfig("mc_pictureplayerpath", filelistpath->text);
251                        }
252
253                        playerstop();
254                        picplayer(picscreen, picture, picname, NULL, 0);
255
256                        eof = 0;
257
258                        setfbtransparent(255);
259                        sleep(1);
260                        apskin->hidden = NO;
261                        filelist->hidden = NO;
262                        listbox->hidden = YES;
263                        changetext(b2, _("Filelist-Mode"));
264                        changetext(b3, _("Random"));
265                        changetext(b4, _("Repeat"));                                                                           
266                        status.playspeed = 0;
267                        status.pause = 0;
268                        status.play = 0;
269                        status.random = 0;
270                        status.repeat = 0;
271                        playlist = 0;
272                        writevfd("Mediacenter");
273                        playinfobarcount = 0;
274status.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_pictureplayerpath", 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_pictureplayerpath", NULL), filelistpath->text) != 0)
344                                        addconfig("mc_pictureplayerpath", 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_pictureplayerpath", filelistpath->text);
353                                        currentdirectory = ostrcat("", getconfig("mc_pictureplayerpath", 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        if(style == 1)
422        {
423                delmarkedpic(1010);
424                delmarkedpic(1011);
425                delmarkedpic(1012);
426                delmarkedpic(1013);
427        }
428
429        free(track), track = NULL;
430        free(filename), filename = NULL;
431        free(currentdirectory), currentdirectory = NULL;
432
433        writevfd("Mediacenter");
434        debug(50, "closed");
435}
436
437#endif
Note: See TracBrowser for help on using the repository browser.