source: titan/plugins/mc/mc_global.h @ 28981

Last change on this file since 28981 was 28981, checked in by obi, 10 years ago

fix

File size: 28.4 KB
Line 
1#ifndef MC_GLOBAL_H
2#define MC_GLOBAL_H
3
4/*
5 ------------------------------------------
6        mc_changeview start
7 ------------------------------------------
8*/
9// flag 1 = vp
10// flag 2 = ap
11// flag 3 = pp
12void mc_changeview(int view, struct skin* filelist, struct skin* apskin, int flag)
13{
14        struct skin* node = filelist;
15
16        struct skin* plot = getscreennode(apskin, "plot");
17        struct skin* title = getscreennode(apskin, "title");
18        struct skin* thumb = getscreennode(apskin, "thumb");
19        struct skin* actorstext = getscreennode(apskin, "actorstext");
20        struct skin* actors = getscreennode(apskin, "actors");
21        struct skin* genretext = getscreennode(apskin, "genretext");
22        struct skin* genre = getscreennode(apskin, "genre");
23        struct skin* yeartext = getscreennode(apskin, "yeartext");
24        struct skin* year = getscreennode(apskin, "year");
25        struct skin* realnametext = getscreennode(apskin, "realnametext");
26        struct skin* realname = getscreennode(apskin, "realname");
27        struct skin* albumtext = getscreennode(apskin, "albumtext");
28        struct skin* album = getscreennode(apskin, "album");
29        struct skin* stars = getscreennode(apskin, "stars");
30
31        struct skin* loadmediadb = getscreen("loading");
32        struct skin* blackscreen = getscreen("blackscreen");
33        drawscreen(blackscreen, 0, 0);
34        drawscreen(loadmediadb, 0, 0);
35                       
36        while(node != NULL)
37        {
38                if(node->del == FILELISTDELMARK)
39                {
40                        node->fontsize = 0;
41                        node->height = 0;
42                        node->width = 0;
43                        node->height = 0;
44                        node->bgcol = 0;
45                        node->transparent = 0;
46                        node->prozwidth = 0;
47                        node->posx = 0;
48                }
49                node = node->next;
50        }
51
52        if(view == 0)
53        {
54                filelist->fontsize = 25;//, fontspace = 5;
55                filelist->height = 460;
56                filelist->width = 1160;
57                filelist->prozwidth = 0;
58                filelist->posx = 40;
59                filelist->transparent = -1;
60                filelist->bgcol = -1;
61                thumb->hidden = YES;
62                plot->hidden = YES;
63                title->hidden = YES;
64                actorstext->hidden = YES;
65                actors->hidden = YES;
66                genretext->hidden = YES;
67                genre->hidden = YES;
68                yeartext->hidden = YES;
69                year->hidden = YES;
70                realnametext->hidden = YES;
71                realname->hidden = YES;
72                albumtext->hidden = YES;
73                album->hidden = YES;
74                stars->hidden = YES;
75        }
76        else if(view == 1)
77        {
78                filelist->fontsize = 35;//, fontspace = 5;
79                filelist->height = 460;
80                filelist->width = 1160;
81                filelist->prozwidth = 0;
82                filelist->posx = 40;
83                filelist->transparent = -1;
84                filelist->bgcol = -1;
85                filelist->prozwidth = 0;
86                thumb->hidden = YES;
87                plot->hidden = YES;
88                title->hidden = YES;   
89                actorstext->hidden = YES;
90                actors->hidden = YES;
91                genretext->hidden = YES;
92                genre->hidden = YES;
93                yeartext->hidden = YES;
94                year->hidden = YES;
95                realnametext->hidden = YES;
96                realname->hidden = YES;
97                albumtext->hidden = YES;
98                album->hidden = YES;
99                stars->hidden = YES;
100        }
101        else if(view == 2)
102        {
103                filelist->fontsize = 20;//, fontspace = 5;
104                filelist->height = 480;
105                filelist->width = 1160;
106                filelist->prozwidth = 0;       
107                filelist->posx = 40;
108                filelist->transparent = -1;
109                filelist->bgcol = -1;
110                thumb->hidden = YES;
111                plot->hidden = YES;
112                title->hidden = YES;
113                actorstext->hidden = YES;
114                actors->hidden = YES;
115                genretext->hidden = YES;
116                genre->hidden = YES;
117                yeartext->hidden = YES;
118                year->hidden = YES;
119                realnametext->hidden = YES;
120                realname->hidden = YES;
121                albumtext->hidden = YES;
122                album->hidden = YES;
123                stars->hidden = YES;
124        }
125        else if(view == 3)
126        {
127                filelist->fontsize = 25;//, fontspace = 10;
128                filelist->height = 350;
129                if(flag == 2)
130                        filelist->width = 800;
131                else
132                        filelist->width = 600;
133                filelist->prozwidth = 0;               
134                filelist->bgcol = 0x474747;
135                filelist->transparent = 40;
136                filelist->posx = 20;
137                thumb->hidden = NO;
138                title->hidden = NO;
139
140                if(flag == 2)
141                {
142                        plot->hidden = YES;
143                        actorstext->hidden = NO;
144                        actors->hidden = NO;
145                        genretext->hidden = NO;
146                        genre->hidden = NO;
147                        yeartext->hidden = NO;
148                        year->hidden = NO;
149                        realnametext->hidden = NO;
150                        realname->hidden = NO;
151                        albumtext->hidden = NO;
152                        album->hidden = NO;
153                        stars->hidden = YES;
154                }
155                else
156                {
157                        plot->hidden = NO;
158                        actorstext->hidden = YES;
159                        actors->hidden = YES;
160                        genretext->hidden = YES;
161                        genre->hidden = YES;
162                        yeartext->hidden = YES;
163                        year->hidden = YES;
164                        realnametext->hidden = YES;
165                        realname->hidden = YES;
166                        albumtext->hidden = YES;
167                        album->hidden = YES;
168                        stars->hidden = NO;
169                }
170        }       
171        else if(view == 4)
172        {
173                filelist->fontsize = 30;//, fontspace = 5;
174                filelist->height = 460;
175                filelist->width = 1160;
176                filelist->prozwidth = 0;
177                filelist->posx = 40;
178                filelist->transparent = -1;
179                filelist->bgcol = -1;
180                filelist->prozwidth = 0;
181                thumb->hidden = YES;
182                plot->hidden = YES;
183                title->hidden = YES;           
184                actorstext->hidden = YES;
185                actors->hidden = YES;
186                genretext->hidden = YES;
187                genre->hidden = YES;
188                yeartext->hidden = YES;
189                year->hidden = YES;
190                realnametext->hidden = YES;
191                realname->hidden = YES;
192                albumtext->hidden = YES;
193                album->hidden = YES;
194                stars->hidden = YES;
195        }
196        else if(view == 5)
197        {
198                filelist->fontsize = 25;//, fontspace = 5;
199                filelist->height = 460;
200                filelist->width = 1160;
201                filelist->prozwidth = 0;
202                filelist->posx = 40;
203                filelist->transparent = -1;
204                filelist->bgcol = -1;
205                filelist->prozwidth = 0;
206                thumb->hidden = YES;
207                plot->hidden = YES;
208                title->hidden = YES;   
209                actorstext->hidden = YES;
210                actors->hidden = YES;
211                genretext->hidden = YES;
212                genre->hidden = YES;
213                yeartext->hidden = YES;
214                year->hidden = YES;
215                realnametext->hidden = YES;
216                realname->hidden = YES;
217                albumtext->hidden = YES;
218                album->hidden = YES;
219                stars->hidden = YES;
220        }
221}
222
223/*
224 ------------------------------------------
225        mc_changeratio start
226 ------------------------------------------
227*/
228int mc_changeratio()
229{
230        debug(50, "[mc_changeratio] start");
231        char *tmppolicy = NULL, *tmpstr = NULL;
232        debug(50, "[mc_changeratio] getpolicy");
233        tmppolicy = getpolicy();
234
235        debug(50, "[mc_changeratio] from: %s", tmppolicy);
236
237        if(!strncmp("letterbox", tmppolicy, 8)){
238                tmpstr = ostrcat(tmpstr, "panscan", 1, 0);
239        } else if(!strncmp("panscan", tmppolicy, 7)){
240                tmpstr = ostrcat(tmpstr, "non", 1, 0);
241        } else if(!strncmp("non", tmppolicy, 3)){
242                tmpstr = ostrcat(tmpstr, "bestfit", 1, 0);
243        } else if(!strncmp("bestfit", tmppolicy, 7)){
244                tmpstr = ostrcat(tmpstr, "letterbox", 1, 0);
245        }
246
247        debug(50, "[mc_changeratio] to: %s", tmpstr);
248        setpolicy(tmpstr);
249
250        free(tmpstr); tmpstr = NULL;
251        free(tmppolicy); tmppolicy = NULL;
252        return 0;
253}
254
255extern struct skin* skin;
256extern struct screensaver* screensaver;
257
258void playereof(struct skin* apskin, struct skin* filelist, struct skin* listbox, struct skin* filelistpath, struct skin* b2, struct skin* picscreen, struct skin* picture, struct skin* picname, int* skip, int* eof, int* playlist, int playertype, int flag)
259{
260                debug(50, "--------------eof-------------");
261                status.playspeed = 0;
262                status.pause = 0;
263                status.play = 0;
264                int skiprcok = 0;
265               
266                //playlist
267                if(*playlist == 1)
268                {
269//                      changetext(b2, _("Playlist-Mode"));
270                        changetext(b2, _("Playlist"));
271
272                        if(screensaver != NULL && screensaver->type == 3 && flag == 2)
273                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
274               
275                        drawscreen(apskin, 0, 0);
276               
277                        int switchtofilelist = 0;
278                                               
279                        if(status.random == 1 && status.repeat == 0)
280                        {
281                                int maxdirs = 0, maxfiles = 0;
282                                getplaylistmaxold(listbox, &maxdirs, &maxfiles);
283                                struct skin* tmplist = getplaylistrandomold(listbox, maxdirs, maxfiles);
284                                debug(50, "struct skin xtext=%s", tmplist->text);
285                                if(tmplist != NULL)
286                                {
287                                        debug(50, "struct skin randomtext=%s", tmplist->text);
288                                        setlistboxselection(listbox, tmplist->name);
289                                }
290                        }
291                        else
292                        {
293                                if(status.repeat == 0)
294                                {
295                                        debug(50, "writerc: rcdown next file");
296
297                                        debug(50, "listbox->aktline: %d", listbox->aktline);
298                                        debug(50, "listbox->linecount: %d", listbox->linecount);
299                                        debug(50, "*eof: %d", *eof);
300                                        debug(50, "flag: %d", flag);
301                       
302
303                                        if(*eof == 0)
304                                        {
305                                                if(listbox->aktline < listbox->linecount)
306                                                {
307                                                        listbox->aktline ++;
308//                                                      if(flag == 1)
309//                                                      {
310//                                                              apskin->hidden = YES;
311//                                                              delownerrc(apskin);
312//                                                              drawscreen(skin, 0, 0);
313//                                                      }
314                                                }
315                                                else
316                                                {
317                                                        if(flag != 3)
318                                                                playrcstop(playertype, flag);
319                                                        if((flag == 1) || (flag == 3))
320                                                        {
321                                                                apskin->hidden = NO;
322                                                                filelist->hidden = NO;
323                                                                listbox->hidden = YES;
324
325                                                                if(flag == 1)
326                                                                        changetext(filelistpath, _(getconfig("mc_vp_path", NULL)));
327                                                                else if(flag == 2)
328                                                                        changetext(filelistpath, _(getconfig("mc_ap_path", NULL)));
329                                                                else if(flag == 3)
330                                                                {
331                                                                        changetext(filelistpath, _(getconfig("mc_pp_path", NULL)));
332                                                                        picplayer(picscreen, picture, picname, NULL, 0);
333                                                                        clearscreen(picscreen);
334                                                                }
335
336                                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
337//                                                              changetext(b2, _("Filelist-Mode"));
338                                                                changetext(b2, _("Playlist"));
339//                                                              writevfdmenu("Filelist-Mode");
340                                                                writevfdmenu("Playlist");
341
342                                                                switchtofilelist = 1;
343       
344                                                                drawscreen(skin, 0, 0);
345                                                               
346                                                                // show skin
347                                                                setfbtransparent(255);
348
349                                                                *playlist = 0;
350                                                        }
351                                                        else
352                                                        {
353                                                                if(screensaver != NULL && screensaver->type == 3 && flag == 2)
354                                                                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
355                                                        }
356                                                        skiprcok = 1;
357                                                }
358                                        }
359                                        else if(*eof == 1)
360                                        {
361                                                if(listbox->aktline < listbox->linecount)
362                                                        listbox->aktline ++;
363                                                        if(flag == 1)
364                                                        {
365                                                                //apskin->hidden = YES;
366                                                                //delownerrc(apskin);
367                                                                drawscreen(skin, 0, 0);
368                                                        }
369                                                else
370                                                {
371                                                        status.play = 1;
372                                                        skiprcok = 1;
373                                                }
374                                        }
375                                        else if(*eof == 2)
376                                        {
377                                                if(listbox->aktline == 1)
378                                                {
379                                                        status.play = 1;
380                                                        if(screensaver != NULL && screensaver->type == 3 && flag == 2)
381                                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
382                                                        skiprcok = 1;
383                                                }
384                                                else
385                                                {
386                                                        listbox->aktline --;
387                                                        if(flag == 1)
388                                                        {
389                                                                //apskin->hidden = YES;
390                                                                //delownerrc(apskin);
391                                                                drawscreen(skin, 0, 0);
392                                                        }
393                                                        // workaround dont open folder on rcchup
394                                                        *skip = 1;
395                                                }
396                                        }
397
398                                        *eof = 0;
399
400                                        debug(50, "listbox->aktline: %d", listbox->aktline);
401                                        debug(50, "listbox->linecount: %d", listbox->linecount);
402                                }
403                        }
404                        delownerrc(apskin);
405                        if(switchtofilelist == 0)
406                                addscreenrc(apskin, listbox);
407                        else
408                                addscreenrc(apskin, filelist);                 
409                }
410                else
411                {
412//                      changetext(b2, _("Filelist-Mode"));
413                        changetext(b2, _("Playlist"));
414                       
415               
416                        if(screensaver != NULL && screensaver->type == 3 && flag == 2)
417                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
418
419                        if(flag != 3)
420                                drawscreen(apskin, 0, 0);
421
422                        if(status.random == 1 && status.repeat == 0)
423                        {
424                                int maxdirs = 0, maxfiles = 0;
425                                getfilelistmax(filelist, &maxdirs, &maxfiles);
426                                struct skin* tmplist = getfilelistrandom(filelist, maxdirs, maxfiles);
427                                debug(50, "struct skin xtext=%s", tmplist->text);
428                                if(tmplist != NULL)
429                                {
430                                        debug(50, "struct skin randomtext=%s", tmplist->text);
431                                        setlistboxselection(filelist, tmplist->name);
432                                }
433                        }
434                        else
435                        {
436                                if(status.repeat == 0)
437                                {
438                                        debug(50, "writerc: rcdown next file");
439
440                                        debug(50, "filelist->aktline: %d", filelist->aktline);
441                                        debug(50, "filelist->linecount: %d", filelist->linecount);
442
443                                        if(*eof == 0)
444                                        {
445                                                if(filelist->aktline < filelist->linecount)
446                                                {
447                                                        filelist->aktline ++;
448                                                }
449                                                else
450                                                {                                                       
451                                                        if(flag != 3)
452                                                                playrcstop(playertype, flag);
453                                                        if((flag == 1) || (flag == 3))
454                                                        {
455                                                                if(flag == 3)
456                                                                {
457                                                                        picplayer(picscreen, picture, picname, NULL, 0);
458                                                                        clearscreen(picscreen);
459                                                                }
460
461                                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
462
463                                                                apskin->hidden = NO;
464                                                                filelist->hidden = NO;
465                                                                listbox->hidden = YES;
466
467                                                                // switch filelist
468                                                                delownerrc(apskin);
469                                                                addscreenrc(apskin, filelist);
470
471                                                                setfbtransparent(255);
472                                                        }
473                                                        else
474                                                        {
475                                                                if(screensaver != NULL && screensaver->type == 3 && flag == 2)
476                                                                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
477                                                        }
478                                                        skiprcok = 1;
479                                                }
480
481                                        }
482                                        else if(*eof == 1)
483                                        {
484                                                if(filelist->aktline < filelist->linecount)
485                                                        filelist->aktline ++;
486                                                else
487                                                {
488                                                        status.play = 1;
489                                                        skiprcok = 1;
490                                                }
491                                        }
492                                        else if(*eof == 2)
493                                        {
494                                                if(filelist->aktline == 1)
495                                                {
496                                                        status.play = 1;
497                                                        if(screensaver != NULL && screensaver->type == 3 && flag == 2)
498                                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
499                                                        skiprcok = 1;
500                                                }
501                                                else
502                                                {
503                                                        filelist->aktline --;
504                                                        // workaround dont open folder on rcchup
505                                                        *skip = 1;
506                                                }
507                                        }
508
509                                        *eof = 0;
510
511                                        debug(50, "filelist->aktline: %d", filelist->aktline);
512                                        debug(50, "filelist->linecount: %d", filelist->linecount);
513                                }
514                        }
515                        delownerrc(apskin);
516                        addscreenrc(apskin, filelist);
517                }
518
519                debug(50, "flag: %d", flag);
520                debug(50, "skiprcok: %d", skiprcok);                                   
521
522                if(flag == 3 && skiprcok == 0)
523                        drawscreen(apskin, 2, 0);
524                else
525                        drawscreen(apskin, 0, 0);
526                       
527                if(skiprcok == 0)
528                        writerc(getrcconfigint("rcok", NULL));
529}
530
531void playerrandom(struct skin* apskin, struct skin* filelist, struct skin* listbox, struct skin* b3, int playlist, int flag)
532{
533        if(playlist == 0)
534        {
535                debug(50, "rcyellow: random");
536                if(status.random == 0)
537                {
538                        int maxdirs = 0, maxfiles = 0;
539                        getfilelistmax(filelist, &maxdirs, &maxfiles);
540                        struct skin* tmplist = getfilelistrandom(filelist, maxdirs, maxfiles);
541
542                        if(tmplist != NULL)
543                        {
544                                debug(50, "struct skin randomtext=%s", tmplist->text);
545                                setlistboxselection(filelist, tmplist->name);
546//                              if(flag == 2)
547                                        changetext(b3, _("Random-On"));
548                                drawscreen(apskin, 0, 0);
549                                status.random = 1;
550                                debug(50, "writerc rcok");
551                                writerc(getrcconfigint("rcok", NULL));
552                        }
553                }
554                else
555                {
556                        status.random = 0;
557//                      if(flag == 2)
558                                changetext(b3, _("Random"));
559                        drawscreen(apskin, 0, 0);
560                }
561        }
562        else
563        {
564                debug(50, "rcyellow: random");
565                if(status.random == 0)
566                {
567                        int maxdirs = 0, maxfiles = 0;
568                        getplaylistmaxold(listbox, &maxdirs, &maxfiles);
569                        struct skin* tmplist = getplaylistrandomold(listbox, maxdirs, maxfiles);
570                        if(tmplist != NULL)
571                        {
572                                debug(50, "struct skin randomtext=%s", tmplist->text);
573                                setlistboxselection(listbox, tmplist->name);
574//                              if(flag == 2)
575                                        changetext(b3, _("Random-On"));
576                                drawscreen(apskin, 0, 0);
577                                status.random = 1;
578                                debug(50, "writerc rcok");
579                                writerc(getrcconfigint("rcok", NULL));
580                        }
581                }
582                else
583                {
584                        status.random = 0;
585//                      if(flag == 2)
586                                changetext(b3, _("Random"));
587                        drawscreen(apskin, 0, 0);
588                }
589        }
590}
591
592void showplaylist(struct skin* apskin, struct skin* filelistpath, struct skin* filelist, struct skin* listbox, struct skin* b2, int mode, int* playlist, int* eof, char** filename, char** currentdirectory, int* playertype, int flag)
593{
594        int playerret = 0;
595        struct skin* tmp = NULL;
596        struct mainplaylist* mplaylist = NULL;
597        struct playlist* playlistnode = NULL;
598        struct menulist* mlist = NULL, *mbox = NULL;
599        char* title = NULL;
600        int count = 0;
601
602        if(mode == 0)
603        {
604                debug(50, "rcgreenss: playlist menu");
605
606                addmenulist(&mlist, _("Load Playlist"), NULL, NULL, 0, 0);
607                addmenulist(&mlist, _("Edit Playlist"), NULL, NULL, 0, 0);
608               
609                mbox = menulistbox(mlist, "playlistmenu", _("Playlist Menu"), _("Choose your Playlist Mode from the following list"), "%pluginpath%/mc/skin", NULL, 1, 0);
610
611                drawscreen(apskin, 0, 0);
612
613                if(mbox != NULL)
614                {
615                        if(ostrcmp(mbox->name, _("Load Playlist")) == 0)
616                        {
617//                              *count = 0;
618//                              *rcwait = 1000;
619       
620                                status.playspeed = 0;
621                                status.pause = 0;
622                                status.play = 0;
623
624                                mplaylist = screenmainplaylist(1);
625                                drawscreen(apskin, 0, 0);
626
627                                if(mplaylist != NULL && mplaylist->playlist != NULL)
628                                {
629                                        playlistnode = NULL;
630                                        playlistnode = mplaylist->playlist;
631                                        if(playlistnode->file != NULL)
632                                        {
633                                                *filename = ostrcat("", playlistnode->file, 0, 0);
634                                                playrcstop(*playertype, flag);
635
636                                                count = 0;
637
638                                                // clear listbox, not working ?
639                                                delmarkedscreennodes(apskin, 2);
640
641                                                char* firsttitle = NULL;
642                                                while(playlistnode != NULL)
643                                                {
644                                                        tmp = addlistbox(apskin, listbox, tmp, 2);
645                                                        if(tmp != NULL)
646                                                        {
647                                                                int count1 = 0;
648                                                                char* tmpstr1 = NULL;
649                                                                tmpstr1 = ostrcat("", playlistnode->file, 0, 0);
650
651                                                                int i = 0;
652                                                                struct splitstr* ret1 = NULL;
653                                                                ret1 = strsplit(tmpstr1, "/", &count1);
654                                                                if(count1 >= 1)
655                                                                        i = count1 - 1;
656                                                                count ++;
657                                                                debug(50, "addlistbox (%d) %s", count, playlistnode->file);
658
659                                                                title = ostrcat("(", oitoa(count), 0, 1);
660                                                                if(count < 10)
661                                                                        title = ostrcat(title, ")    ", 1, 0);
662                                                                else if(count < 100)
663                                                                        title = ostrcat(title, ")   ", 1, 0);
664                                                                else
665                                                                        title = ostrcat(title, ")  ", 1, 0);
666
667                                                                title = ostrcat(title, (&ret1[i])->part, 1, 0);
668                                                                changetext(tmp, _(title));
669
670                                                                if(firsttitle == NULL)
671                                                                        firsttitle = ostrcat("", title, 0, 0);                 
672
673                                                                free(ret1), ret1 = NULL;
674                                                                free(tmpstr1), tmpstr1 = NULL;
675
676                                                                // new
677
678                                                                changename(tmp, playlistnode->file);
679                                                                tmp->handle = (char*)playlistnode;
680                                                                tmp->del = 2;
681                                                        }
682                                                        playlistnode = playlistnode->next;
683                                                }
684
685                                                *currentdirectory = ostrcat("Playlist: ", mplaylist->name, 0, 0);
686                                                changetext(filelistpath, _(*currentdirectory));
687                                                filelist->hidden = YES;
688                                                listbox->hidden = NO;
689
690                                                // workaround playereof
691                                                playlistnode = NULL;
692                                                playlistnode = mplaylist->playlist;
693
694                                                setlistboxselection(listbox, *filename);
695                                                if(firsttitle == NULL)
696                                                        firsttitle = ostrcat("", "dummy no read title", 0, 0);                                         
697
698                                                title = ostrcat("", firsttitle, 0, 0);
699//                                              changetext(b2, _("Playlist-Mode"));
700                                                changetext(b2, _("Playlist"));
701
702                                                if(screensaver != NULL && screensaver->type == 0)
703                                                        screensaver->value = title;
704
705                                                delownerrc(apskin);
706                                                addscreenrc(apskin, listbox);
707                                                drawscreen(apskin, 0, 0);
708                                                // show playlist end   
709                                                sleep(1);
710
711                                                if(flag == 1  && status.play == 1)
712                                                {
713                                                        servicestop(status.aktservice, 1, 1);
714                                                        drawscreen(skin, 0, 0);
715                                                        setfbtransparent(255);
716                                                        debug(50, "check");
717                                                        debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
718                                                        debug(50, "status.play: %d", status.play);
719                                                        debug(50, "flag: %d", flag);
720                                                }
721                                                else if(flag == 2  && status.play == 1)
722                                                {
723                                                        addscreenrc(apskin, listbox);
724                                                        drawscreen(apskin, 0, 0);
725                                                        debug(50, "check");
726                                                        debug(50, "autostart_playlist: %d", getconfigint("mc_ap_autostart_playlist", NULL));
727                                                        debug(50, "status.play: %d", status.play);                             
728                                                        debug(50, "flag: %d", flag);
729                                                }
730                       
731                                                if((getconfigint("mc_vp_autostart_playlist", NULL) == 1 && flag == 1 && status.play == 0) || (getconfigint("mc_ap_autostart_playlist", NULL) == 1 && flag == 2 && status.play == 0))
732                                                {
733                                                        debug(50, "-------------- check ok titan playlist pls --------------");
734                                                        debug(50, "playerstart: %s", *filename);
735                                                        debug(50, "flag: %d", flag);
736                                                        debug(50, "playertype: %d", *playertype);       
737                                                                                       
738                                                        if(flag == 1)
739                                                        {
740                                                                servicestop(status.aktservice, 1, 1);
741                                                                drawscreen(skin, 0, 0);
742                                                                setfbtransparent(255);
743                                                                debug(50, "check");
744                                                                debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
745                                                                debug(50, "status.play: %d", status.play);
746                                                        }
747                                                        else if(flag == 2)
748                                                        {
749                                                                addscreenrc(apskin, listbox);
750                                                                drawscreen(apskin, 0, 0);
751                                                                debug(50, "check");
752                                                                debug(50, "autostart_playlist: %d", getconfigint("mc_ap_autostart_playlist", NULL));
753                                                                debug(50, "status.play: %d", status.play);                             
754                                                        }
755                       
756//                                                      playerret = playerstart(*filename);
757                                                        if(getconfigint("playertype", NULL) == 1 && cmpfilenameext(*filename, ".ts") == 0)
758                                                                *playertype = 1;
759                                                        else
760                                                                *playertype = 0;
761                                       
762                                                        if(*playertype == 1)
763                                                                playerret = playerstartts(*filename, 0);
764                                                        else
765                                                                playerret = playerstart(*filename);
766                                       
767                                                        playwritevfd(*filename, NULL);
768                               
769       
770                                                        #ifndef SIMULATE
771                                                        if(playerret != 0)
772                                                        {
773                                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
774                                                                *eof = 1;
775                                                        }
776                                                        #endif
777       
778                                                        status.play = 1;
779                                                }
780                                                *playlist = 1;
781                                                free(firsttitle), firsttitle = NULL;
782                                        }
783                                }
784                        }
785                        else
786                        {
787                                screenmainplaylist(0);
788                                writeallconfig(0);
789                                drawscreen(apskin, 0, 0);
790                        }
791                        freemenulist(mlist, 1);
792                }
793        }
794        else
795        {
796                FILE *fd = NULL;
797                char *fileline = NULL;
798                int linecount = 0;
799                int httpstream = 0;
800
801                fileline = malloc(MINMALLOC);
802                if(fileline == NULL)
803                {
804                        err("no memory");
805                        return;
806                }
807
808                fd = fopen(*filename, "r");
809                if(fd == NULL)
810                {
811                        perr("can't open %s", *filename);
812                        free(fileline);
813                        return;
814                }
815               
816                // clear listbox, not working ?
817                delmarkedscreennodes(apskin, 2);
818
819                char* firstfile = NULL;
820                char* firsttitle = NULL;
821                while(fgets(fileline, MINMALLOC, fd) != NULL)
822                {
823                        int addcurrdir = 0;
824                        if(fileline[0] == '#' || fileline[0] == '\n')
825                                continue;
826                        if(fileline[0] == '/')
827                                addcurrdir = 1;
828                        if(strlen(fileline) >= 6 && fileline[4] == ':' && fileline[5] == '/' && fileline[6] == '/')
829                        {
830                                addcurrdir = 1;
831                                httpstream = 1;
832                        }
833                        if(fileline[strlen(fileline) - 1] == '\n')
834                                fileline[strlen(fileline) - 1] = '\0';
835                        if(fileline[strlen(fileline) - 1] == '\r')
836                                fileline[strlen(fileline) - 1] = '\0';
837
838                        linecount++;
839
840                        tmp = addlistbox(apskin, listbox, tmp, 2);
841                        if(tmp != NULL)
842                        {
843                                int count1 = 0;
844                                char* tmpstr1 = NULL;
845                                tmpstr1 = ostrcat("", fileline, 0, 0);
846
847                                int i = 0;
848                                struct splitstr* ret1 = NULL;
849                                ret1 = strsplit(tmpstr1, "/", &count1);
850                                if(count1 >= 1)
851                                        i = count1 - 1;
852                                count ++;
853                                debug(50, "addlistbox (%d) %s", count, fileline);
854
855                                title = ostrcat("(", oitoa(count), 0, 1);
856                                if(count < 10)
857                                        title = ostrcat(title, ")    ", 1, 0);
858                                else if(count < 100)
859                                        title = ostrcat(title, ")   ", 1, 0);
860                                else
861                                        title = ostrcat(title, ")  ", 1, 0);
862
863                                title = ostrcat(title, (&ret1[i])->part, 1, 0);
864                                changetext(tmp, _(title));
865
866                                if(firstfile == NULL)
867                                {
868                                        if(addcurrdir == 0)
869                                        {
870                                                if(flag == 1)
871                                                        firstfile = ostrcat(getconfig("mc_vp_path", NULL), "/", 0, 0);
872                                                else if(flag == 2)
873                                                        firstfile = ostrcat(getconfig("mc_ap_path", NULL), "/", 0, 0);
874
875                                                firstfile = ostrcat(firstfile, fileline, 1, 0);
876                                        }
877                                        else
878                                                firstfile = ostrcat("", fileline, 0, 0);
879
880                                        firsttitle = ostrcat("", title, 0, 0);                 
881                                }
882                                free(ret1), ret1 = NULL;
883                                free(tmpstr1), tmpstr1 = NULL;
884
885                                if(addcurrdir == 0)
886                                {                                       
887                                        char* tmpstr3 = NULL;
888
889                                        if(flag == 1)
890                                                tmpstr3 = ostrcat(getconfig("mc_vp_path", NULL), "/", 0, 0);
891                                        else if(flag == 2)
892                                                tmpstr3 = ostrcat(getconfig("mc_ap_path", NULL), "/", 0, 0);
893
894                                        tmpstr3 = ostrcat(tmpstr3, fileline, 1, 0);
895                                        changename(tmp, tmpstr3);
896                                        free(tmpstr3), tmpstr3 = NULL;
897                                }
898                                else
899                                        changename(tmp, fileline);
900
901
902                                //tmp->handle = (char*)fileline;
903                                tmp->del = 2;
904                        }
905                }
906
907                if(*filename[0] == '/')
908                {
909                        int count3 = 0;
910                        char* tmpstr3 = NULL;
911                        char* title = NULL;
912                        tmpstr3 = ostrcat("", *filename, 0, 0);
913
914                        struct splitstr* ret3 = NULL;
915                        ret3 = strsplit(tmpstr3, "/", &count3);
916                        count = count3 - 1;
917                        title = ostrcat("", (&ret3[count])->part, 0, 0);
918                        *currentdirectory= ostrcat("Playlist: ", title, 0, 0);
919                        free(ret3), ret3 = NULL;
920                        free(tmpstr3), tmpstr3 = NULL;
921                        free(title), title = NULL;
922                }
923                else
924                {
925                        *currentdirectory= ostrcat("Playlist: ", *filename, 0, 0);
926                }
927
928                changetext(filelistpath, _(*currentdirectory));
929
930                filelist->hidden = YES;
931                listbox->hidden = NO;
932
933//              changetext(b2, _("Playlist-Mode"));
934                changetext(b2, _("Playlist"));
935                delownerrc(apskin);
936                addscreenrc(apskin, listbox);
937                drawscreen(apskin, 0, 0);
938                // show playlist end   
939
940                if(firstfile != NULL)
941                {
942                        playrcstop(*playertype, flag);
943                        setlistboxselection(listbox, *filename);
944                        *filename = ostrcat("", firstfile, 0, 0);
945                        title = ostrcat("", firsttitle, 0, 0);
946
947                        //if(flag == 2)
948//                              changetext(b2, _("Playlist-Mode"));
949                                changetext(b2, _("Playlist"));
950
951                        if(screensaver != NULL && screensaver->type == 0 && flag == 2)
952                                screensaver->value = title;
953
954                        sleep(1);
955
956                        if(flag == 1  && status.play == 1)
957                        {
958                                servicestop(status.aktservice, 1, 1);
959                                drawscreen(skin, 0, 0);
960                                setfbtransparent(255);
961                                debug(50, "check");
962                                debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
963                                debug(50, "status.play: %d", status.play);
964                                debug(50, "flag: %d", flag);
965                        }
966                        else if(flag == 2  && status.play == 1)
967                        {
968                                addscreenrc(apskin, listbox);
969                                drawscreen(apskin, 0, 0);
970                                debug(50, "check");
971                                debug(50, "autostart_playlist: %d", getconfigint("mc_ap_autostart_playlist", NULL));
972                                debug(50, "status.play: %d", status.play);                             
973                                debug(50, "flag: %d", flag);
974                        }
975
976                        // show playlist end
977                        if((getconfigint("mc_vp_autostart_playlist", NULL) == 1 && flag == 1 && status.play == 0) || (getconfigint("mc_ap_autostart_playlist", NULL) == 1 && flag == 2 && status.play == 0))
978                        {
979                                delownerrc(apskin);
980                                debug(50, "-------------- check ok m3u --------------");
981                                debug(50, "playerstart: %s", *filename);
982                                debug(50, "flag: %d", flag);
983                                debug(50, "playertype: %d", *playertype);
984
985                                if(flag == 1)
986                                {
987                                        servicestop(status.aktservice, 1, 1);
988                                        drawscreen(skin, 0, 0);
989                                        setfbtransparent(255);
990                                        debug(50, "check");
991                                        debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
992                                        debug(50, "status.play: %d", status.play);
993                                }
994                                else if(flag == 2)
995                                {
996                                        addscreenrc(apskin, listbox);
997                                        drawscreen(apskin, 0, 0);
998                                        debug(50, "check");
999                                        debug(50, "autostart_playlist: %d", getconfigint("mc_ap_autostart_playlist", NULL));
1000                                        debug(50, "status.play: %d", status.play);                             
1001                                }
1002
1003//                              playerret = playerstart(*filename);
1004                                if(getconfigint("playertype", NULL) == 1 && cmpfilenameext(*filename, ".ts") == 0)
1005                                        *playertype = 1;
1006                                else
1007                                        *playertype = 0;
1008               
1009                                if(*playertype == 1)
1010                                        playerret = playerstartts(*filename, 0);
1011                                else
1012                                        playerret = playerstart(*filename);
1013
1014                                playwritevfd(*filename, NULL);
1015                               
1016                                //playwritevfd(*filename, NULL);
1017                                #ifndef SIMULATE
1018                                        if(playerret != 0)
1019                                        {
1020                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1021
1022                                                *eof = 1;
1023                                        }
1024                                #endif
1025       
1026                                status.play = 1;
1027                                if(flag == 1)
1028                                        screenplayinfobar(*filename, NULL, 0, 0, 0);
1029                        }                               
1030
1031                        *playlist = 1;
1032
1033                        free(fileline), fileline = NULL;
1034                        free(firstfile), firstfile = NULL;
1035                        free(firsttitle), firsttitle = NULL;
1036                }
1037                fclose(fd);
1038        }
1039}
1040
1041void mc_audioplayer_infobar(struct skin* apskin, struct skin* infobar, struct skin* spos, struct skin* slen, struct skin* sreverse, struct skin* sprogress, struct skin* b12, struct skin* b13, char* filename)
1042{
1043        debug(50, "infobar start");
1044
1045        char* tmpstr = NULL;
1046        unsigned long long int pos = 0, len = 0, reverse = 0;
1047
1048        pos = playergetpts() / 90000;
1049        len = playergetlength();
1050        reverse = len - pos;
1051
1052        debug(50, "pos: %llu", pos);
1053        debug(50, "len: %llu", len);
1054        debug(50, "reverse: %llu", reverse);
1055
1056        if(len == 0)
1057                sprogress->progresssize = 0;
1058        else
1059                sprogress->progresssize = pos * 100 / len;
1060
1061        tmpstr = convert_timesec(pos);
1062        changetext(spos, _(tmpstr));
1063        free(tmpstr); tmpstr = NULL;
1064
1065        tmpstr = convert_timesec(len);
1066        changetext(slen, _(tmpstr));
1067        free(tmpstr); tmpstr = NULL;
1068
1069        tmpstr = convert_timesec(reverse);
1070        changetext(sreverse, _(tmpstr));
1071        free(tmpstr); tmpstr = NULL;
1072
1073        if(status.random == 1)
1074                changetext(b12, _("Random-On"));
1075        else
1076                changetext(b12, _("Random"));   
1077
1078        if(status.repeat == 1)
1079                changetext(b13, _("Repeat-On"));
1080        else
1081                changetext(b13, _("Repeat"));
1082
1083        drawscreen(infobar, 0, 0);
1084}
1085
1086void picplayer(struct skin* picscreen, struct skin* picture, struct skin* picname, char* filename, int flag)
1087{
1088        if(filename == NULL)
1089        {
1090                clearscreen(picscreen);
1091                drawscreen(skin, 0, 0);
1092                return;
1093        }
1094
1095        char* tmpstr = NULL;
1096
1097        tmpstr = ostrcat(filename, "", 0, 0);
1098
1099        if(getconfigint("mc_pp_showpictitle", NULL) == 1 && tmpstr != NULL) changetext(picname,_((basename(tmpstr))));
1100        free(tmpstr); tmpstr = NULL;
1101
1102        changepic(picture, filename);
1103        picture->picwidth = 1;
1104        picture->picheight = 1;
1105        picture->bgcol = 0;
1106        picture->picquality = getconfigint("mc_pp_picquality", NULL);
1107
1108        drawscreen(picscreen, 0, 4);
1109}
1110
1111#endif
Note: See TracBrowser for help on using the repository browser.