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

Last change on this file since 16561 was 16561, 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, 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, apskin);
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, 0);
118                                status.repeat = 1;
119                        }
120                        else
121                        {
122                                status.repeat = 0;
123                                changetext(b4, _("Repeat"));
124                                drawscreen(apskin, 0, 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, apskin);
144                                        delownerrc(apskin);
145                                        getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->text);
146                                        addscreenrc(apskin, filelist);
147                                        drawscreen(apskin, 0, 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, 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, apskin);
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, 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, 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                        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_pp_path", NULL)));
311                                                        filelist->hidden = NO;
312                                                        listbox->hidden = YES;
313       
314                                                        addscreenrc(apskin, filelist);
315                                                        drawscreen(apskin, 0, 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, 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_pp_path", NULL), filelistpath->text) != 0)
343                                        addconfig("mc_pp_path", 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_pp_path", filelistpath->text);
352                                        currentdirectory = ostrcat("", getconfig("mc_pp_path", 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, 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
421        free(track), track = NULL;
422        free(filename), filename = NULL;
423        free(currentdirectory), currentdirectory = NULL;
424
425        writevfd("Mediacenter");
426        debug(50, "closed");
427}
428
429#endif
Note: See TracBrowser for help on using the repository browser.