source: titan/titan/play.h @ 24152

Last change on this file since 24152 was 24152, checked in by nit, 10 years ago

[titan] add 2x rcyellow to player for subtitle

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