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

Last change on this file since 25932 was 25932, checked in by obi, 9 years ago

next step translate

File size: 28.1 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
271                        if(screensaver != NULL && screensaver->type == 3 && flag == 2)
272                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
273               
274                        drawscreen(apskin, 0, 0);
275               
276                        int switchtofilelist = 0;
277                                               
278                        if(status.random == 1 && status.repeat == 0)
279                        {
280                                int maxdirs = 0, maxfiles = 0;
281                                getplaylistmaxold(listbox, &maxdirs, &maxfiles);
282                                struct skin* tmplist = getplaylistrandomold(listbox, maxdirs, maxfiles);
283                                debug(50, "struct skin xtext=%s", tmplist->text);
284                                if(tmplist != NULL)
285                                {
286                                        debug(50, "struct skin randomtext=%s", tmplist->text);
287                                        setlistboxselection(listbox, tmplist->name);
288                                }
289                        }
290                        else
291                        {
292                                if(status.repeat == 0)
293                                {
294                                        debug(50, "writerc: rcdown next file");
295
296                                        debug(50, "listbox->aktline: %d", listbox->aktline);
297                                        debug(50, "listbox->linecount: %d", listbox->linecount);
298                                        debug(50, "*eof: %d", *eof);
299                                        debug(50, "flag: %d", flag);
300                       
301
302                                        if(*eof == 0)
303                                        {
304                                                if(listbox->aktline < listbox->linecount)
305                                                {
306                                                        listbox->aktline ++;
307//                                                      if(flag == 1)
308//                                                      {
309//                                                              apskin->hidden = YES;
310//                                                              delownerrc(apskin);
311//                                                              drawscreen(skin, 0, 0);
312//                                                      }
313                                                }
314                                                else
315                                                {
316                                                        if(flag != 3)
317                                                                playrcstop(playertype, flag);
318                                                        if((flag == 1) || (flag == 3))
319                                                        {
320                                                                apskin->hidden = NO;
321                                                                filelist->hidden = NO;
322                                                                listbox->hidden = YES;
323
324                                                                if(flag == 1)
325                                                                        changetext(filelistpath, _(getconfig("mc_vp_path", NULL)));
326                                                                else if(flag == 2)
327                                                                        changetext(filelistpath, _(getconfig("mc_ap_path", NULL)));
328                                                                else if(flag == 3)
329                                                                {
330                                                                        changetext(filelistpath, _(getconfig("mc_pp_path", NULL)));
331                                                                        picplayer(picscreen, picture, picname, NULL, 0);
332                                                                        clearscreen(picscreen);
333                                                                }
334
335                                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
336                                                                changetext(b2, _("Filelist-Mode"));
337                                                                writevfdmenu("Filelist-Mode");
338                                                                switchtofilelist = 1;
339       
340                                                                drawscreen(skin, 0, 0);
341                                                               
342                                                                // show skin
343                                                                setfbtransparent(255);
344
345                                                                *playlist = 0;
346                                                        }
347                                                        else
348                                                        {
349                                                                if(screensaver != NULL && screensaver->type == 3 && flag == 2)
350                                                                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
351                                                        }
352                                                        skiprcok = 1;
353                                                }
354                                        }
355                                        else if(*eof == 1)
356                                        {
357                                                if(listbox->aktline < listbox->linecount)
358                                                        listbox->aktline ++;
359                                                        if(flag == 1)
360                                                        {
361                                                                //apskin->hidden = YES;
362                                                                //delownerrc(apskin);
363                                                                drawscreen(skin, 0, 0);
364                                                        }
365                                                else
366                                                {
367                                                        status.play = 1;
368                                                        skiprcok = 1;
369                                                }
370                                        }
371                                        else if(*eof == 2)
372                                        {
373                                                if(listbox->aktline == 1)
374                                                {
375                                                        status.play = 1;
376                                                        if(screensaver != NULL && screensaver->type == 3 && flag == 2)
377                                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
378                                                        skiprcok = 1;
379                                                }
380                                                else
381                                                {
382                                                        listbox->aktline --;
383                                                        if(flag == 1)
384                                                        {
385                                                                //apskin->hidden = YES;
386                                                                //delownerrc(apskin);
387                                                                drawscreen(skin, 0, 0);
388                                                        }
389                                                        // workaround dont open folder on rcchup
390                                                        *skip = 1;
391                                                }
392                                        }
393
394                                        *eof = 0;
395
396                                        debug(50, "listbox->aktline: %d", listbox->aktline);
397                                        debug(50, "listbox->linecount: %d", listbox->linecount);
398                                }
399                        }
400                        delownerrc(apskin);
401                        if(switchtofilelist == 0)
402                                addscreenrc(apskin, listbox);
403                        else
404                                addscreenrc(apskin, filelist);                 
405                }
406                else
407                {
408                        changetext(b2, _("Filelist-Mode"));
409               
410                        if(screensaver != NULL && screensaver->type == 3 && flag == 2)
411                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
412
413                        if(flag != 3)
414                                drawscreen(apskin, 0, 0);
415
416                        if(status.random == 1 && status.repeat == 0)
417                        {
418                                int maxdirs = 0, maxfiles = 0;
419                                getfilelistmax(filelist, &maxdirs, &maxfiles);
420                                struct skin* tmplist = getfilelistrandom(filelist, maxdirs, maxfiles);
421                                debug(50, "struct skin xtext=%s", tmplist->text);
422                                if(tmplist != NULL)
423                                {
424                                        debug(50, "struct skin randomtext=%s", tmplist->text);
425                                        setlistboxselection(filelist, tmplist->name);
426                                }
427                        }
428                        else
429                        {
430                                if(status.repeat == 0)
431                                {
432                                        debug(50, "writerc: rcdown next file");
433
434                                        debug(50, "filelist->aktline: %d", filelist->aktline);
435                                        debug(50, "filelist->linecount: %d", filelist->linecount);
436
437                                        if(*eof == 0)
438                                        {
439                                                if(filelist->aktline < filelist->linecount)
440                                                {
441                                                        filelist->aktline ++;
442                                                }
443                                                else
444                                                {                                                       
445                                                        if(flag != 3)
446                                                                playrcstop(playertype, flag);
447                                                        if((flag == 1) || (flag == 3))
448                                                        {
449                                                                if(flag == 3)
450                                                                {
451                                                                        picplayer(picscreen, picture, picname, NULL, 0);
452                                                                        clearscreen(picscreen);
453                                                                }
454
455                                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
456
457                                                                apskin->hidden = NO;
458                                                                filelist->hidden = NO;
459                                                                listbox->hidden = YES;
460
461                                                                // switch filelist
462                                                                delownerrc(apskin);
463                                                                addscreenrc(apskin, filelist);
464
465                                                                setfbtransparent(255);
466                                                        }
467                                                        else
468                                                        {
469                                                                if(screensaver != NULL && screensaver->type == 3 && flag == 2)
470                                                                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
471                                                        }
472                                                        skiprcok = 1;
473                                                }
474
475                                        }
476                                        else if(*eof == 1)
477                                        {
478                                                if(filelist->aktline < filelist->linecount)
479                                                        filelist->aktline ++;
480                                                else
481                                                {
482                                                        status.play = 1;
483                                                        skiprcok = 1;
484                                                }
485                                        }
486                                        else if(*eof == 2)
487                                        {
488                                                if(filelist->aktline == 1)
489                                                {
490                                                        status.play = 1;
491                                                        if(screensaver != NULL && screensaver->type == 3 && flag == 2)
492                                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
493                                                        skiprcok = 1;
494                                                }
495                                                else
496                                                {
497                                                        filelist->aktline --;
498                                                        // workaround dont open folder on rcchup
499                                                        *skip = 1;
500                                                }
501                                        }
502
503                                        *eof = 0;
504
505                                        debug(50, "filelist->aktline: %d", filelist->aktline);
506                                        debug(50, "filelist->linecount: %d", filelist->linecount);
507                                }
508                        }
509                        delownerrc(apskin);
510                        addscreenrc(apskin, filelist);
511                }
512
513                debug(50, "flag: %d", flag);
514                debug(50, "skiprcok: %d", skiprcok);                                   
515
516                if(flag == 3 && skiprcok == 0)
517                        drawscreen(apskin, 2, 0);
518                else
519                        drawscreen(apskin, 0, 0);
520                       
521                if(skiprcok == 0)
522                        writerc(getrcconfigint("rcok", NULL));
523}
524
525void playerrandom(struct skin* apskin, struct skin* filelist, struct skin* listbox, struct skin* b3, int playlist, int flag)
526{
527        if(playlist == 0)
528        {
529                debug(50, "rcyellow: random");
530                if(status.random == 0)
531                {
532                        int maxdirs = 0, maxfiles = 0;
533                        getfilelistmax(filelist, &maxdirs, &maxfiles);
534                        struct skin* tmplist = getfilelistrandom(filelist, maxdirs, maxfiles);
535
536                        if(tmplist != NULL)
537                        {
538                                debug(50, "struct skin randomtext=%s", tmplist->text);
539                                setlistboxselection(filelist, tmplist->name);
540//                              if(flag == 2)
541                                        changetext(b3, _("Random-On"));
542                                drawscreen(apskin, 0, 0);
543                                status.random = 1;
544                                debug(50, "writerc rcok");
545                                writerc(getrcconfigint("rcok", NULL));
546                        }
547                }
548                else
549                {
550                        status.random = 0;
551//                      if(flag == 2)
552                                changetext(b3, _("Random"));
553                        drawscreen(apskin, 0, 0);
554                }
555        }
556        else
557        {
558                debug(50, "rcyellow: random");
559                if(status.random == 0)
560                {
561                        int maxdirs = 0, maxfiles = 0;
562                        getplaylistmaxold(listbox, &maxdirs, &maxfiles);
563                        struct skin* tmplist = getplaylistrandomold(listbox, maxdirs, maxfiles);
564                        if(tmplist != NULL)
565                        {
566                                debug(50, "struct skin randomtext=%s", tmplist->text);
567                                setlistboxselection(listbox, tmplist->name);
568//                              if(flag == 2)
569                                        changetext(b3, _("Random-On"));
570                                drawscreen(apskin, 0, 0);
571                                status.random = 1;
572                                debug(50, "writerc rcok");
573                                writerc(getrcconfigint("rcok", NULL));
574                        }
575                }
576                else
577                {
578                        status.random = 0;
579//                      if(flag == 2)
580                                changetext(b3, _("Random"));
581                        drawscreen(apskin, 0, 0);
582                }
583        }
584}
585
586void 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)
587{
588        int playerret = 0;
589        struct skin* tmp = NULL;
590        struct mainplaylist* mplaylist = NULL;
591        struct playlist* playlistnode = NULL;
592        struct menulist* mlist = NULL, *mbox = NULL;
593        char* title = NULL;
594        int count = 0;
595
596        if(mode == 0)
597        {
598                debug(50, "rcgreenss: playlist menu");
599
600                addmenulist(&mlist, _("Load Playlist"), NULL, NULL, 0, 0);
601                addmenulist(&mlist, _("Edit Playlist"), NULL, NULL, 0, 0);
602               
603                mbox = menulistbox(mlist, "playlistmenu", NULL, "%pluginpath%/mc/skin", NULL, 1, 0);
604
605                drawscreen(apskin, 0, 0);
606
607                if(mbox != NULL)
608                {
609                        if(ostrcmp(mbox->name, _("Load Playlist")) == 0)
610                        {
611//                              *count = 0;
612//                              *rcwait = 1000;
613       
614                                status.playspeed = 0;
615                                status.pause = 0;
616                                status.play = 0;
617
618                                mplaylist = screenmainplaylist(1);
619                                drawscreen(apskin, 0, 0);
620
621                                if(mplaylist != NULL && mplaylist->playlist != NULL)
622                                {
623                                        playlistnode = NULL;
624                                        playlistnode = mplaylist->playlist;
625                                        if(playlistnode->file != NULL)
626                                        {
627                                                *filename = ostrcat("", playlistnode->file, 0, 0);
628                                                playrcstop(*playertype, flag);
629
630                                                count = 0;
631
632                                                // clear listbox, not working ?
633                                                delmarkedscreennodes(apskin, 2);
634
635                                                char* firsttitle = NULL;
636                                                while(playlistnode != NULL)
637                                                {
638                                                        tmp = addlistbox(apskin, listbox, tmp, 2);
639                                                        if(tmp != NULL)
640                                                        {
641                                                                int count1 = 0;
642                                                                char* tmpstr1 = NULL;
643                                                                tmpstr1 = ostrcat("", playlistnode->file, 0, 0);
644
645                                                                int i = 0;
646                                                                struct splitstr* ret1 = NULL;
647                                                                ret1 = strsplit(tmpstr1, "/", &count1);
648                                                                if(count1 >= 1)
649                                                                        i = count1 - 1;
650                                                                count ++;
651                                                                debug(50, "addlistbox (%d) %s", count, playlistnode->file);
652
653                                                                title = ostrcat("(", oitoa(count), 0, 1);
654                                                                if(count < 10)
655                                                                        title = ostrcat(title, ")    ", 1, 0);
656                                                                else if(count < 100)
657                                                                        title = ostrcat(title, ")   ", 1, 0);
658                                                                else
659                                                                        title = ostrcat(title, ")  ", 1, 0);
660
661                                                                title = ostrcat(title, (&ret1[i])->part, 1, 0);
662                                                                changetext(tmp, _(title));
663
664                                                                if(firsttitle == NULL)
665                                                                        firsttitle = ostrcat("", title, 0, 0);                 
666
667                                                                free(ret1), ret1 = NULL;
668                                                                free(tmpstr1), tmpstr1 = NULL;
669
670                                                                // new
671
672                                                                changename(tmp, playlistnode->file);
673                                                                tmp->handle = (char*)playlistnode;
674                                                                tmp->del = 2;
675                                                        }
676                                                        playlistnode = playlistnode->next;
677                                                }
678
679                                                *currentdirectory = ostrcat("Playlist: ", mplaylist->name, 0, 0);
680                                                changetext(filelistpath, _(*currentdirectory));
681                                                filelist->hidden = YES;
682                                                listbox->hidden = NO;
683
684                                                // workaround playereof
685                                                playlistnode = NULL;
686                                                playlistnode = mplaylist->playlist;
687
688                                                setlistboxselection(listbox, *filename);
689                                                if(firsttitle == NULL)
690                                                        firsttitle = ostrcat("", "dummy no read title", 0, 0);                                         
691
692                                                title = ostrcat("", firsttitle, 0, 0);
693                                                changetext(b2, _("Playlist-Mode"));
694
695                                                if(screensaver != NULL && screensaver->type == 0)
696                                                        screensaver->value = title;
697
698                                                delownerrc(apskin);
699                                                addscreenrc(apskin, listbox);
700                                                drawscreen(apskin, 0, 0);
701                                                // show playlist end   
702                                                sleep(1);
703
704                                                if(flag == 1  && status.play == 1)
705                                                {
706                                                        servicestop(status.aktservice, 1, 1);
707                                                        drawscreen(skin, 0, 0);
708                                                        setfbtransparent(255);
709                                                        debug(50, "check");
710                                                        debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
711                                                        debug(50, "status.play: %d", status.play);
712                                                        debug(50, "flag: %d", flag);
713                                                }
714                                                else if(flag == 2  && status.play == 1)
715                                                {
716                                                        addscreenrc(apskin, listbox);
717                                                        drawscreen(apskin, 0, 0);
718                                                        debug(50, "check");
719                                                        debug(50, "autostart_playlist: %d", getconfigint("mc_ap_autostart_playlist", NULL));
720                                                        debug(50, "status.play: %d", status.play);                             
721                                                        debug(50, "flag: %d", flag);
722                                                }
723                       
724                                                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))
725                                                {
726                                                        debug(50, "-------------- check ok titan playlist pls --------------");
727                                                        debug(50, "playerstart: %s", *filename);
728                                                        debug(50, "flag: %d", flag);
729                                                        debug(50, "playertype: %d", *playertype);       
730                                                                                       
731                                                        if(flag == 1)
732                                                        {
733                                                                servicestop(status.aktservice, 1, 1);
734                                                                drawscreen(skin, 0, 0);
735                                                                setfbtransparent(255);
736                                                                debug(50, "check");
737                                                                debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
738                                                                debug(50, "status.play: %d", status.play);
739                                                        }
740                                                        else if(flag == 2)
741                                                        {
742                                                                addscreenrc(apskin, listbox);
743                                                                drawscreen(apskin, 0, 0);
744                                                                debug(50, "check");
745                                                                debug(50, "autostart_playlist: %d", getconfigint("mc_ap_autostart_playlist", NULL));
746                                                                debug(50, "status.play: %d", status.play);                             
747                                                        }
748                       
749//                                                      playerret = playerstart(*filename);
750                                                        if(getconfigint("playertype", NULL) == 1 && cmpfilenameext(*filename, ".ts") == 0)
751                                                                *playertype = 1;
752                                                        else
753                                                                *playertype = 0;
754                                       
755                                                        if(*playertype == 1)
756                                                                playerret = playerstartts(*filename, 0);
757                                                        else
758                                                                playerret = playerstart(*filename);
759                                       
760                                                        playwritevfd(*filename, NULL);
761                               
762       
763                                                        #ifndef SIMULATE
764                                                        if(playerret != 0)
765                                                        {
766                                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
767                                                                *eof = 1;
768                                                        }
769                                                        #endif
770       
771                                                        status.play = 1;
772                                                }
773                                                *playlist = 1;
774                                                free(firsttitle), firsttitle = NULL;
775                                        }
776                                }
777                        }
778                        else
779                        {
780                                screenmainplaylist(0);
781                                writeallconfig(0);
782                                drawscreen(apskin, 0, 0);
783                        }
784                        freemenulist(mlist, 1);
785                }
786        }
787        else
788        {
789                FILE *fd = NULL;
790                char *fileline = NULL;
791                int linecount = 0;
792                int httpstream = 0;
793
794                fileline = malloc(MINMALLOC);
795                if(fileline == NULL)
796                {
797                        err("no memory");
798                        return;
799                }
800
801                fd = fopen(*filename, "r");
802                if(fd == NULL)
803                {
804                        perr("can't open %s", *filename);
805                        free(fileline);
806                        return;
807                }
808               
809                // clear listbox, not working ?
810                delmarkedscreennodes(apskin, 2);
811
812                char* firstfile = NULL;
813                char* firsttitle = NULL;
814                while(fgets(fileline, MINMALLOC, fd) != NULL)
815                {
816                        int addcurrdir = 0;
817                        if(fileline[0] == '#' || fileline[0] == '\n')
818                                continue;
819                        if(fileline[0] == '/')
820                                addcurrdir = 1;
821                        if(strlen(fileline) >= 6 && fileline[4] == ':' && fileline[5] == '/' && fileline[6] == '/')
822                        {
823                                addcurrdir = 1;
824                                httpstream = 1;
825                        }
826                        if(fileline[strlen(fileline) - 1] == '\n')
827                                fileline[strlen(fileline) - 1] = '\0';
828                        if(fileline[strlen(fileline) - 1] == '\r')
829                                fileline[strlen(fileline) - 1] = '\0';
830
831                        linecount++;
832
833                        tmp = addlistbox(apskin, listbox, tmp, 2);
834                        if(tmp != NULL)
835                        {
836                                int count1 = 0;
837                                char* tmpstr1 = NULL;
838                                tmpstr1 = ostrcat("", fileline, 0, 0);
839
840                                int i = 0;
841                                struct splitstr* ret1 = NULL;
842                                ret1 = strsplit(tmpstr1, "/", &count1);
843                                if(count1 >= 1)
844                                        i = count1 - 1;
845                                count ++;
846                                debug(50, "addlistbox (%d) %s", count, fileline);
847
848                                title = ostrcat("(", oitoa(count), 0, 1);
849                                if(count < 10)
850                                        title = ostrcat(title, ")    ", 1, 0);
851                                else if(count < 100)
852                                        title = ostrcat(title, ")   ", 1, 0);
853                                else
854                                        title = ostrcat(title, ")  ", 1, 0);
855
856                                title = ostrcat(title, (&ret1[i])->part, 1, 0);
857                                changetext(tmp, _(title));
858
859                                if(firstfile == NULL)
860                                {
861                                        if(addcurrdir == 0)
862                                        {
863                                                if(flag == 1)
864                                                        firstfile = ostrcat(getconfig("mc_vp_path", NULL), "/", 0, 0);
865                                                else if(flag == 2)
866                                                        firstfile = ostrcat(getconfig("mc_ap_path", NULL), "/", 0, 0);
867
868                                                firstfile = ostrcat(firstfile, fileline, 1, 0);
869                                        }
870                                        else
871                                                firstfile = ostrcat("", fileline, 0, 0);
872
873                                        firsttitle = ostrcat("", title, 0, 0);                 
874                                }
875                                free(ret1), ret1 = NULL;
876                                free(tmpstr1), tmpstr1 = NULL;
877
878                                if(addcurrdir == 0)
879                                {                                       
880                                        char* tmpstr3 = NULL;
881
882                                        if(flag == 1)
883                                                tmpstr3 = ostrcat(getconfig("mc_vp_path", NULL), "/", 0, 0);
884                                        else if(flag == 2)
885                                                tmpstr3 = ostrcat(getconfig("mc_ap_path", NULL), "/", 0, 0);
886
887                                        tmpstr3 = ostrcat(tmpstr3, fileline, 1, 0);
888                                        changename(tmp, tmpstr3);
889                                        free(tmpstr3), tmpstr3 = NULL;
890                                }
891                                else
892                                        changename(tmp, fileline);
893
894
895                                //tmp->handle = (char*)fileline;
896                                tmp->del = 2;
897                        }
898                }
899
900                if(*filename[0] == '/')
901                {
902                        int count3 = 0;
903                        char* tmpstr3 = NULL;
904                        char* title = NULL;
905                        tmpstr3 = ostrcat("", *filename, 0, 0);
906
907                        struct splitstr* ret3 = NULL;
908                        ret3 = strsplit(tmpstr3, "/", &count3);
909                        count = count3 - 1;
910                        title = ostrcat("", (&ret3[count])->part, 0, 0);
911                        *currentdirectory= ostrcat("Playlist: ", title, 0, 0);
912                        free(ret3), ret3 = NULL;
913                        free(tmpstr3), tmpstr3 = NULL;
914                        free(title), title = NULL;
915                }
916                else
917                {
918                        *currentdirectory= ostrcat("Playlist: ", *filename, 0, 0);
919                }
920
921                changetext(filelistpath, _(*currentdirectory));
922
923                filelist->hidden = YES;
924                listbox->hidden = NO;
925
926                changetext(b2, _("Playlist-Mode"));
927                delownerrc(apskin);
928                addscreenrc(apskin, listbox);
929                drawscreen(apskin, 0, 0);
930                // show playlist end   
931
932                if(firstfile != NULL)
933                {
934                        playrcstop(*playertype, flag);
935                        setlistboxselection(listbox, *filename);
936                        *filename = ostrcat("", firstfile, 0, 0);
937                        title = ostrcat("", firsttitle, 0, 0);
938
939                        //if(flag == 2)
940                                changetext(b2, _("Playlist-Mode"));
941
942                        if(screensaver != NULL && screensaver->type == 0 && flag == 2)
943                                screensaver->value = title;
944
945                        sleep(1);
946
947                        if(flag == 1  && status.play == 1)
948                        {
949                                servicestop(status.aktservice, 1, 1);
950                                drawscreen(skin, 0, 0);
951                                setfbtransparent(255);
952                                debug(50, "check");
953                                debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
954                                debug(50, "status.play: %d", status.play);
955                                debug(50, "flag: %d", flag);
956                        }
957                        else if(flag == 2  && status.play == 1)
958                        {
959                                addscreenrc(apskin, listbox);
960                                drawscreen(apskin, 0, 0);
961                                debug(50, "check");
962                                debug(50, "autostart_playlist: %d", getconfigint("mc_ap_autostart_playlist", NULL));
963                                debug(50, "status.play: %d", status.play);                             
964                                debug(50, "flag: %d", flag);
965                        }
966
967                        // show playlist end
968                        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))
969                        {
970                                delownerrc(apskin);
971                                debug(50, "-------------- check ok m3u --------------");
972                                debug(50, "playerstart: %s", *filename);
973                                debug(50, "flag: %d", flag);
974                                debug(50, "playertype: %d", *playertype);
975
976                                if(flag == 1)
977                                {
978                                        servicestop(status.aktservice, 1, 1);
979                                        drawscreen(skin, 0, 0);
980                                        setfbtransparent(255);
981                                        debug(50, "check");
982                                        debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
983                                        debug(50, "status.play: %d", status.play);
984                                }
985                                else if(flag == 2)
986                                {
987                                        addscreenrc(apskin, listbox);
988                                        drawscreen(apskin, 0, 0);
989                                        debug(50, "check");
990                                        debug(50, "autostart_playlist: %d", getconfigint("mc_ap_autostart_playlist", NULL));
991                                        debug(50, "status.play: %d", status.play);                             
992                                }
993
994//                              playerret = playerstart(*filename);
995                                if(getconfigint("playertype", NULL) == 1 && cmpfilenameext(*filename, ".ts") == 0)
996                                        *playertype = 1;
997                                else
998                                        *playertype = 0;
999               
1000                                if(*playertype == 1)
1001                                        playerret = playerstartts(*filename, 0);
1002                                else
1003                                        playerret = playerstart(*filename);
1004
1005                                playwritevfd(*filename, NULL);
1006                               
1007                                //playwritevfd(*filename, NULL);
1008                                #ifndef SIMULATE
1009                                        if(playerret != 0)
1010                                        {
1011                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
1012
1013                                                *eof = 1;
1014                                        }
1015                                #endif
1016       
1017                                status.play = 1;
1018                                if(flag == 1)
1019                                        screenplayinfobar(*filename, NULL, 0, 0, 0);
1020                        }                               
1021
1022                        *playlist = 1;
1023
1024                        free(fileline), fileline = NULL;
1025                        free(firstfile), firstfile = NULL;
1026                        free(firsttitle), firsttitle = NULL;
1027                }
1028                fclose(fd);
1029        }
1030}
1031
1032void 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)
1033{
1034        debug(50, "infobar start");
1035
1036        char* tmpstr = NULL;
1037        unsigned long long int pos = 0, len = 0, reverse = 0;
1038
1039        pos = playergetpts() / 90000;
1040        len = playergetlength();
1041        reverse = len - pos;
1042
1043        debug(50, "pos: %llu", pos);
1044        debug(50, "len: %llu", len);
1045        debug(50, "reverse: %llu", reverse);
1046
1047        if(len == 0)
1048                sprogress->progresssize = 0;
1049        else
1050                sprogress->progresssize = pos * 100 / len;
1051
1052        tmpstr = convert_timesec(pos);
1053        changetext(spos, _(tmpstr));
1054        free(tmpstr); tmpstr = NULL;
1055
1056        tmpstr = convert_timesec(len);
1057        changetext(slen, _(tmpstr));
1058        free(tmpstr); tmpstr = NULL;
1059
1060        tmpstr = convert_timesec(reverse);
1061        changetext(sreverse, _(tmpstr));
1062        free(tmpstr); tmpstr = NULL;
1063
1064        if(status.random == 1)
1065                changetext(b12, _("Random-On"));
1066        else
1067                changetext(b12, _("Random"));   
1068
1069        if(status.repeat == 1)
1070                changetext(b13, _("Repeat-On"));
1071        else
1072                changetext(b13, _("Repeat"));
1073
1074        drawscreen(infobar, 0, 0);
1075}
1076
1077void picplayer(struct skin* picscreen, struct skin* picture, struct skin* picname, char* filename, int flag)
1078{
1079        if(filename == NULL)
1080        {
1081                clearscreen(picscreen);
1082                drawscreen(skin, 0, 0);
1083                return;
1084        }
1085
1086        char* tmpstr = NULL;
1087
1088        tmpstr = ostrcat(filename, "", 0, 0);
1089
1090        if(getconfigint("mc_pp_showpictitle", NULL) == 1 && tmpstr != NULL) changetext(picname,_((basename(tmpstr))));
1091        free(tmpstr); tmpstr = NULL;
1092
1093        changepic(picture, filename);
1094        picture->picwidth = 1;
1095        picture->picheight = 1;
1096        picture->bgcol = 0;
1097        picture->picquality = getconfigint("mc_pp_picquality", NULL);
1098
1099        drawscreen(picscreen, 0, 4);
1100}
1101
1102#endif
Note: See TracBrowser for help on using the repository browser.