source: titan/titan/play.h @ 23743

Last change on this file since 23743 was 23743, checked in by obi, 11 years ago

fix

File size: 42.4 KB
Line 
1#ifndef PLAY_H
2#define PLAY_H
3
4extern struct screensaver* screensaver;
5
6void screenplaypolicy()
7{
8        if(checkbit(status.playercan, 0) == 0) return;
9
10        int rcret = 0;
11        struct skin* playpolicy = getscreen("playpolicy");
12        char* tmpstr = NULL;
13
14start:
15        changepolicy();
16        tmpstr = getpolicy();
17        changetext(playpolicy, _(tmpstr));
18        free(tmpstr); tmpstr = NULL;
19        drawscreen(playpolicy, 0, 0);
20
21        while(1)
22        {
23                rcret = waitrc(playpolicy, 1000, 0);
24                if(rcret == getrcconfigint("rcok", NULL))
25                        goto start;
26                break;
27        }
28
29        clearscreen(playpolicy);
30}
31
32void screenplaybufferstatus(struct stimerthread* self)
33{
34        int rcret = -1, draw = 50;
35        if(self == NULL) return;
36
37        struct skin* playbufferstatus = getscreen("playbufferstatus");
38
39        playbufferstatus->progresssize = 0;
40       
41        while(self->aktion != STOP)
42        {
43                rcret = waitrc(0, 1, 0);
44                if(rcret == getrcconfigint("rcexit", NULL))
45                {
46                        playerstopbuffer();
47                        break;
48                }
49
50                if(draw == 50)
51                {
52                        draw = 0;
53                        if(playergetbuffersize() > 0)
54                                drawscreen(playbufferstatus, 0, 0);
55                }
56                //usleep(10000);
57                draw++;
58        }
59       
60        if(playergetbuffersize() > 0)
61        {
62                clearscreen(playbufferstatus);
63                drawscreen(skin, 0, 0);
64        }
65}
66
67//flag = 4 ---> timeshift
68//flag = 5 --> timeshift, not in play mode (only recording)
69void screenplayinfobar(char* file, char* showname, int mode, int playertype, int flag)
70{
71        int change = 1;
72
73        if(checkbit(status.playercan, 14) == 0) return;
74
75        if((flag == 2) || (flag == 3))
76        {
77                return;
78        }
79        struct skin* playinfobar = getscreen("playinfobar");
80        struct skin* playinfobarpic = getscreen("playinfobarpic");
81        if(mode == 1)
82        {
83                clearscreen(playinfobar);
84                clearscreen(playinfobarpic);
85                drawscreen(skin, 0, 0);
86                return;
87        }
88
89        struct skin* title = getscreennode(playinfobar, "title");
90        struct skin* spos = getscreennode(playinfobar, "pos");
91        struct skin* slen = getscreennode(playinfobar, "len");
92        struct skin* sreverse = getscreennode(playinfobar, "reverse");
93        struct skin* sprogress = getscreennode(playinfobar, "progress");
94        char* tmpstr = NULL;
95        unsigned long long pos = 0, len = 0, reverse = 0;
96
97        // show thumb cover start
98        struct skin* playinfobarcover = getscreen("playinfobarcover");
99        struct skin* cover = getscreennode(playinfobarcover, "cover");
100        cover->hidden = YES;
101        if(file != NULL)
102        {
103                struct mediadb* node = NULL;
104                char* dname = ostrcat(file, NULL, 0, 0);
105                dname = dirname(dname);
106                node = getmediadb(dname, basename(file), 0);
107                free(dname); dname = NULL;
108               
109                if(node != NULL)
110                {
111                        if(ostrncmp("tt", node->id, 2) == 0)
112                        {
113                                tmpstr = ostrcat(tmpstr, getconfig("mediadbpath", NULL), 1, 0);
114                                tmpstr = ostrcat(tmpstr, "/", 1, 0);
115                                tmpstr = ostrcat(tmpstr, node->id, 1, 0);
116                                tmpstr = ostrcat(tmpstr, "_poster.jpg", 0, 0);
117                                if(file_exist(tmpstr))
118                                {
119                                        changepic(cover, tmpstr);
120                                        cover->hidden = NO;
121                                }
122                                free(tmpstr), tmpstr = NULL;
123                        }
124                }
125        }
126        // show thumb cover end
127
128        if(showname == NULL)
129        {
130                tmpstr = ostrcat(file, NULL, 0, 0);
131                if(tmpstr != NULL) changetext(title, basename(tmpstr));
132                free(tmpstr); tmpstr = NULL;
133        }
134        else
135                changetext(title, showname);
136
137        if(playertype == 1)
138        {
139                int ret = 0;
140                unsigned long long startpos = 0;
141                if(flag == 4)
142                        ret = playergetinfots(&len, &startpos, NULL, &pos, NULL, 1);
143                else if(flag == 5)
144                        ret = playergetinfots(&len, &startpos, NULL, &pos, NULL, 2);
145                else
146                        ret = playergetinfots(&len, &startpos, NULL, &pos, NULL, 0);
147                len = len / 90000;
148                pos = (pos - startpos) / 90000;
149                if(ret != 0) change = 0;
150        }
151        else if(playertype == 2)
152        {
153                pos = dvdgetpts() / 90000;
154                len = dvdgetlength();
155        }
156        else
157        {
158                pos = playergetpts() / 90000;
159                len = playergetlength();
160        }
161        if(pos < 0) pos = 0;
162        reverse = len - pos;
163
164        if(change == 1)
165        {
166                if(len == 0)
167                        sprogress->progresssize = 0;
168                else
169                        sprogress->progresssize = pos * 100 / len;
170        }
171
172        tmpstr = convert_timesec(pos);
173        changetext(spos, tmpstr);
174        free(tmpstr); tmpstr = NULL;
175
176        tmpstr = convert_timesec(len);
177        changetext(slen, tmpstr);
178        free(tmpstr); tmpstr = NULL;
179
180        tmpstr = convert_timesec(reverse);
181        changetext(sreverse, tmpstr);
182        free(tmpstr); tmpstr = NULL;
183
184        drawscreen(playinfobar, 0, 0);
185        drawscreen(playinfobarpic, 0, 0);
186        drawscreen(playinfobarcover, 0, 0);
187}
188
189void screenplaytracklist(int mode, int playertype, int flag)
190{
191        //mode 1 = audiotracks
192        //mode 2 = subtitle tracks
193
194        if(mode == 1 && checkbit(status.playercan, 1) == 0) return;
195        if(mode == 2 && checkbit(status.playercan, 2) == 0) return;
196
197        if(playertype == 1)
198        {
199                screenplayinfobar(NULL, NULL, 1, playertype, flag);
200                if(mode == 1)
201                        playerchangeaudiotrackts();
202                else if(mode == 2)
203                        playerchangesubtitletrackts();
204                blitfb(0);
205                return;
206        }
207
208        int i = 0;
209        int rcret = 0, curtrackid = 0;
210        struct skin* track = NULL;
211        if(mode == 1)
212                track = getscreen("audiotrack");
213        else if(mode == 2)
214                track = getscreen("subtitle");
215        struct skin* listbox = getscreennode(track, "listbox");
216        struct skin* tmp = NULL;
217        char** tracklist = NULL;
218        char* curtrackencoding = NULL, *curtrackname = NULL;
219        char* tmpstr = NULL;
220
221        playergetcurtrac(mode, &curtrackid, &curtrackencoding, &curtrackname);
222        tracklist = playergettracklist(mode);
223
224        if(tracklist != NULL)
225        {
226                while(tracklist[i] != NULL)
227                {
228                        tmp = addlistbox(track, listbox, tmp, 1);
229                        if(tmp != NULL)
230                        {
231                                if(ostrcmp(tracklist[i], "und") == 0)
232                                        tmpstr = ostrcat(tmpstr, _("undefined"), 1, 0);
233                                else
234                                        tmpstr = ostrcat(tmpstr, _(tracklist[i]), 1, 0);
235                                tmpstr = ostrcat(tmpstr, " (", 1, 0);
236                                tmpstr = ostrcat(tmpstr, tracklist[i + 1], 1, 0);
237                                tmpstr = ostrcat(tmpstr, ")", 1, 0);
238                                changetext(tmp, tmpstr);
239                                free(tmpstr); tmpstr = NULL;
240                                tmp->type = CHOICEBOX;
241                                tmp->del = 1;
242                                tmp->handle = (char*)(i / 2);
243
244                                if(ostrcmp(curtrackname, tracklist[i]) == 0 && ostrcmp(curtrackencoding, tracklist[i + 1]) == 0)
245                                {
246                                        tmp->handle1 = (char*)(i / 2);
247                                        changeinput(tmp, _("running"));
248                                }
249                                else
250                                        changeinput(tmp, "");
251                        }
252                        i += 2;
253                }
254        }
255
256        free(curtrackencoding); curtrackencoding = NULL;
257        free(curtrackname); curtrackname = NULL;
258        playerfreetracklist(tracklist);
259        tracklist = NULL;
260
261        listbox->aktline = 1;
262        listbox->aktpage = -1;
263
264        screenplayinfobar(NULL, NULL, 1, playertype, flag);
265        drawscreen(track, 0, 0);
266        addscreenrc(track, listbox);
267
268        while(1)
269        {
270                rcret = waitrc(track, 0, 0);
271
272                if(rcret == getrcconfigint("rcexit", NULL)) break;
273                if(rcret == getrcconfigint("rcok", NULL))
274                {
275                        if(listbox->select != NULL)
276                        {
277                                if(mode == 1)
278                                        playerchangeaudiotrack((int)listbox->select->handle);
279                                else if(mode == 2)
280                                {
281                                        if(listbox->select->handle1 != NULL)
282                                                playerstopsubtitletrack();
283                                        else   
284                                                playerchangesubtitletrack((int)listbox->select->handle);
285                                }
286                        }
287                        break;
288                }
289        }
290
291        delmarkedscreennodes(track, 1);
292        delownerrc(track);
293        clearscreen(track);
294        blitfb(0);
295}
296
297void playrcyellow(char* file, char* showname, int playinfobarstatus, int playertype, int flag)
298{
299//      if(checkbit(status.playercan, 1) == 0) return;
300
301        screenplaytracklist(1, playertype, flag);
302        if(playinfobarstatus > 0)
303                screenplayinfobar(file, showname, 0, playertype, flag);
304}
305
306void playrctext(char* file, char* showname, int playinfobarstatus, int playertype, int flag)
307{
308//      if(checkbit(status.playercan, 2) == 0) return;
309
310        screenplaytracklist(2, playertype, flag);
311        if(playinfobarstatus > 0)
312                screenplayinfobar(file, showname, 0, playertype, flag);
313}
314
315void playrcgreen(char* file, char* showname, int playinfobarstatus, int playertype, int flag)
316{
317//      if(checkbit(status.playercan, 3) == 0) return;
318
319        screenplayinfobar(file, showname, 1, playertype, flag);
320        if(playertype == 2)
321                screenvideomode(2);
322        else
323                screenvideomode(1);
324        drawscreen(skin, 0, 0);
325        if(playinfobarstatus > 0)
326                screenplayinfobar(file, showname, 0, playertype, flag);
327}
328
329void playrcblue(char* file, char* showname, int playinfobarstatus, int playertype, int flag)
330{
331        if(checkbit(status.playercan, 4) == 0) return;
332
333        screenplayinfobar(file, showname, 1, playertype, flag);
334        screenpowerofftimer();
335        drawscreen(skin, 0, 0);
336        if(playinfobarstatus > 0)
337                screenplayinfobar(file, showname, 0, playertype, flag);
338}
339
340void playrcok(char* file, char* showname, int playinfobarstatus, int playertype, int flag)
341{
342//      if(checkbit(status.playercan, 0) == 0) return;
343
344        free(status.playfile); status.playfile = NULL;
345        status.playfile = ostrcat(file, NULL, 0, 0);
346        screenplaypolicy(file, 1);
347        drawscreen(skin, 0, 0);
348        if(playinfobarstatus > 0)
349                screenplayinfobar(file, showname, 0, playertype, flag);
350}
351
352void id3tag_info(char* file)
353{
354        char* tmpstr = NULL;
355
356        if(file == NULL) return;
357        if(!filelistflt(".mp3 .flac .ogg .wma .ra .wav", file))
358        {
359                struct id3tag* id3tag = NULL;
360                int hash = gethash(file);
361                char* tmphash = olutoa(hash);
362                               
363                id3tag = getid3(file, tmphash, 1);
364                free(tmphash); tmphash = NULL;
365       
366                if(id3tag != NULL)
367                {
368                        tmpstr = ostrcat(tmpstr, _("Title:"), 1, 0);
369                        tmpstr = ostrcat(tmpstr, " ", 1, 0);
370                        tmpstr = ostrcat(tmpstr, id3tag->title, 1, 0);
371                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
372                       
373                        tmpstr = ostrcat(tmpstr, _("Artist:"), 1, 0);
374                        tmpstr = ostrcat(tmpstr, " ", 1, 0);
375                        tmpstr = ostrcat(tmpstr, id3tag->artist, 1, 0);
376                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
377                       
378                        tmpstr = ostrcat(tmpstr, _("Album:"), 1, 0);
379                        tmpstr = ostrcat(tmpstr, " ", 1, 0);
380                        tmpstr = ostrcat(tmpstr, id3tag->album, 1, 0);
381                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
382                       
383                        tmpstr = ostrcat(tmpstr, _("Year:"), 1, 0);
384                        tmpstr = ostrcat(tmpstr, " ", 1, 0);
385                        tmpstr = ostrcat(tmpstr, id3tag->year, 1, 0);
386                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
387               
388                        tmpstr = ostrcat(tmpstr, _("Genre:"), 1, 0);
389                        tmpstr = ostrcat(tmpstr, " ", 1, 0);
390                        tmpstr = ostrcat(tmpstr, id3tag->genretext, 1, 0);
391                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
392
393                        tmpstr = ostrcat(tmpstr, _("Comment:"), 1, 0);
394                        tmpstr = ostrcat(tmpstr, " ", 1, 0);
395                        tmpstr = ostrcat(tmpstr, id3tag->comment, 1, 0);
396                        tmpstr = ostrcat(tmpstr, "\n", 1, 0);
397                }
398                freeid3(id3tag); id3tag = NULL;         
399        }
400        else
401        {
402                tmpstr = ostrcat(tmpstr, _("Title:"), 1, 0);
403                tmpstr = ostrcat(tmpstr, " ", 1, 0);
404                tmpstr = ostrcat(tmpstr, playergetinfo("Title"), 1, 1);
405                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
406               
407                tmpstr = ostrcat(tmpstr, _("Artist:"), 1, 0);
408                tmpstr = ostrcat(tmpstr, " ", 1, 0);
409                tmpstr = ostrcat(tmpstr, playergetinfo("Artist"), 1, 1);
410                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
411               
412                tmpstr = ostrcat(tmpstr, _("Album:"), 1, 0);
413                tmpstr = ostrcat(tmpstr, " ", 1, 0);
414                tmpstr = ostrcat(tmpstr, playergetinfo("Album"), 1, 1);
415                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
416               
417                tmpstr = ostrcat(tmpstr, _("Year:"), 1, 0);
418                tmpstr = ostrcat(tmpstr, " ", 1, 0);
419                tmpstr = ostrcat(tmpstr, playergetinfo("Year"), 1, 1);
420                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
421       
422                tmpstr = ostrcat(tmpstr, _("Genre:"), 1, 0);
423                tmpstr = ostrcat(tmpstr, " ", 1, 0);
424                tmpstr = ostrcat(tmpstr, playergetinfo("Genre"), 1, 1);
425                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
426               
427                tmpstr = ostrcat(tmpstr, _("Comment:"), 1, 0);
428                tmpstr = ostrcat(tmpstr, " ", 1, 0);
429                tmpstr = ostrcat(tmpstr, playergetinfo("Comment"), 1, 1);
430                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
431               
432                tmpstr = ostrcat(tmpstr, _("Track:"), 1, 0);
433                tmpstr = ostrcat(tmpstr, " ", 1, 0);
434                tmpstr = ostrcat(tmpstr, playergetinfo("Track"), 1, 1);
435                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
436               
437                tmpstr = ostrcat(tmpstr, _("Copyright:"), 1, 0);
438                tmpstr = ostrcat(tmpstr, " ", 1, 0);
439                tmpstr = ostrcat(tmpstr, playergetinfo("Copyright"), 1, 1);
440                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
441               
442        //      tmpstr = ostrcat(tmpstr, _("TestLibEplayer:"), 1, 0);
443        //      tmpstr = ostrcat(tmpstr, " ", 1, 0);
444        //      tmpstr = ostrcat(tmpstr, playergetinfo("TestLibEplayer"), 1, 1);
445        //      tmpstr = ostrcat(tmpstr, "\n", 1, 0);
446        }
447                       
448        textbox(_("iD3Tag"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 500, 100, 0);
449        free(tmpstr), tmpstr = NULL;
450}
451
452void imdb_submenu(char* file, int mode)
453{
454        struct skin* pluginnode = NULL;
455        void (*startplugin)(char*, char*, int, char*, char*);
456
457        startplugin = NULL;
458       
459        if(mode == 0)
460                pluginnode = getplugin("IMDb");
461        else if(mode == 1)
462                pluginnode = getplugin("IMDb-API");
463        else if(mode == 2)
464                pluginnode = getplugin("TMDb");
465                       
466        if(pluginnode != NULL)
467        {                       
468                if(mode == 0)
469                        startplugin = dlsym(pluginnode->pluginhandle, "screenimdb");
470                else if(mode == 1)
471                        startplugin = dlsym(pluginnode->pluginhandle, "screenimdbapi");
472                else if(mode == 2)
473                        startplugin = dlsym(pluginnode->pluginhandle, "screentmdb");
474
475                if(startplugin != NULL)
476                {
477                                debug(133, "file=%s", basename(file));
478                        if(file != NULL)
479                        {
480                                if(ostrstr(file, "/") != NULL)
481                                {
482                                        //create imdb search name
483       
484                                        char* dname = ostrcat(file, NULL, 0, 0);
485                                        dname = dirname(dname);
486                               
487                                        char* shortname = ostrcat(basename(file), NULL, 0, 0);
488                                        string_tolower(shortname);
489        //                              shortname = string_shortname(shortname, 1);
490                                        shortname = string_shortname(shortname, 2);
491                                        string_removechar(shortname);
492                                        strstrip(shortname);
493       
494                                        debug(133, "inputfile=%s", file);
495                                        debug(133, "shortname=%s", shortname);
496                                        debug(133, "dname=%s", dname);
497                                        debug(133, "file=%s", basename(file));
498       
499                                        startplugin(shortname, NULL, 2, dname, basename(file));
500       
501                                        free(shortname), shortname = NULL;
502                                        free(dname), dname = NULL;
503                                }
504                                else
505                                {
506                                        startplugin(file, NULL, 2, NULL, NULL);
507                                }
508                               
509                        }                               
510                }
511        }
512}
513
514void get_mediadb_scan_info()
515{
516        int videocount = 0, audiocount = 0, picturecount = 0;
517        getmediadbcounts(&videocount, &audiocount, &picturecount);
518
519        char* tmpstr = NULL;
520        tmpstr = ostrcat(tmpstr, "scanning (", 1, 0);
521        tmpstr = ostrcat(tmpstr, oitoa(videocount), 1, 1);
522        tmpstr = ostrcat(tmpstr, "/", 1, 0);
523        tmpstr = ostrcat(tmpstr, oitoa(status.mediadbfiles), 1, 1);
524        tmpstr = ostrcat(tmpstr, ")", 1, 0);
525       
526        tmpstr = ostrcat(tmpstr, "\n\n ", 1, 0);
527        tmpstr = ostrcat(tmpstr, _("MediaDB directory scan started in Background !"), 1, 0);
528        tmpstr = ostrcat(tmpstr, "\n\n  ", 1, 0);
529        tmpstr = ostrcat(tmpstr, _("Delete MediaDB before scan"), 1, 0);
530        tmpstr = ostrcat(tmpstr, ": \t", 1, 0);
531        if(ostrcmp(getconfig("mediadbscandelall", NULL), "1") == 0)
532                tmpstr = ostrcat(tmpstr, _("yes"), 1, 0);
533        else
534                tmpstr = ostrcat(tmpstr, _("no"), 1, 0);
535        tmpstr = ostrcat(tmpstr, "\n  ", 1, 0);                 
536        tmpstr = ostrcat(tmpstr, _("Delete unused entrys before scan"), 1, 0);
537        tmpstr = ostrcat(tmpstr, ": \t", 1, 0);         
538        if(ostrcmp(getconfig("mediadbscandelnotfound", NULL), "1") == 0)
539                tmpstr = ostrcat(tmpstr, _("yes"), 1, 0);
540        else
541                tmpstr = ostrcat(tmpstr, _("no"), 1, 0);
542        tmpstr = ostrcat(tmpstr, "\n  ", 1, 0);
543        tmpstr = ostrcat(tmpstr, _("scan Directory"), 1, 0);
544        tmpstr = ostrcat(tmpstr, ": \t\t\t", 1, 0);
545        tmpstr = ostrcat(tmpstr, getconfig("mc_vp_path", NULL), 1, 0);
546        tmpstr = ostrcat(tmpstr, "\n  ", 1, 0);         
547        tmpstr = ostrcat(tmpstr, _("MediaDB place"), 1, 0);
548        tmpstr = ostrcat(tmpstr, ": \t\t\t", 1, 0);                             
549        tmpstr = ostrcat(tmpstr, getconfig("mediadbpath", NULL), 1, 0);
550        tmpstr = ostrcat(tmpstr, "\n  ", 1, 0);
551        tmpstr = ostrcat(tmpstr, _("MediaDB Debug"), 1, 0);
552        tmpstr = ostrcat(tmpstr, ": \t\t\t", 1, 0);
553        if(ostrcmp(getconfig("mediadbdebug", NULL), "1") == 0)
554                tmpstr = ostrcat(tmpstr, _("yes"), 1, 0);
555        else
556                tmpstr = ostrcat(tmpstr, _("no"), 1, 0);
557        tmpstr = ostrcat(tmpstr, "\n  ", 1, 0);         
558        tmpstr = ostrcat(tmpstr, _("Backdrop Download Count"), 1, 0);
559        tmpstr = ostrcat(tmpstr, ": \t\t", 1, 0);               
560        if(getconfigint("mediadbbackdrop", NULL) == 0)
561                tmpstr = ostrcat(tmpstr, _("all"), 1, 0);
562        else
563                tmpstr = ostrcat(tmpstr, oitoa(getconfigint("mediadbbackdrop", NULL)), 1, 1);
564
565        textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1100, 500, 10, 0);
566        free(tmpstr), tmpstr = NULL;
567}
568
569// flag 100 = tithek
570int playrcred(char* file, char* showname, int playinfobarstatus, int playertype, int flag)
571{
572        int ret = 1;
573//      if(checkbit(status.playercan, 5) == 0) return;
574        if(status.play == 1)
575                screenplayinfobar(file, showname, 1, playertype, flag);
576
577        int hangtime = status.hangtime;
578
579        struct skin* pluginnode = NULL;
580        void (*startplugin)(void);
581        struct skin* plugin = getscreen("plugin");
582        struct skin* child = plugin->child;
583        struct menulist* mlist = NULL, *mbox = NULL;
584        char* skintitle = "Menu";
585
586        if(flag < 99)
587        {
588                if(status.play == 1)
589                {
590                        addmenulist(&mlist, "Video Settings", NULL, NULL, 0, 0);
591                        addmenulist(&mlist, "AV Settings", NULL, NULL, 0, 0);
592                        addmenulist(&mlist, "iD3Tag Info", NULL, NULL, 0, 0);
593                }
594
595                addmenulist(&mlist, "MediaDB Edit", NULL, NULL, 0, 0);
596       
597                if(status.play == 0)
598                        addmenulist(&mlist, "Delete File", NULL, NULL, 0, 0);
599                       
600                if(status.mediadbfiles > 0)
601                        addmenulist(&mlist, "MediaDB Scan Info", NULL, NULL, 0, 0);
602        }
603        else
604        {
605                if(status.expertmodus >= 11 || file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack"))
606                {
607                        addmenulist(&mlist, "Search on Kinox", NULL, NULL, 0, 0);
608                        addmenulist(&mlist, "Search on Movie4k", NULL, NULL, 0, 0);
609                        addmenulist(&mlist, "Search on Solarmovies (movie)", NULL, NULL, 0, 0);
610                        addmenulist(&mlist, "Search on Solarmovies (serie)", NULL, NULL, 0, 0);
611                        addmenulist(&mlist, "Search on Movie4k", NULL, NULL, 0, 0);
612                }
613                addmenulist(&mlist, "Search on Youtube", NULL, NULL, 0, 0);
614                addmenulist(&mlist, "Search on MyVideo", NULL, NULL, 0, 0);
615        }
616
617        addmenulist(&mlist, "Downloads", NULL, NULL, 0, 0);
618
619        //add plugins
620        while(child != NULL)
621        {
622                if(child->del == PLUGINDELMARK && (status.security == 1 || (status.security == 0 && checkpluginskip(child->name) == 0)))
623                {
624                        if(ostrcmp(child->name, "Streaminfo") == 0 && status.play == 1)
625                                addmenulist(&mlist, child->name, NULL, child->pic, 0, 0);
626                        else if(ostrcmp(child->name, "IMDb") == 0)
627                                addmenulist(&mlist, child->name, NULL, child->pic, 0, 0);
628                        else if(ostrcmp(child->name, "IMDb-API") == 0)
629                                addmenulist(&mlist, child->name, NULL, child->pic, 0, 0);
630                        else if(ostrcmp(child->name, "TMDb") == 0)
631                                addmenulist(&mlist, child->name, NULL, child->pic, 0, 0);
632                }
633                child = child->next;
634        }
635
636        mbox = menulistbox(mlist, NULL, skintitle, NULL, NULL, 1, 0);
637        if(mbox != NULL)
638        {
639                if(ostrcmp(mbox->name, "Video Settings") == 0)
640                        screenvideosettings();
641                else if(ostrcmp(mbox->name, "AV Settings") == 0)
642                        screenavsettings(0);
643                else if(ostrcmp(mbox->name, "IMDb") == 0)
644                        imdb_submenu(file, 0);
645                else if(ostrcmp(mbox->name, "IMDb-API") == 0)
646                        imdb_submenu(file, 1);
647                else if(ostrcmp(mbox->name, "TMDb") == 0)
648                        imdb_submenu(file, 2);
649                else if(ostrcmp(mbox->name, "iD3Tag Info") == 0)
650                        id3tag_info(file);
651                else if(ostrcmp(mbox->name, "MediaDB Scan Info") == 0)
652                        get_mediadb_scan_info();
653                else if(ostrcmp(mbox->name, "MediaDB Edit") == 0)
654                        screenmediadbedit(file, 0, 0);
655                else if(ostrcmp(mbox->name, "Delete File") == 0)
656                {
657                        playcheckdirrcret(file, 1);
658                        ret = 7;
659                }
660                else if(ostrcmp(mbox->name, "Downloads") == 0)
661                        screenbgdownload(1);
662                else if(ostrcmp(mbox->name, "Search on Kinox") == 0)
663                        ret = 2;
664                else if(ostrcmp(mbox->name, "Search on Solarmovies (movie)") == 0)
665                        ret = 3;
666                else if(ostrcmp(mbox->name, "Search on Solarmovies (serie)") == 0)
667                        ret = 4;
668                else if(ostrcmp(mbox->name, "Search on Youtube") == 0)
669                        ret = 5;
670                else if(ostrcmp(mbox->name, "Search on MyVideo") == 0)
671                        ret = 6;
672                else if(ostrcmp(mbox->name, "Search on Movie4k") == 0)
673                        ret = 7;
674                else if(ostrcmp(mbox->name, "Downloads") == 0)
675                {
676                        if(status.play == 1)
677                                screenbgdownload(1);
678                        else
679                                screenbgdownload(0);
680                }                       
681                else
682                {
683                        pluginnode = getplugin(mbox->name);
684
685                        if(pluginnode != NULL)
686                        {
687                                startplugin = dlsym(pluginnode->pluginhandle, "start");
688                                if(startplugin != NULL)
689                                        startplugin();
690                        }
691                }
692        }
693
694        freemenulist(mlist, 1); mlist = NULL;
695        drawscreen(skin, 0, 0);
696        resettvpic();
697        if(playinfobarstatus > 0 &&     status.play == 1)
698                screenplayinfobar(file, showname, 0, playertype, flag);
699
700        status.hangtime = hangtime;
701        return ret;
702}
703
704void playrcinfo(char* file, char* showname, int* playinfobarstatus, int* playinfobarcount, int playertype, int flag)
705{
706        if(checkbit(status.playercan, 14) == 0) return;
707
708        if(*playinfobarstatus == 0)
709        {
710                *playinfobarstatus = 1;
711                *playinfobarcount = 0;
712                screenplayinfobar(file, showname, 0, playertype, flag);
713        }
714        else if(*playinfobarstatus == 1)
715        {
716                *playinfobarstatus = 0;
717                screenplayinfobar(NULL, NULL, 1, playertype, flag);
718        }
719}
720
721void playrcstop(int playertype, int flag)
722{
723        if(checkbit(status.playercan, 6) == 0) return;
724
725        free(status.playfile); status.playfile = NULL;
726       
727        if(playertype == 1)
728                playerstopts(0, 0);
729        else if(playertype == 2)
730                dvdstop();
731        else
732                playerstop();
733
734        writevfdmenu("Player");
735        screenplayinfobar(NULL, NULL, 1, playertype, flag);
736}
737
738//type 0: only from play
739//type 1: only from pause
740void playrcsf(char* file, char* showname, int* playinfobarstatus, int* playinfobarcount, int playertype, int type, int flag)
741{
742        if(checkbit(status.playercan, 15) == 0) return;
743
744        if(status.playspeed == 0 && ((type == 0 && status.pause == 0) || (type == 1 && status.pause == 1)))
745        {
746                status.slowspeed++;
747                if(status.slowspeed > 6) status.slowspeed = 6;
748                if(status.slowspeed > 0)
749                {
750                        status.play = 0;
751
752                        if(playertype == 1)
753                                playerslowts((int)pow(2, status.slowspeed));
754                        else if(playertype == 0)
755                                playerslow(status.playspeed);
756                        *playinfobarstatus = 2;
757                        *playinfobarcount = 0;
758                        screenplayinfobar(file, showname, 0, playertype, flag);
759                }
760                if(status.slowspeed == 0)
761                {
762                        status.pause = 0;
763                        status.play = 1;
764                        if(playertype == 1)
765                        {
766                                playerpausets();
767                                audioclearbuffer(status.aktservice->audiodev);
768                                playercontinuets();
769                                playerresetts();
770                        }
771                        else if(playertype == 2)
772                                dvdcontinue();
773                        else
774                                playercontinue();
775                        *playinfobarstatus = 1;
776                        *playinfobarcount = 0;
777                        screenplayinfobar(file, showname, 0, playertype, flag);
778                }
779        }
780}
781
782//type 0: only from play
783//type 1: only from pause
784void playrcsr(char* file, char* showname, int* playinfobarstatus, int* playinfobarcount, int playertype, int type, int flag)
785{
786        if(checkbit(status.playercan, 15) == 0) return;
787
788        if(status.playspeed == 0 && ((type == 0 && status.pause == 0) || (type == 1 && status.pause == 1)))
789        {
790                status.slowspeed--;
791                if(status.slowspeed < 0) status.slowspeed = 0;
792                if(status.slowspeed > 0)
793                {
794                        status.play = 0;
795                        if(playertype == 1)
796                                playerslowts((int)pow(2, status.slowspeed));
797                        else if(playertype == 0)
798                                playerslowts(status.slowspeed);
799                        *playinfobarstatus = 2;
800                        *playinfobarcount = 0;
801                        screenplayinfobar(file, showname, 0, playertype, flag);
802                }
803                if(status.slowspeed == 0)
804                {
805                        status.pause = 0;
806                        status.play = 1;
807                        if(playertype == 1)
808                        {
809                                playerpausets();
810                                audioclearbuffer(status.aktservice->audiodev);
811                                playercontinuets();
812                                playerresetts();
813                        }
814                        else if(playertype == 2)
815                                dvdcontinue();
816                        else
817                                playercontinue();
818                        *playinfobarstatus = 1;
819                        *playinfobarcount = 0;
820                        screenplayinfobar(file, showname, 0, playertype, flag);
821                }
822        }
823}
824
825void playrcff(char* file, char* showname, int* playinfobarstatus, int* playinfobarcount, int playertype, int flag)
826{
827        if(status.pause == 1)
828        {
829                playrcsf(file, showname, playinfobarstatus, playinfobarcount, playertype, 1, flag);
830                return;
831        }
832
833        if(checkbit(status.playercan, 7) == 0) return;
834
835        if(status.pause == 0 && status.slowspeed == 0)
836        {
837                status.playspeed++;
838                if(status.playspeed > 6) status.playspeed = 6;
839                if(status.playspeed > 0)
840                {
841                        status.play = 0;
842                        if(playertype == 1)
843                                playerffts((int)pow(2, status.playspeed));
844                        else if(playertype == 2)
845                                dvdff(status.playspeed);
846                        else   
847                                playerff(status.playspeed);
848                        *playinfobarstatus = 2;
849                        *playinfobarcount = 0;
850                        screenplayinfobar(file, showname, 0, playertype, flag);
851                }
852                if(status.playspeed < 0)
853                {
854                        status.play = 0;
855                        if(playertype == 1)
856                                playerfrts((int)(pow(2, status.playspeed * -1) * -1), 0);
857                        else if(playertype == 2)
858                                dvdfr(status.playspeed);
859                        else
860                                playerfr(status.playspeed);
861                        *playinfobarstatus = 2;
862                        *playinfobarcount = 0;
863                        screenplayinfobar(file, showname, 0, playertype, flag);
864                }
865                if(status.playspeed == 0)
866                {
867                        status.play = 1;
868                        if(playertype == 1)
869                        {
870                                playerpausets();
871                                playercontinuets();
872                                playerresetts();
873                        }
874                        else if(playertype == 2)
875                                dvdcontinue();
876                        else
877                                playercontinue();
878                        *playinfobarstatus = 1;
879                        *playinfobarcount = 0;
880                        screenplayinfobar(file, showname, 0, playertype, flag);
881                }
882        }
883}
884
885void playrcfr(char* file, char* showname, int* playinfobarstatus, int* playinfobarcount, int playertype, int flag)
886{
887        if(status.pause == 1)
888        {
889                playrcsr(file, showname, playinfobarstatus, playinfobarcount, playertype, 1, flag);
890                return;
891        }
892       
893        if(checkbit(status.playercan, 8) == 0) return;
894
895        if(status.pause == 0 && status.slowspeed == 0)
896        {
897                status.playspeed--;
898                if(status.playspeed < -6) status.playspeed = -6;
899                if(status.playspeed > 0)
900                {
901                        status.play = 0;
902                        if(playertype == 1)
903                                playerffts((int)pow(2, status.playspeed));
904                        else if(playertype == 2)
905                                dvdff(status.playspeed);
906                        else
907                                playerff(status.playspeed);
908                        *playinfobarstatus = 2;
909                        *playinfobarcount = 0;
910                        screenplayinfobar(file, showname, 0, playertype, flag);
911                }
912                if(status.playspeed < 0)
913                {
914                        status.play = 0;
915                        if(playertype == 1)
916                                playerfrts((int)(pow(2, status.playspeed * -1) * -1), 0);
917                        else if(playertype == 2)
918                                dvdfr(status.playspeed);
919                        else
920                                playerfr(status.playspeed);
921                        *playinfobarstatus = 2;
922                        *playinfobarcount = 0;
923                        screenplayinfobar(file, showname, 0, playertype, flag);
924                }
925                if(status.playspeed == 0)
926                {
927                        status.play = 1;
928                        if(playertype == 1)
929                        {
930                                playerpausets();
931                                playercontinuets();
932                                playerresetts();
933                        }
934                        else if(playertype == 2)
935                                dvdcontinue();
936                        else
937                                playercontinue();
938                        *playinfobarstatus = 1;
939                        *playinfobarcount = 0;
940                        screenplayinfobar(file, showname, 0, playertype, flag);
941                }
942        }
943}
944
945void playrcpause(char* file, char* showname, int* playinfobarstatus, int* playinfobarcount, int playertype, int flag)
946{
947        if(status.playspeed != 0 || status.slowspeed != 0)
948        {
949                playrcplay(file, showname, playinfobarstatus, playinfobarcount, playertype, flag);
950                return;
951        }
952       
953        if(checkbit(status.playercan, 9) == 0) return;
954
955        if(status.pause == 1)
956        {
957                if(playertype == 1)
958                {
959                        playercontinuets();
960                }
961                else if(playertype == 2)
962                        dvdcontinue();
963                else
964                        playercontinue();
965                status.slowspeed = 0;
966                status.playspeed = 0;
967                status.play = 1;
968                status.pause = 0;
969                *playinfobarstatus = 1;
970                *playinfobarcount = 0;
971                screenplayinfobar(file, showname, 0, playertype, flag);
972        }
973        else
974        {
975                status.slowspeed = 0;
976                status.playspeed = 0;
977                status.play = 0;
978                status.pause = 1;
979                if(playertype == 1)
980                        playerpausets();
981                else if(playertype == 2)
982                        dvdpause();
983                else
984                        playerpause();
985                *playinfobarstatus = 2;
986                *playinfobarcount = 0;
987                screenplayinfobar(file, showname, 0, playertype, flag);
988        }
989}
990
991void playrcplay(char* file, char* showname, int* playinfobarstatus, int* playinfobarcount, int playertype, int flag)
992{
993        if(checkbit(status.playercan, 10) == 0) return;
994
995        free(status.playfile); status.playfile = NULL;
996        status.playfile = ostrcat(file, NULL, 0, 0);
997
998        if(playertype == 1)
999        {
1000                if(status.playspeed != 0 || status.slowspeed != 0)
1001                        playerpausets();
1002                if(status.slowspeed != 0)
1003                        audioclearbuffer(status.aktservice->audiodev);
1004                playercontinuets();
1005                if(status.playspeed != 0 || status.slowspeed != 0)
1006                        playerresetts();
1007        }
1008        else if(playertype == 2)
1009                dvdcontinue();
1010        else
1011                playercontinue();
1012        status.slowspeed = 0;
1013        status.playspeed = 0;
1014        status.pause = 0;
1015        status.play = 1;
1016        *playinfobarstatus = 1;
1017        *playinfobarcount = 0;
1018        screenplayinfobar(file, showname, 0, playertype, flag);
1019}
1020
1021void playrcjumpr(char* file, char* showname, int sec, int* playinfobarstatus, int* playinfobarcount, int playertype, int flag)
1022{
1023//      if(checkbit(status.playercan, 11) == 0) return;
1024
1025        unsigned long long pos = 0;
1026       
1027        if(status.pause == 0 && status.playspeed == 0 && status.slowspeed == 0)
1028        {
1029                struct skin* load = getscreen("loading");
1030                drawscreen(load, 0, 0);
1031               
1032                //a jump over the beginning of the
1033                //file, freez the player (type 0)
1034                if(playertype == 1)
1035                        playerseekts(getservice(RECORDPLAY, 0), sec * -1, 0);
1036                else if(playertype == 2)
1037                        pos = dvdgetpts() / 90000;
1038                else
1039                        pos = playergetpts() / 90000;
1040       
1041                if(playertype != 1)
1042                {
1043                        if(pos + 10 > sec)
1044                        {
1045                                if(playertype == 2)
1046                                        dvdseek(sec * -1);
1047                                else
1048                                        playerseek(sec * -1);
1049                        }
1050                        else
1051                        {
1052                                if(playertype == 2)
1053                                {
1054                                        dvdstop();
1055                                        dvdstart(file);
1056                                }
1057                                else
1058                                {
1059                                        playerstop();
1060                                        playerstart(file);
1061                                }
1062                        }
1063                }
1064
1065                *playinfobarstatus = 1;
1066                *playinfobarcount = 0;
1067                //status.play = 0;
1068                clearscreen(load);
1069                screenplayinfobar(file, showname, 0, playertype, flag);
1070                //status.play = 1;
1071                sleep(1);
1072        }
1073}
1074
1075void playrcjumpto(char* file, char* showname, int* playinfobarstatus, int* playinfobarcount, int playertype, int flag)
1076{
1077        if(status.pause == 0 && status.playspeed == 0 && status.slowspeed == 0)
1078        {
1079                char* tmpstr = numinput(_("Jump To (min)"), NULL, "000", 0);
1080                if(tmpstr != NULL)
1081                {
1082                        int jump = atoi(tmpstr) * 60;
1083                        playrcjumpf(file, showname, jump, playinfobarstatus, playinfobarcount, playertype, flag);
1084                }
1085                free(tmpstr), tmpstr = NULL;
1086        }
1087}
1088
1089void playrcjumpf(char* file, char* showname, int sec, int* playinfobarstatus, int* playinfobarcount, int playertype, int flag)
1090{
1091//      if(checkbit(status.playercan, 12) == 0) return;
1092
1093        if(status.pause == 0 && status.playspeed == 0 && status.slowspeed == 0)
1094        {
1095                struct skin* load = getscreen("loading");
1096                drawscreen(load, 0, 0);
1097               
1098                if(playertype == 1)
1099                        playerseekts(getservice(RECORDPLAY, 0), sec, 0);
1100                else if(playertype == 2)
1101                        dvdseek(sec);
1102                else
1103                        playerseek(sec);
1104                *playinfobarstatus = 1;
1105                *playinfobarcount = 0;
1106                //status.play = 0;
1107                clearscreen(load);
1108                screenplayinfobar(file, showname, 0, playertype, flag);
1109                //status.play = 1;
1110        }
1111}
1112
1113void playchangecodec(int playertype)
1114{
1115        if(checkbit(status.playercan, 13) == 0) return;
1116
1117        char** tracklist = NULL;
1118
1119        if(getconfigint("av_ac3default", NULL) == 1)
1120        {
1121                int i = 0;
1122               
1123                tracklist = playergettracklist(1);
1124                if(tracklist != NULL)
1125                {
1126                        while(tracklist[i] != NULL)
1127                        {
1128                                if(ostrcmp(tracklist[i + 1], "A_AC3") == 0)
1129                                {
1130                                        playerchangeaudiotrack(i / 2);
1131                                }
1132                                i += 2;
1133                        }
1134                }
1135                playerfreetracklist(tracklist);
1136                tracklist = NULL;
1137        }
1138}
1139
1140int playcheckdirrcret(char* file, int dirrcret)
1141{
1142        int ret = 0;
1143        char* epgfilename = NULL, *tmpstr = NULL;
1144
1145        if(dirrcret == 4)
1146        {
1147                int sort = screendirsort();
1148                addconfigint("dirsort", sort);
1149                ret = 1;
1150        }
1151        if(dirrcret == 3)
1152        {
1153                epgfilename = changefilenameext(file, ".epg");
1154
1155                tmpstr = readfiletomem(epgfilename, 0);
1156                if(tmpstr != NULL)
1157                        textbox(_("EPG Info"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 600, 0, 2);
1158                else {
1159                        free(epgfilename); epgfilename = NULL;
1160                        epgfilename = changefilenameext(file, ".eit");
1161                        tmpstr = readeittomem(epgfilename);
1162                        if(tmpstr != NULL)
1163                                textbox(_("EPG Info"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 800, 600, 0, 2);
1164                }
1165                free(epgfilename); epgfilename = NULL;
1166                free(tmpstr); tmpstr = NULL;
1167                ret = 1;
1168        }
1169        if(dirrcret == 1)
1170        {
1171                if(getservicebyrecname(file, 0, 0) != NULL)
1172                        textbox(_("Message"), _("Record in progress"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
1173                else if(textbox(_("Really Delete ?"), file, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0) == 1)
1174                {
1175                        unlink(file);
1176                        epgfilename = changefilenameext(file, ".epg");
1177                        unlink(epgfilename);
1178                        free(epgfilename); epgfilename = NULL;
1179                        epgfilename = changefilenameext(file, ".se");
1180                        unlink(epgfilename);
1181                        free(epgfilename); epgfilename = NULL;
1182                        epgfilename = changefilenameext(file, ".ma");
1183                        unlink(epgfilename);
1184                        free(epgfilename); epgfilename = NULL;
1185                }
1186                ret = 1;
1187        }
1188       
1189        return ret;
1190}
1191
1192void playwritevfd(char* file, char* showname)
1193{
1194        char* tmpstr = NULL;
1195
1196        if(showname == NULL)
1197        {
1198                tmpstr = ostrcat(file, NULL, 0, 0);
1199                if(tmpstr != NULL) writevfdmenu(basename(tmpstr));
1200                free(tmpstr); tmpstr = NULL;
1201        }
1202        else
1203                writevfdmenu(showname);
1204}
1205
1206
1207void playstartservice()
1208{
1209        char* tmpstr = NULL;
1210
1211        if(status.aktservice->channel != NULL)
1212        {
1213                tmpstr = ostrcat(status.aktservice->channellist, NULL, 0, 0);
1214                servicecheckret(servicestart(status.aktservice->channel, tmpstr, NULL, 3), 0);
1215        }
1216        else
1217        {
1218                tmpstr = ostrcat(status.lastservice->channellist, NULL, 0, 0);
1219                servicecheckret(servicestart(status.lastservice->channel, tmpstr, NULL, 0), 0);
1220        }
1221        free(tmpstr); tmpstr = NULL;
1222}
1223
1224// flag 0 = dirlist/playing/infobar
1225// flag 1 = playing/infobar
1226// flag 2 = playing
1227// flag 3 = not stop/start live service
1228// flag 4 = playing with screensaver
1229// startfolder 2 = do nothing with playstop/playstart
1230int screenplay(char* startfile, char* showname, int startfolder, int flag)
1231{
1232        int rcret = 0, playertype = 0, ret = 0, rcwait = 1000, screensaver_delay = 0;
1233        char* file = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
1234        char* tmppolicy = NULL, *startdir = NULL;
1235        char* formats = NULL;
1236        struct skin* playinfobar = getscreen("playinfobar");
1237        struct skin* sprogress = getscreennode(playinfobar, "progress");
1238        struct skin* load = getscreen("loading");
1239
1240        int oldsort = getconfigint("dirsort", NULL);
1241        int skip13 = getconfigint("skip13", NULL);
1242        int skip46 = getconfigint("skip46", NULL);
1243        int skip79 = getconfigint("skip79", NULL);
1244
1245        if(startfolder == 0 && flag != 3)
1246        {
1247                rcret = servicestop(status.aktservice, 1, 1);
1248                if(rcret == 1) return ret;
1249        }
1250
1251        if(status.webplayfile != NULL)
1252        {
1253                startfile = status.webplayfile;
1254                rcret = servicestop(status.aktservice, 1, 1);
1255                if(rcret == 1) return ret;
1256        }
1257
1258        // allowed from atemio avi mkv mpg4 xvid mpg1 mpg2 jpeg png
1259        if(status.expertmodus > 0 && status.security == 1)
1260                formats = ostrcat(formats, ".flac .ogg .mp3 .avi .dat .divx .flv .mkv .m4v .mp4 .mov .mpg .mpeg .mts .m2ts .trp .ts .vdr .vob .wmv .rm", 1, 0);
1261        else
1262                formats = ostrcat(formats, ".ts .mts .m2ts", 1, 0);
1263       
1264        status.updatevfd = PAUSE;
1265        tmppolicy = getpolicy();
1266
1267playerstart:
1268        //reset timeline
1269        sprogress->progresssize = 0;
1270
1271        if(startfolder == 0)
1272                startdir = getconfig("rec_moviepath", NULL);
1273        else
1274                startdir = getconfig("rec_path", NULL);
1275
1276        status.playspeed = 0, status.play = 0, status.pause = 0, status.slowspeed = 0;
1277        int playinfobarcount = 0, playinfobarstatus = 1, dirrcret = 0;
1278
1279        if(startfile == NULL)
1280        {
1281                readmediadb(getconfig("mediadbfile", NULL), 0, 0);
1282
1283                tmpstr = ostrcat(file, NULL, 0, 0);
1284                char* tmpstartdir = startdir;
1285                if(file != NULL)
1286                {
1287                        tmpstr1 = ostrcat(file, NULL, 0, 0);
1288                        startdir = dirname(tmpstr1);
1289                }
1290                free(file); file = NULL;
1291                file = screendir(startdir, formats, basename(tmpstr), &dirrcret, ".epg", _("DEL"), getrcconfigint("rcred", NULL), _("SELECT"), 0, "EPG", getrcconfigint("rcyellow", NULL), "SORT", getrcconfigint("rcblue", NULL), 90, 1, 90, 1, 64);
1292                free(tmpstr); tmpstr = NULL;
1293                free(tmpstr1); tmpstr1 = NULL;
1294                startdir = tmpstartdir;
1295        }
1296        else
1297                file = ostrcat(startfile, NULL, 0, 0);
1298
1299        if(file == NULL)
1300        {
1301                if(playcheckdirrcret(file, dirrcret) == 1)
1302                        goto playerstart;
1303        }
1304
1305        if(file != NULL)
1306        {
1307                if(getconfigint("playertype", NULL) == 1 && (cmpfilenameext(file, ".ts") == 0 || cmpfilenameext(file, ".mts") == 0 || cmpfilenameext(file, ".m2ts") == 0))
1308                        playertype = 1;
1309
1310                if(startfile == NULL)
1311                {
1312                        tmpstr = ostrcat(file, NULL, 0, 0);
1313                        if(tmpstr != NULL && startfolder == 0) addconfig("rec_moviepath", dirname(tmpstr));
1314                        free(tmpstr); tmpstr = NULL;
1315               
1316                        if(playcheckdirrcret(file, dirrcret) == 1)
1317                                goto playerstart;
1318
1319                        if(startfolder == 1 && flag != 3)
1320                        {
1321                                rcret = servicestop(status.aktservice, 1, 1);
1322                                if(rcret == 1)
1323                                {
1324                                        free(tmppolicy);
1325                                        free(file);
1326                                        free(formats);
1327                                        addconfigint("dirsort", oldsort);
1328                                        return ret;
1329                                }
1330                        }
1331                }
1332
1333                drawscreen(skin, 0, 0);
1334                drawscreen(load, 0, 0);
1335                playwritevfd(file, showname);
1336                if(playertype == 1)
1337                        rcret = playerstartts(file, 0);
1338                else if(playertype == 2)
1339                        rcret = playerstart(file);
1340                else
1341                {
1342                        if(ostrstr(file, "http://") == file)
1343                        {
1344                                struct stimerthread* bufferstatus = addtimer(&screenplaybufferstatus, START, 1000, 1, NULL, NULL, NULL);
1345                                rcret = playerstart(file);
1346                                if(bufferstatus != NULL && gettimer(bufferstatus) != NULL)
1347                                {
1348                                        bufferstatus->aktion = STOP;
1349                                        usleep(100000);
1350                                }
1351                        }
1352                        else
1353                                rcret = playerstart(file);
1354                }
1355#ifndef SIMULATE
1356                if(rcret != 0)
1357                {
1358                        textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 7, 0);
1359                        writevfdmenu("Player");
1360                       
1361                        if(startfile == NULL)
1362                        {
1363                                if(startfolder == 1 && flag != 3) playstartservice();
1364                                goto playerstart;
1365                        }
1366                        else
1367                        {
1368                                ret = 2;
1369                                goto playerend;
1370                        }
1371                }
1372#endif
1373                clearscreen(load);
1374                screenplayinfobar(file, showname, 0, playertype, flag);
1375
1376                if(flag == 4 && getconfigint("screensaver", NULL) == 1)
1377                {
1378                        screensaver_delay = getconfigint("screensaver_delay", NULL);
1379                        initscreensaver();
1380                }                                                               
1381               
1382                //change codec if ac3default and video has ac3
1383                //deaktivate, freeze player, makes a seek -5
1384                //see eplayer container_ffmpeg_switch_audio
1385                //the seek to the beginning of the file freez
1386                //eplayer.
1387                //playchangecodec();
1388                free(status.playfile); status.playfile = NULL;
1389                status.playfile = ostrcat(file, NULL, 0, 0);
1390                status.play = 1;
1391                int count = 0;
1392                while(1)
1393                {
1394                        while((playertype == 0 && playerisplaying()) || (playertype == 1 && playerisplayingts()))
1395                        {
1396                                rcret = waitrc(playinfobar, rcwait, 0);
1397                                playinfobarcount++;
1398                                if(playinfobarstatus > 0)
1399                                        screenplayinfobar(file, showname, 0, playertype, flag);
1400                                if(playinfobarstatus == 1 && playinfobarcount >= getconfigint("infobartimeout", NULL))
1401                                {
1402                                        playinfobarstatus = 0;
1403                                        screenplayinfobar(NULL, NULL, 1, playertype, flag);
1404                                }
1405                               
1406                                if(flag == 4)
1407                                {
1408                                        if(status.play == 1 && screensaver != NULL)
1409                                                count++;
1410       
1411                                        if(count > screensaver_delay && screensaver != NULL)
1412                                        {
1413                                                showscreensaver();
1414                                                rcwait = screensaver->speed;
1415                                        }
1416                                }
1417               
1418                                if(rcret == getrcconfigint("rcyellow", NULL))
1419                                        playrcyellow(file, showname, playinfobarstatus, playertype, flag);
1420                               
1421                                if(rcret == getrcconfigint("rctext", NULL) || rcret == getrcconfigint("rcsubtitel", NULL))
1422                                        playrctext(file, showname, playinfobarstatus, playertype, flag);
1423                                       
1424                                if(rcret == getrcconfigint("rcgreen", NULL))
1425                                        playrcgreen(file, showname, playinfobarstatus, playertype, flag);
1426                                       
1427                                if(rcret == getrcconfigint("rcblue", NULL))
1428                                        playrcblue(file, showname, playinfobarstatus, playertype, flag);
1429                                       
1430                                if(rcret == getrcconfigint("rcok", NULL))
1431                                        playrcok(file, showname, playinfobarstatus, playertype, flag);
1432                               
1433                                if(rcret == getrcconfigint("rcred", NULL))
1434                                        playrcred(file, showname, playinfobarstatus, playertype, flag);
1435
1436                                if(rcret == getrcconfigint("rcinfo", NULL))
1437                                        playrcinfo(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1438                               
1439                                if(rcret == getrcconfigint("rcstop", NULL) || rcret == getrcconfigint("rcexit", NULL))
1440                                {
1441                                        playrcstop(playertype, flag);
1442                                        if(startfile == NULL)
1443                                        {                                               
1444                                                if(startfolder == 1 && flag != 3) playstartservice();
1445                                                goto playerstart;
1446                                        }
1447                                        else
1448                                        {
1449                                                ret = 1;
1450                                                goto playerend;
1451                                        }
1452                                }
1453                               
1454                                if(rcret == getrcconfigint("rcsf", NULL))
1455                                        playrcsf(file, showname, &playinfobarstatus, &playinfobarcount, playertype, 0, flag);
1456         
1457                        if(rcret == getrcconfigint("rcsr", NULL))
1458                                        playrcsr(file, showname, &playinfobarstatus, &playinfobarcount, playertype, 0, flag);
1459
1460                                if(rcret == getrcconfigint("rcff", NULL))
1461                                        playrcff(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1462                               
1463                                if(rcret == getrcconfigint("rcfr", NULL))
1464                                        playrcfr(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1465
1466                                if(rcret == getrcconfigint("rcpause", NULL) || ((checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1) && rcret == getrcconfigint("rcplay", NULL) && status.pause == 0 && status.slowspeed == 0 && status.playspeed == 0))
1467                                {       
1468                                        playrcpause(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1469                                        continue;
1470                                }
1471
1472                                if(rcret == getrcconfigint("rcplay", NULL))
1473                                        playrcplay(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1474
1475                                if(rcret == getrcconfigint("rcleft", NULL))
1476                                        playrcjumpr(file, showname, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
1477                               
1478                                if(rcret == getrcconfigint("rc1", NULL))
1479                                        playrcjumpr(file, showname, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
1480                               
1481                                if(rcret == getrcconfigint("rc4", NULL))
1482                                        playrcjumpr(file, showname, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
1483                               
1484                                if(rcret == getrcconfigint("rc7", NULL))
1485                                        playrcjumpr(file, showname, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
1486
1487                                if(rcret == getrcconfigint("rc2", NULL))
1488                                        playrcjumpto(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1489                               
1490                                if(rcret == getrcconfigint("rcright", NULL))
1491                                        playrcjumpf(file, showname, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
1492                               
1493                                if(rcret == getrcconfigint("rc3", NULL))
1494                                        playrcjumpf(file, showname, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
1495                               
1496                                if(rcret == getrcconfigint("rc6", NULL))
1497                                        playrcjumpf(file, showname, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
1498                               
1499                                if(rcret == getrcconfigint("rc9", NULL))
1500                                        playrcjumpf(file, showname, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
1501
1502                                if(rcret == getrcconfigint("rcdown", NULL))
1503                                        playrcjumpr(file, showname, 300, &playinfobarstatus, &playinfobarcount, playertype, flag);
1504
1505                                if(rcret == getrcconfigint("rcup", NULL))
1506                                        playrcjumpf(file, showname, 300, &playinfobarstatus, &playinfobarcount, playertype, flag);
1507                               
1508                                if(rcret == getrcconfigint("rc0", NULL))
1509                                        setmarker();
1510                                if(rcret == getrcconfigint("rc5", NULL))
1511                                        screenmarker();
1512
1513                        }
1514                        //don't change this sleep, without this
1515                        //the player stops to fast, and a last seek can
1516                        //produce a segfault
1517playerend:
1518                        sleep(1);
1519                        if(playertype == 1)
1520                                playerafterendts();
1521                        else
1522                                playerafterend();
1523
1524                        writevfdmenu("Player");
1525                        screenplayinfobar(file, showname, 1, playertype, flag);
1526
1527                        if(startfile == NULL)
1528                        {
1529                                if(startfolder == 1 && flag != 3) playstartservice();
1530                                goto playerstart;
1531                        }
1532                        else
1533                                break;
1534                }
1535        }
1536        if(startfolder == 0 && flag != 3) playstartservice();
1537        status.updatevfd = START;
1538       
1539        if(status.webplayfile != NULL)
1540        {
1541                playstartservice();
1542                free(status.webplayfile); status.webplayfile = NULL;
1543        }
1544
1545        if(tmppolicy != NULL)
1546        {
1547                setpolicy(tmppolicy);
1548                free(tmppolicy);
1549        }
1550       
1551        if(flag == 4)
1552                deinitscreensaver();
1553
1554        addconfigint("dirsort", oldsort);
1555        free(status.playfile); status.playfile = NULL;
1556        status.slowspeed = 0;
1557        status.playspeed = 0;
1558        status.pause = 0;
1559        status.play = 0;
1560        free(file);
1561        free(formats);
1562
1563        if(status.mediadbthread == NULL)
1564        {
1565                if(status.writemediadb == 1)
1566                        writemediadb(getconfig("mediadbfile", NULL), NULL);
1567                freemediadb(0);
1568        }
1569
1570        return ret;
1571}
1572
1573#endif
Note: See TracBrowser for help on using the repository browser.