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

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

[titan] update mc

File size: 12.0 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        tmpview = view;
58        mc_changeview(view, filelist);
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(tmpview, 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                                addscreenrc(apskin, filelist);
206                                                       
207                                drawscreen(apskin, 0);
208                        }
209                }
210                else if(rcret == getrcconfigint("rcstop", NULL))
211                {
212                        debug(50, "rcstop: stopplayback");
213
214                        picplayer(picscreen, picture, picname, NULL, 0);
215                        clearscreen(picscreen);
216                        eof = 0;
217
218                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
219       
220                        apskin->hidden = NO;
221                        filelist->hidden = NO;
222                        listbox->hidden = YES;
223                        changetext(filelistpath, _(getconfig("mc_pictureplayerpath", NULL)));
224                        changetext(b2, _("Filelist-Mode"));
225
226                        // switch filelist
227                        delownerrc(apskin);
228                        addscreenrc(apskin, filelist);
229                        setfbtransparent(255);
230                        drawscreen(apskin, 0);
231
232                        sleep(1);
233
234                        playinfobarcount = 0;
235                        playinfobarstatus = 1;
236                        status.playspeed = 0;
237                        status.pause = 0;
238                        status.play = 0;
239                        playlist = 0;
240                        playinfobarcount = 0;
241                        writevfd("pictureplayer Filelist-Mode");
242                }
243                else if(rcret == getrcconfigint("rcexit", NULL))
244                {
245                        debug(50, "exit - save mc_pictureplayerpath: %s", filelistpath->text);
246                        if(playlist == 0)
247                        {
248                                if(ostrcmp(getconfig("mc_pictureplayerpath", NULL), filelistpath->text) != 0)
249                                        addconfig("mc_pictureplayerpath", filelistpath->text);
250                        }
251
252                        playerstop();
253                        picplayer(picscreen, picture, picname, NULL, 0);
254
255                        eof = 0;
256
257                        setfbtransparent(255);
258                        sleep(1);
259                        apskin->hidden = NO;
260                        filelist->hidden = NO;
261                        listbox->hidden = YES;
262                        changetext(b2, _("Filelist-Mode"));
263                        changetext(b3, _("Random"));
264                        changetext(b4, _("Repeat"));                                                                           
265                        status.playspeed = 0;
266                        status.pause = 0;
267                        status.play = 0;
268                        status.random = 0;
269                        status.repeat = 0;
270                        playlist = 0;
271                        writevfd("Mediacenter");
272                        playinfobarcount = 0;
273status.filelistextend = 0;
274                        break;
275                }
276                else if(rcret == getrcconfigint("rcok", NULL))
277                {
278                        if(playlist == 1 && listbox->select != NULL)
279                        {
280                                filename = ostrcat("", listbox->select->name, 0, 0);
281
282                                changetext(b2, _("Playlist-Mode"));
283                       
284                                debug(50, "screensaver title: %s", listbox->select->text);
285                                if(screensaver != NULL && screensaver->type == 0)
286                                        screensaver->value = listbox->select->text;
287
288                                debug(50, "playerstop");
289                                playerstop();
290
291                                debug(50, "playerstart: %s", filename);
292                                eof = 0;
293
294                                delownerrc(apskin);
295                                setfbtransparent(255);
296
297                                if(ostrcmp(sound, "off") != 0){
298                                        playerret = playerstart(filename);
299                                        playwritevfd(filename);
300
301                                        #ifndef SIMULATE
302                                                if(playerret != 0)
303                                                {
304                                                        writevfd("pictureplayer Filelist-Mode");
305                                                        status.play = 0;
306                                                        playlist = 0;
307                                                        status.playspeed = 0;
308                                                        textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
309
310                                                        changetext(filelistpath, _(getconfig("mc_pictureplayerpath", NULL)));
311                                                        filelist->hidden = NO;
312                                                        listbox->hidden = YES;
313       
314                                                        addscreenrc(apskin, filelist);
315                                                        drawscreen(apskin, 0);
316                                                        continue;
317                                                }
318                                        #endif
319                                }
320
321                                screenplayinfobar(filename, 0, playertype, 0);                 
322                                status.play = 1;
323                        }
324                        else if(filelist->select != NULL && filelist->select->input != NULL)
325                        {
326                                // workaround dont open folder on rcchup
327                                if(skip == 1)
328                                {
329                                        drawscreen(apskin, 0);
330                                        writerc(getrcconfigint("rcok", NULL));
331                                        skip = 0;
332                                }
333                                else
334                                {
335                                        debug(50, "mc_mounter_chk start");
336                                        mc_mounter_chk(filelistpath);
337                                        debug(50, "mc_mounter_chk done");
338                                }
339                        }
340                        else if(filelist->select != NULL && filelist->select->input == NULL)
341                        {
342                                if(ostrcmp(getconfig("mc_pictureplayerpath", NULL), filelistpath->text) != 0)
343                                        addconfig("mc_pictureplayerpath", filelistpath->text);
344
345                                debug(50, "filelist->select->text: %s", filelist->select->text);
346                                filename = createpath(filelistpath->text, filelist->select->text);
347
348                                if(!strncmp(".rar",filename+strlen(filename)-4,4) || !strncmp(".iso",filename+strlen(filename)-4,4) || !strncmp(".img",filename+strlen(filename)-4,4))
349                                {
350                                        debug(50, "mc_mounter_main filename: %s", filename);
351                                        //addconfig("mc_pictureplayerpath", filelistpath->text);
352                                        currentdirectory = ostrcat("", getconfig("mc_pictureplayerpath", NULL), 0, 0);
353
354                                        mc_mounter_main(0,filename,filelistpath,filelist,apskin,filemask,tmpview,currentdirectory);
355                                        debug(50, "mc_mounter_main done");
356       
357                                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
358                                        continue;
359                                }
360                                else if(!strncmp(".m3u",filename+strlen(filename)-4,4) || !strncmp(".pls",filename+strlen(filename)-4,4))
361                                {
362                                        showplaylist(apskin, filelistpath, filelist, listbox, b2, 1, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
363                                        continue;
364                                }
365
366                                changetext(b2, _("Filelist-Mode"));
367                       
368                                if(screensaver != NULL && screensaver->type == 0)
369                                        screensaver->value = (void*)filelist->select->text;
370
371                                delownerrc(apskin);
372//                              setfbtransparent(255);
373
374                                debug(50, "playerstart: %s", filename);
375                                eof = 0;
376
377                                playinfobarcount = 0, playinfobarstatus = 1;
378                                picplayer(picscreen, picture, picname, filename, 1);
379                                servicestop(status.aktservice, 1, 1);
380
381                                status.play = 1;
382                        }
383                }
384               
385                if(playerisplaying() == 0)
386                {
387                        playerstop();
388
389                        if(ostrcmp(sound, "off") != 0){
390                                playerret = playerstart(track);
391                                playwritevfd(filename);
392
393                                #ifndef SIMULATE
394                                        if(playerret != 0)
395                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
396                                #endif
397                        }
398                }
399
400                if((eof >= 1) || (nextpic == 1))
401                {
402                        if(status.play == 1)
403                        {
404//                              setfbtransparent(0);
405//                              apskin->hidden = NO;
406//                              drawscreen(skin, 0);
407                                playereof(apskin, filelist, listbox, filelistpath, picscreen, picture, picname, b2, &skip, &eof, &playlist, playertype, flag);
408                        }
409                }
410        }
411
412        deinitscreensaver();
413        status.hangtime = getconfigint("hangtime", NULL);
414        delconfigtmp("dirsort");
415
416        delmarkedscreennodes(apskin, FILELISTDELMARK);
417        delownerrc(apskin);
418        clearscreen(apskin);
419        clearscreen(picscreen);
420        if(style == 1)
421        {
422                delmarkedpic(1010);
423                delmarkedpic(1011);
424                delmarkedpic(1012);
425                delmarkedpic(1013);
426        }
427
428        free(track), track = NULL;
429        free(filename), filename = NULL;
430        free(currentdirectory), currentdirectory = NULL;
431
432        writevfd("Mediacenter");
433        debug(50, "closed");
434}
435
436#endif
Note: See TracBrowser for help on using the repository browser.