source: titan/titan/play.h @ 30678

Last change on this file since 30678 was 30672, checked in by nit, 9 years ago

seek -1 sec after audio change

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