source: titan/titan/play.h @ 25502

Last change on this file since 25502 was 25502, checked in by gost, 10 years ago

[titan] play ts... optimize timeline

File size: 45.8 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 DrDish (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 DrDish (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                }
1270                ret = 1;
1271        }
1272       
1273        return ret;
1274}
1275
1276void playwritevfd(char* file, char* showname)
1277{
1278        char* tmpstr = NULL;
1279
1280        if(showname == NULL)
1281        {
1282                tmpstr = ostrcat(file, NULL, 0, 0);
1283                if(tmpstr != NULL) writevfdmenu(basename(tmpstr));
1284                free(tmpstr); tmpstr = NULL;
1285        }
1286        else
1287                writevfdmenu(showname);
1288}
1289
1290
1291void playstartservice()
1292{
1293        char* tmpstr = NULL;
1294
1295        if(status.aktservice->channel != NULL)
1296        {
1297                tmpstr = ostrcat(status.aktservice->channellist, NULL, 0, 0);
1298                servicecheckret(servicestart(status.aktservice->channel, tmpstr, NULL, 3), 0);
1299        }
1300        else
1301        {
1302                tmpstr = ostrcat(status.lastservice->channellist, NULL, 0, 0);
1303                servicecheckret(servicestart(status.lastservice->channel, tmpstr, NULL, 0), 0);
1304        }
1305        free(tmpstr); tmpstr = NULL;
1306}
1307
1308// flag 0 = dirlist/playing/infobar
1309// flag 1 = playing/infobar
1310// flag 2 = playing
1311// flag 3 = not stop/start live service
1312// flag 4 = playing with screensaver
1313// startfolder 2 = do nothing with playstop/playstart
1314int screenplay(char* startfile, char* showname, int startfolder, int flag)
1315{
1316        int rcret = 0, playertype = 0, ret = 0, rcwait = 1000, screensaver_delay = 0, holdselection = 0;
1317        char* file = NULL, *tmpstr = NULL, *tmpstr1 = NULL;
1318        char* tmppolicy = NULL, *startdir = NULL;
1319        char* formats = NULL;
1320        struct skin* playinfobar = getscreen("playinfobar");
1321        struct skin* sprogress = getscreennode(playinfobar, "progress");
1322        struct skin* load = getscreen("loading");
1323
1324        int oldsort = getconfigint("dirsort", NULL);
1325        int skip13 = getconfigint("skip13", NULL);
1326        int skip46 = getconfigint("skip46", NULL);
1327        int skip79 = getconfigint("skip79", NULL);
1328
1329        if(startfolder == 0 && flag != 3)
1330        {
1331                rcret = servicestop(status.aktservice, 1, 1);
1332                if(rcret == 1) return ret;
1333        }
1334
1335        if(status.webplayfile != NULL)
1336        {
1337                startfile = status.webplayfile;
1338                rcret = servicestop(status.aktservice, 1, 1);
1339                if(rcret == 1) return ret;
1340        }
1341
1342        // allowed from atemio avi mkv mpg4 xvid mpg1 mpg2 jpeg png
1343        if(status.expertmodus > 0 && status.security == 1)
1344                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);
1345        else
1346                formats = ostrcat(formats, ".ts", 1, 0);
1347       
1348        status.updatevfd = PAUSE;
1349        tmppolicy = getpolicy();
1350
1351playerstart:
1352        //reset timeline
1353        sprogress->progresssize = 0;
1354
1355        if(startfolder == 0)
1356                startdir = getconfig("rec_moviepath", NULL);
1357        else
1358                startdir = getconfig("rec_path", NULL);
1359
1360        status.playspeed = 0, status.play = 0, status.pause = 0, status.slowspeed = 0;
1361        int playinfobarcount = 0, playinfobarstatus = 1, dirrcret = 0;
1362
1363        if(startfile == NULL)
1364        {
1365                readmediadb(getconfig("mediadbfile", NULL), 0, 0);
1366
1367                tmpstr = ostrcat(file, NULL, 0, 0);
1368                char* tmpstartdir = startdir;
1369                if(file != NULL)
1370                {
1371                        tmpstr1 = ostrcat(file, NULL, 0, 0);
1372                        startdir = dirname(tmpstr1);
1373                }
1374                free(file); file = NULL;
1375                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);
1376                holdselection = 0;
1377                free(tmpstr); tmpstr = NULL;
1378                free(tmpstr1); tmpstr1 = NULL;
1379                startdir = tmpstartdir;
1380        }
1381        else
1382                file = ostrcat(startfile, NULL, 0, 0);
1383
1384        if(file == NULL)
1385        {
1386                if(playcheckdirrcret(file, dirrcret) == 1)
1387                        goto playerstart;
1388        }
1389
1390        if(file != NULL)
1391        {
1392                if(getconfigint("playertype", NULL) == 1 && cmpfilenameext(file, ".ts") == 0)
1393                        playertype = 1;
1394
1395                if(startfile == NULL)
1396                {
1397                        tmpstr = ostrcat(file, NULL, 0, 0);
1398                        if(tmpstr != NULL && startfolder == 0) addconfig("rec_moviepath", dirname(tmpstr));
1399                        free(tmpstr); tmpstr = NULL;
1400               
1401                        if(playcheckdirrcret(file, dirrcret) == 1)
1402                        {
1403                                if(dirrcret == 1) holdselection = 1;
1404                                goto playerstart;
1405                        }
1406
1407                        if(startfolder == 1 && flag != 3)
1408                        {
1409                                rcret = servicestop(status.aktservice, 1, 1);
1410                                if(rcret == 1)
1411                                {
1412                                        free(tmppolicy);
1413                                        free(file);
1414                                        free(formats);
1415                                        addconfigint("dirsort", oldsort);
1416                                        return ret;
1417                                }
1418                        }
1419                }
1420
1421                drawscreen(skin, 0, 0);
1422                drawscreen(load, 0, 0);
1423                playwritevfd(file, showname);
1424                if(playertype == 1)
1425                        rcret = playerstartts(file, 0);
1426                else if(playertype == 2)
1427                        rcret = playerstart(file);
1428                else
1429                {
1430                        if(ostrstr(file, "http://") == file)
1431                        {
1432                                struct stimerthread* bufferstatus = addtimer(&screenplaybufferstatus, START, 1000, 1, NULL, NULL, NULL);
1433                                rcret = playerstart(file);
1434                                if(bufferstatus != NULL && gettimer(bufferstatus) != NULL)
1435                                {
1436                                        bufferstatus->aktion = STOP;
1437                                        usleep(100000);
1438                                }
1439                        }
1440                        else
1441                                rcret = playerstart(file);
1442                }
1443#ifndef SIMULATE
1444                if(rcret != 0)
1445                {
1446                        textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 7, 0);
1447                        writevfdmenu("Player");
1448                       
1449                        if(startfile == NULL)
1450                        {
1451                                if(startfolder == 1 && flag != 3) playstartservice();
1452                                goto playerstart;
1453                        }
1454                        else
1455                        {
1456                                ret = 2;
1457                                goto playerend;
1458                        }
1459                }
1460#endif
1461                clearscreen(load);
1462                screenplayinfobar(file, showname, 0, playertype, flag);
1463
1464                if(flag == 4 && getconfigint("screensaver", NULL) == 1)
1465                {
1466                        screensaver_delay = getconfigint("screensaver_delay", NULL);
1467                        initscreensaver();
1468                }                                                               
1469               
1470                //change codec if ac3default and video has ac3
1471                //deaktivate, freeze player, makes a seek -5
1472                //see eplayer container_ffmpeg_switch_audio
1473                //the seek to the beginning of the file freez
1474                //eplayer.
1475                //playchangecodec();
1476                free(status.playfile); status.playfile = NULL;
1477                status.playfile = ostrcat(file, NULL, 0, 0);
1478                status.play = 1;
1479                int count = 0;
1480                while(1)
1481                {
1482                        while((playertype == 0 && playerisplaying()) || (playertype == 1 && playerisplayingts()))
1483                        {
1484                                rcret = waitrc(playinfobar, rcwait, 0);
1485                                playinfobarcount++;
1486                                if(playinfobarstatus > 0)
1487                                        screenplayinfobar(file, showname, 0, playertype, flag);
1488                                if(playinfobarstatus == 1 && playinfobarcount >= getconfigint("infobartimeout", NULL))
1489                                {
1490                                        playinfobarstatus = 0;
1491                                        screenplayinfobar(NULL, NULL, 1, playertype, flag);
1492                                }
1493                               
1494                                if(flag == 4)
1495                                {
1496                                        if(status.play == 1 && screensaver != NULL)
1497                                                count++;
1498       
1499                                        if(count > screensaver_delay && screensaver != NULL)
1500                                        {
1501                                                showscreensaver();
1502                                                rcwait = screensaver->speed;
1503                                        }
1504                                }
1505               
1506                                if(rcret == getrcconfigint("rcyellow", NULL))
1507                                        playrcyellow(file, showname, playinfobarstatus, playertype, flag);
1508                               
1509                                if(rcret == getrcconfigint("rctext", NULL) || rcret == getrcconfigint("rcsubtitel", NULL))
1510                                        playrctext(file, showname, playinfobarstatus, playertype, flag);
1511                                       
1512                                if(rcret == getrcconfigint("rcgreen", NULL))
1513                                        playrcgreen(file, showname, playinfobarstatus, playertype, flag);
1514                                       
1515                                if(rcret == getrcconfigint("rcblue", NULL))
1516                                        playrcblue(file, showname, playinfobarstatus, playertype, flag);
1517                                       
1518                                if(rcret == getrcconfigint("rcok", NULL))
1519                                        playrcok(file, showname, playinfobarstatus, playertype, flag);
1520                               
1521                                if(rcret == getrcconfigint("rcred", NULL))
1522                                        playrcred(file, showname, playinfobarstatus, playertype, flag);
1523
1524                                if(rcret == getrcconfigint("rcinfo", NULL))
1525                                        playrcinfo(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1526                               
1527                                if(rcret == getrcconfigint("rcstop", NULL) || rcret == getrcconfigint("rcexit", NULL))
1528                                {
1529                                        playrcstop(playertype, flag);
1530                                        if(startfile == NULL)
1531                                        {                                               
1532                                                if(startfolder == 1 && flag != 3) playstartservice();
1533                                                goto playerstart;
1534                                        }
1535                                        else
1536                                        {
1537                                                ret = 1;
1538                                                goto playerend;
1539                                        }
1540                                }
1541                               
1542                                if(rcret == getrcconfigint("rcsf", NULL))
1543                                        playrcsf(file, showname, &playinfobarstatus, &playinfobarcount, playertype, 0, flag);
1544         
1545                        if(rcret == getrcconfigint("rcsr", NULL))
1546                                        playrcsr(file, showname, &playinfobarstatus, &playinfobarcount, playertype, 0, flag);
1547
1548                                if(rcret == getrcconfigint("rcff", NULL))
1549                                        playrcff(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1550                               
1551                                if(rcret == getrcconfigint("rcfr", NULL))
1552                                        playrcfr(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1553
1554                                if(rcret == getrcconfigint("rcpause", NULL) || ((checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1) && rcret == getrcconfigint("rcplay", NULL) && status.pause == 0 && status.slowspeed == 0 && status.playspeed == 0))
1555                                {       
1556                                        playrcpause(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1557                                        continue;
1558                                }
1559
1560                                if(rcret == getrcconfigint("rcplay", NULL))
1561                                        playrcplay(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1562
1563                                if(rcret == getrcconfigint("rcleft", NULL))
1564                                        playrcjumpr(file, showname, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
1565                               
1566                                if(rcret == getrcconfigint("rc1", NULL))
1567                                        playrcjumpr(file, showname, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
1568                               
1569                                if(rcret == getrcconfigint("rc4", NULL))
1570                                        playrcjumpr(file, showname, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
1571                               
1572                                if(rcret == getrcconfigint("rc7", NULL))
1573                                        playrcjumpr(file, showname, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
1574
1575                                if(rcret == getrcconfigint("rc2", NULL))
1576                                        playrcjumpto(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1577                               
1578                                if(rcret == getrcconfigint("rcright", NULL))
1579                                        playrcjumpf(file, showname, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
1580                               
1581                                if(rcret == getrcconfigint("rc3", NULL))
1582                                        playrcjumpf(file, showname, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
1583                               
1584                                if(rcret == getrcconfigint("rc6", NULL))
1585                                        playrcjumpf(file, showname, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
1586                               
1587                                if(rcret == getrcconfigint("rc9", NULL))
1588                                        playrcjumpf(file, showname, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
1589
1590                                if(rcret == getrcconfigint("rcdown", NULL))
1591                                        playrcjumpr(file, showname, 300, &playinfobarstatus, &playinfobarcount, playertype, flag);
1592
1593                                if(rcret == getrcconfigint("rcup", NULL))
1594                                        playrcjumpf(file, showname, 300, &playinfobarstatus, &playinfobarcount, playertype, flag);
1595                               
1596                                if(rcret == getrcconfigint("rc0", NULL))
1597                                        setmarker();
1598                                       
1599                                if(rcret == getrcconfigint("rc5", NULL))
1600                                        screenmarker(file, showname, &playinfobarstatus, &playinfobarcount, playertype, flag);
1601
1602                        }
1603                        //don't change this sleep, without this
1604                        //the player stops to fast, and a last seek can
1605                        //produce a segfault
1606playerend:
1607                        sleep(1);
1608                        if(playertype == 1)
1609                                playerafterendts();
1610                        else
1611                                playerafterend();
1612
1613                        writevfdmenu("Player");
1614                        screenplayinfobar(file, showname, 1, playertype, flag);
1615
1616                        if(startfile == NULL)
1617                        {
1618                                if(startfolder == 1 && flag != 3) playstartservice();
1619                                goto playerstart;
1620                        }
1621                        else
1622                                break;
1623                }
1624        }
1625        if(startfolder == 0 && flag != 3) playstartservice();
1626        status.updatevfd = START;
1627       
1628        if(status.webplayfile != NULL)
1629        {
1630                playstartservice();
1631                free(status.webplayfile); status.webplayfile = NULL;
1632        }
1633
1634        if(tmppolicy != NULL)
1635        {
1636                setpolicy(tmppolicy);
1637                free(tmppolicy);
1638        }
1639       
1640        if(flag == 4)
1641                deinitscreensaver();
1642
1643        addconfigint("dirsort", oldsort);
1644        free(status.playfile); status.playfile = NULL;
1645        status.slowspeed = 0;
1646        status.playspeed = 0;
1647        status.pause = 0;
1648        status.play = 0;
1649        free(file);
1650        free(formats);
1651
1652        if(status.mediadbthread == NULL)
1653        {
1654                if(status.writemediadb == 1)
1655                        writemediadb(getconfig("mediadbfile", NULL), NULL);
1656                freemediadb(0);
1657        }
1658
1659        return ret;
1660}
1661
1662#endif
Note: See TracBrowser for help on using the repository browser.