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

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

[titan] update mediadb stuff

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