source: titan/titan/play.h @ 26495

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

next step translate

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