source: titan/plugins/mc/mc_videoplayer.h @ 44656

Last change on this file since 44656 was 44656, checked in by obi, 4 years ago

mc vp disable internal ts player

File size: 32.2 KB
Line 
1#ifndef MC_VIDEOPLAYER_H
2#define MC_VIDEOPLAYER_H
3
4extern struct skin* skin;
5extern struct screensaver* screensaver;
6extern struct mediadb* mediadb;
7
8void screenmc_videoplayer()
9{
10        int videooff = 0;
11        // workaround for grey background mvi
12        struct skin* loadmediadb = getscreen("loading");
13        struct skin* blackscreen = getscreen("blackscreen");
14        drawscreen(blackscreen, 0, 0);
15        drawscreen(loadmediadb, 0, 0);
16
17        readmediadb(getconfig("mediadbfile", NULL), 0, 0);
18
19        char* lastid = NULL, *filename = NULL, *tmppolicy = NULL ,*currentdirectory = NULL, *selectedfile = NULL, *tmpstr = NULL;
20        int rcret = 0, rcwait = 1000, playerret = 0, flag = 1, skip = 0, eof = 0, playinfobarcount = 0, playinfobarstatus = 1, tmpview = 0, playlist = 0, playertype = 0, mviwait = 0, mvinum = 0, exit = 0;
21
22        tmpstr = ostrcat(getconfig("mc_vp_dirsort", NULL), NULL, 0, 0);
23        addconfigtmp("dirsort", tmpstr);
24        free(tmpstr), tmpstr = NULL;
25
26        // main screen
27        struct skin* apskin = getscreen("mc_videoplayer");
28        struct skin* filelistpath = getscreennode(apskin, "filelistpath");
29        struct skin* filelist = getscreennode(apskin, "filelist");
30        struct skin* listbox = getscreennode(apskin, "listbox");
31        struct skin* b2 = getscreennode(apskin, "b2");
32        struct skin* b3 = getscreennode(apskin, "b3");
33        struct skin* b4 = getscreennode(apskin, "b4");
34        struct skin* plot = getscreennode(apskin, "plot");
35        struct skin* title = getscreennode(apskin, "title");
36        struct skin* thumb = getscreennode(apskin, "thumb");
37        struct skin* stars = getscreennode(apskin, "stars");
38
39//      apskin->bgcol = getskinconfigint("black", NULL);
40       
41        if(getconfigint("mc_vp_uselastdir", NULL) == 1)
42        {
43                currentdirectory = ostrcat(currentdirectory, getconfig("mc_vp_path", NULL), 1, 0);
44                selectedfile = ostrcat(selectedfile, getconfig("mc_vp_selectedfile", NULL), 1, 0);
45        }
46        else
47        {
48                currentdirectory = ostrcat(currentdirectory, getconfig("mc_vp_defaultdir", NULL), 1, 0);               
49        }
50
51        // enable listbox and set hidden
52        listbox->aktpage = -1;
53        listbox->aktline = 0;
54        listbox->hidden = YES;
55
56        // read configs
57        int view = getconfigint("mc_vp_view", NULL);
58        int skip13 = getconfigint("skip13", NULL);
59        int skip46 = getconfigint("skip46", NULL);
60        int skip79 = getconfigint("skip79", NULL);
61
62        // save policy
63        tmppolicy = getpolicy();
64       
65        // set allowed filemask
66        char* filemask = NULL;
67        if(file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack"))
68                filemask = ostrcat("*.m3u8 *.m3u *.pls *.ifo *.rar *.iso *.img *.avi *.dat *.divx *.flv *.mkv *.m4v *.mp4 *.mov *.mpg *.mpeg *.mts *.m2ts *.trp *.ts *.vdr *.vob *.rm *.wmv", NULL, 0, 0);
69        else
70                filemask = ostrcat("*.m3u *.pls *.avi *.mkv *.mpg *.mpeg *.ts *.mp2t", NULL, 0, 0);
71       
72        // disable global transparent/hangtime
73//      setfbtransparent(255);
74        status.hangtime = 99999;
75        status.playspeed = 0, status.play = 0, status.pause = 0, status.random = 0;
76
77        debug(50, "start screenmc_videoplayer view=%d", view);
78
79//      singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
80        char* defaultmvi = NULL;
81        defaultmvi = createpluginpath("/mc/skin/default.mvi", 0);
82        singlepicstart(defaultmvi, 0);
83
84        if(getconfigint("screensaver", NULL) == 1)
85                initscreensaver();
86
87        tmpview = view;
88        mc_changeview(view, filelist, apskin, flag);
89        thumb->hidden = YES;
90        plot->hidden = YES;
91        title->hidden = YES;
92        stars->hidden = YES;
93
94//      clearscreen(loadmediadb);       
95        getfilelist(apskin, filelistpath, filelist, currentdirectory, filemask, tmpview, selectedfile);
96        addscreenrc(apskin, filelist);
97
98        char* savecmd = NULL;
99
100        if(!file_exist("/mnt/swapextensions/player"))   
101                mkdir("/mnt/swapextensions/player", 0777);
102       
103        int refresh = 0;                       
104        while(1)
105        {
106               
107                rcret = waitrcext(apskin, rcwait, 0, tmpview);
108                if(filelist->select != NULL && filelist->select->input != NULL)
109                        refresh = 1;
110                else
111                        refresh = 0;
112
113#ifdef EXTEPLAYER3
114//              getsubtext();
115#endif
116                if(status.play == 1 || status.playspeed != 0)
117                {
118                        playinfobarcount ++;
119                        if(playinfobarstatus > 0)
120                        {
121                                if(videooff == 0) screenplayinfobar(filename, NULL, 0, playertype, 0);
122                        }
123                        if(playinfobarstatus == 1 && playinfobarcount >= getconfigint("infobartimeout", NULL))
124                        {
125                                playinfobarstatus = 0;
126                                if(videooff == 0) screenplayinfobar(NULL, NULL, 1, playertype, 0);
127                        }
128                }
129                else if(exit == 0 && tmpview == 3 && filelist->select != NULL && status.play == 0 && status.pause == 0)
130                {
131                        char* cmd = NULL;
132                        char* pic = NULL;
133
134                        int waittime = 5, foundthumb = 0, foundplot = 0, foundtitle = 0, foundstars = 0;
135                        waittime = getconfigint("mc_vp_backdrop_interval", NULL);
136
137                        if(filelist->select != NULL && filelist->select->input == NULL)
138                        {
139                                struct mediadb* mnode = getmediadb(filelistpath->text, filelist->select->name, 0);
140
141                                if(mnode != NULL)
142                                {
143                                        if(mnode->id != NULL)
144                                        {
145                                                if(ostrcmp(lastid, mnode->id) != 0)                                     
146                                                {
147                                                        free(lastid), lastid = NULL;
148                                                        lastid = ostrcat(lastid, mnode->id, 1, 0);
149                                                        mvinum = 1;
150                                                        mviwait = waittime;
151                                                }
152                                                else
153                                                {
154                                                        if(mvinum == mnode->backdropcount)
155                                                                mvinum = 1;
156
157                                                        if(mviwait > waittime && mvinum < mnode->backdropcount)
158                                                                mvinum++;
159                                                }
160
161                                                tmpstr = ostrcat(tmpstr, getconfig("mediadbpath", NULL), 1, 0);
162                                                tmpstr = ostrcat(tmpstr, "/", 1, 0);                                                                                                                                                   
163                                                tmpstr = ostrcat(tmpstr, mnode->id, 1, 0);
164       
165                                                pic = ostrcat(tmpstr, "_thumb.jpg", 0, 0);
166                                               
167                                                cmd = ostrcat(tmpstr, "_backdrop", 0, 0);
168                                                cmd = ostrcat(cmd, oitoa(mvinum), 1, 0);
169                                                cmd = ostrcat(cmd, ".mvi", 1, 0);
170                                                free(tmpstr), tmpstr = NULL;
171                                        }
172                                        if(mnode->plot != NULL)
173                                                changetext(plot, mnode->plot);
174                                        if(mnode->title != NULL)
175                                                changetext(title, mnode->title);
176
177                                        if(mnode->poster == NULL)
178                                        {
179                                                thumb->hidden = YES;
180                                                free(pic), pic = NULL;
181                                                foundthumb = 0;
182                                        }
183                                        else
184                                        {
185                                                thumb->hidden = NO;
186                                                changepic(thumb, pic);
187                                                free(pic), pic = NULL;
188                                                foundthumb = 1;
189                                        }
190                                       
191                                        if(mnode->plot == NULL)
192                                        {
193                                                foundplot = 0;
194                                                plot->hidden = YES;
195                                        }
196                                        else
197                                        {
198                                                foundplot = 1;
199                                                plot->hidden = NO;
200                                        }
201                                       
202                                        if(mnode->title == NULL)
203                                        {
204                                                foundtitle = 0;
205                                                title->hidden = YES;
206                                        }
207                                        else
208                                        {
209                                                foundtitle = 1;
210                                                title->hidden = NO;
211                                        }
212                                       
213                                        if(mnode->rating != 0)
214                                        {
215                                                foundstars = 1;
216                                                int rating = mnode->rating;
217                                                if(rating == 10)
218                                                        changepic(stars, "%pluginpath%/mc/skin/stars10.png");
219                                                else if(rating > 9)
220                                                        changepic(stars, "%pluginpath%/mc/skin/stars9x.png");
221                                                else if(rating == 9)
222                                                        changepic(stars, "%pluginpath%/mc/skin/stars9.png");
223                                                else if(rating > 8)
224                                                        changepic(stars, "%pluginpath%/mc/skin/stars8x.png");
225                                                else if(rating == 8)
226                                                        changepic(stars, "%pluginpath%/mc/skin/stars8.png");
227                                                else if(rating > 7)
228                                                        changepic(stars, "%pluginpath%/mc/skin/stars7x.png");
229                                                else if(rating == 7)
230                                                        changepic(stars, "%pluginpath%/mc/skin/stars7.png");
231                                                else if(rating > 6)
232                                                        changepic(stars, "%pluginpath%/mc/skin/stars6x.png");
233                                                else if(rating == 6)
234                                                        changepic(stars, "%pluginpath%/mc/skin/stars6.png");
235                                                else if(rating > 5)
236                                                        changepic(stars, "%pluginpath%/mc/skin/stars5x.png");
237                                                else if(rating == 5)
238                                                        changepic(stars, "%pluginpath%/mc/skin/stars5.png");
239                                                else if(rating > 5)
240                                                        changepic(stars, "%pluginpath%/mc/skin/stars5x.png");
241                                                else if(rating == 5)
242                                                        changepic(stars, "%pluginpath%/mc/skin/stars5.png");
243                                                else if(rating > 4)
244                                                        changepic(stars, "%pluginpath%/mc/skin/stars4x.png");
245                                                else if(rating == 4)
246                                                        changepic(stars, "%pluginpath%/mc/skin/stars4.png");
247                                                else if(rating > 3)
248                                                        changepic(stars, "%pluginpath%/mc/skin/stars3x.png");
249                                                else if(rating == 3)
250                                                        changepic(stars, "%pluginpath%/mc/skin/stars3.png");
251                                                else if(rating > 2)
252                                                        changepic(stars, "%pluginpath%/mc/skin/stars2x.png");
253                                                else if(rating == 2)
254                                                        changepic(stars, "%pluginpath%/mc/skin/stars2.png");
255                                                else if(rating > 1)
256                                                        changepic(stars, "%pluginpath%/mc/skin/stars1x.png");
257                                                else if(rating == 1)
258                                                        changepic(stars, "%pluginpath%/mc/skin/stars1.png");
259                                                else if(rating > 0)
260                                                        changepic(stars, "%pluginpath%/mc/skin/stars0x.png");
261                                                else
262                                                        changepic(stars, NULL);
263                                                stars->hidden = NO;
264                                        }
265                                        else
266                                        {
267                                                foundstars = 0;
268                                                changepic(stars, NULL);
269                                                stars->hidden = YES;
270                                        }
271                                }
272                                else   
273                                {
274                                        refresh = 1;                           
275                                        foundthumb = 0;
276                                        foundplot = 0;
277                                        foundtitle = 0;
278                                        foundstars = 0;
279                                        thumb->hidden = YES;
280                                        plot->hidden = YES;
281                                        title->hidden = YES;
282                                        stars->hidden = YES;
283                                        free(pic), pic = NULL;
284                                }
285                                       
286                                drawscreen(apskin, 0, 0);
287                        }
288
289                        debug(50, "cmd: %s", cmd);     
290                        if(!file_exist(cmd))
291                        {
292                                free(cmd), cmd = NULL;
293//                              cmd = ostrcat(cmd, "/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 1, 0);
294                                cmd = ostrcat(cmd, defaultmvi, 1, 0);
295                                mviwait = waittime;
296                                if(foundthumb == 0)
297                                        thumb->hidden = YES;
298                                if(foundplot == 0)
299                                        plot->hidden = YES;
300                                if(foundtitle == 0)
301                                        title->hidden = YES;
302                                if(foundstars == 0)                                     
303                                        stars->hidden = YES;
304
305                                drawscreen(apskin, 0, 0);
306                        }
307
308                        if(savecmd == NULL)
309                        {
310                                singlepicstart(cmd, 0);
311                                free(savecmd), savecmd = NULL;
312                                savecmd = ostrcat(savecmd, cmd, 1, 0);
313                        }
314                        else
315                        {
316                                if((refresh == 1 ) || (exit == 0 && ostrcmp(savecmd, cmd) != 0 && mviwait > waittime - 1))
317                                {
318                                        singlepicstart(cmd, 0);
319                                        free(savecmd), savecmd = NULL;
320                                        savecmd = ostrcat(savecmd, cmd, 1, 0);
321                                        mviwait = 0;
322                                }
323                                else if(waittime == 0)
324                                {
325                                        debug(50, "disable Backdrop Interval");
326                                }
327                                else
328                                        mviwait++;
329                        }
330                        free(cmd), cmd = NULL;
331                }
332
333                if (rcret == getrcconfigint("rcrecord", NULL))
334                {
335                        system("grab -j 100");
336                        textbox(_("Message"), _("Shooting Background done !\nSave Screenshoot Path: /tmp/screenshot.jpg"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
337                }
338                else if(rcret == getrcconfigint("rc2", NULL))
339                {
340                        if((status.play == 1) || (status.playspeed != 0))
341                                playrcjumpto(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
342                }
343                else if(rcret == getrcconfigint("rc1", NULL))
344                {
345                        if((status.play == 1) || (status.playspeed != 0))
346                                playrcjumpr(filename, NULL, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
347                }
348                else if(rcret == getrcconfigint("rc4", NULL))
349                {
350                        if((status.play == 1) || (status.playspeed != 0))
351                                playrcjumpr(filename, NULL, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
352                }
353                else if(rcret == getrcconfigint("rc7", NULL))
354                {
355                        if((status.play == 1) || (status.playspeed != 0))
356                                playrcjumpr(filename, NULL, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
357                }
358                else if(rcret == getrcconfigint("rc3", NULL))
359                {
360                        if((status.play == 1) || (status.playspeed != 0))
361                                playrcjumpf(filename, NULL, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
362                }
363                else if(rcret == getrcconfigint("rc6", NULL))
364                {
365                        if((status.play == 1) || (status.playspeed != 0))
366                                playrcjumpf(filename, NULL, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
367                }
368                else if(rcret == getrcconfigint("rc9", NULL))
369                {
370                        if((status.play == 1) || (status.playspeed != 0))
371                                playrcjumpf(filename, NULL, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
372                }
373                else if(rcret == getrcconfigint("rcleft", NULL))
374                {
375                        if((status.play == 1) || (status.playspeed != 0))
376                                playrcjumpr(filename, NULL, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
377                }
378                else if(rcret == getrcconfigint("rcright", NULL))
379                {
380                        if((status.play == 1) || (status.playspeed != 0))
381                                playrcjumpf(filename, NULL, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
382                }
383                else if(rcret == getrcconfigint("rcdown", NULL))
384                {
385                        if((status.play == 1) || (status.playspeed != 0))
386                                playrcjumpr(filename, NULL, 600, &playinfobarstatus, &playinfobarcount, playertype, flag);
387                }
388                else if(rcret == getrcconfigint("rcup", NULL))
389                {
390                        if(status.play == 1 || status.playspeed != 0 || status.pause == 1)
391                                playrcjumpf(filename, NULL, 600, &playinfobarstatus, &playinfobarcount, playertype, flag);
392                }
393
394                else if(rcret == getrcconfigint("rcff", NULL))
395                {
396                        if(status.play == 1 || status.playspeed != 0 || status.pause == 1)
397                                playrcff(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
398                }       
399                else if(rcret == getrcconfigint("rcfr", NULL))
400                {
401                        if((status.play == 1) || (status.playspeed != 0))
402                                playrcfr(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
403                }
404               
405                else if(rcret == getrcconfigint("rcpause", NULL) || ((checkbox("DM7020HD") == 1 || checkbox("DM7020HDV2") == 1 || checkbox("DM900") == 1 || checkbox("DM520") == 1 || checkbox("DM525") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1 || checkbox("ATEMIO520") == 1 || checkbox("ATEMIO530") == 1) && rcret == getrcconfigint("rcplay", NULL) && status.pause == 0 && status.slowspeed == 0 && status.playspeed == 0 && ostrcmp(getconfig("remotecontrol", NULL), "0") == 0))
406                {
407                        if((status.play == 1) || (status.pause == 1) || (status.playspeed != 0))
408                                playrcpause(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
409                }
410                else if(rcret == getrcconfigint("rcplay", NULL))
411                {
412                        if((status.play == 1) || (status.pause == 1) || (status.playspeed != 0))
413                                playrcplay(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
414                }
415                else if(rcret == getrcconfigint("rcnext", NULL) || rcret == getrcconfigint("rcchdown", NULL))
416                {
417                        if(status.play == 1)
418                                eof = 1;
419                }
420                else if(rcret == getrcconfigint("rcprev", NULL) || rcret == getrcconfigint("rcchup", NULL))
421                {
422                        if(status.play == 1)
423                                eof = 2;
424                }
425                else if(rcret == getrcconfigint("rcblue", NULL))
426                {
427                        if(status.play == 1)
428                                playrcblue(filename, NULL, playinfobarstatus, playertype, flag);
429                        else
430                        {
431                                if(status.repeat == 0)
432                                {
433                                        changetext(b4, _("Repeat-On"));
434                                        drawscreen(apskin, 0, 0);
435                                        status.repeat = 1;
436                                }
437                                else
438                                {
439                                        status.repeat = 0;
440                                        changetext(b4, _("Repeat"));
441                                        drawscreen(apskin, 0, 0);
442                                }
443                        }
444                }
445                else if(rcret == getrcconfigint("rcyellow", NULL))
446                {
447                        if(status.play == 1)
448                                playrcyellow(filename, NULL, playinfobarstatus, playertype, flag);                                             
449                        else
450                                playerrandom(apskin, filelist, listbox, b3, playlist, flag);
451                }
452                else if(rcret == getrcconfigint("rcred", NULL))
453                {
454                        if(status.play == 1)
455                                playrcred(filename, NULL, playinfobarstatus, playertype, flag);
456                        else
457                        {
458                                if(playlist == 0)
459                                {
460                                        int sort = screendirsort();
461                                        debug(50, "rcred: tmpsort=%d", sort);
462
463                                        // fixt grey if sorting >10s
464                                        drawscreen(skin, 0, 0);
465       
466                                        addconfiginttmp("dirsort", sort);
467                                        mc_changeview(tmpview, filelist, apskin, flag);
468
469                                        delownerrc(apskin);     
470                                        getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->name);
471                                        addscreenrc(apskin, filelist);
472                                        drawscreen(apskin, 0, 0);
473                                }
474                        }
475                }
476                else if(rcret == getrcconfigint("rcgreen", NULL))
477                {
478                        if(status.play == 1)
479                                playrcgreen(filename, NULL, playinfobarstatus, playertype, flag);
480                        else
481                        {
482                                showplaylist(apskin, filelistpath, filelist, listbox, b2, 0, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
483                                drawscreen(apskin, 0, 0);
484                                continue;                       
485                        }
486                }
487                else if(rcret == getrcconfigint("rctext", NULL) || rcret == getrcconfigint("rcsubtitel", NULL))
488                {               
489                        if(status.play == 1)
490                                playrctext(filename, NULL, playinfobarstatus, playertype, flag);       
491                }
492                else if(rcret == getrcconfigint("rcmenu", NULL))
493                {
494                        if(status.play == 0 && status.pause == 0)
495                        {
496                                refresh = 1;
497                                debug(50, "rcmenu: settings");
498//                              singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
499                                singlepicstart(defaultmvi, 0);
500                                view = getconfigint("mc_vp_view", NULL);
501                                printf("view in: %d\n", view);
502                                printf("tmpview in: %d\n", tmpview);
503
504                                screenmc_videoplayer_settings();
505                                drawscreen(blackscreen, 0, 0);
506                                drawscreen(loadmediadb, 0, 0);                         
507                                if(view != getconfigint("mc_vp_view", NULL))
508                                {
509                                        printf("view changed > change tmpview\n");
510                                        tmpview = getconfigint("mc_vp_view", NULL);
511                                }
512
513                                if(getconfig("mc_vp_dirsort", NULL) != getconfig("dirsort", NULL))
514                                {
515                                        char* tmpstr = NULL;
516                                        tmpstr = ostrcat(getconfig("mc_vp_dirsort", NULL), NULL, 0, 0);
517                                        addconfigtmp("dirsort", tmpstr);
518                                        free(tmpstr), tmpstr = NULL;
519                                }
520
521                                printf("1view in: %d\n", view);
522                                printf("1tmpview in: %d\n", tmpview);
523                               
524                                mc_changeview(tmpview, filelist, apskin, flag);
525
526                                drawscreen(blackscreen, 0, 0);
527                                drawscreen(loadmediadb, 0, 0);
528                                printf("2view in: %d\n", view);
529                                printf("2tmpview in: %d\n", tmpview);
530       
531                                delownerrc(apskin);
532                                getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->name);
533                                addscreenrc(apskin, filelist);
534                                drawscreen(apskin, 0, 0);
535                        }
536                }
537                else if(rcret == getrcconfigint("rcinfo", NULL))
538                {
539                        if(status.play == 0 && status.pause == 0)
540                        {
541                                drawscreen(blackscreen, 0, 0);
542//                              if(filelist->select != NULL && filelist->select->input == NULL)
543//                              {
544                                        filename = createpath(filelistpath->text, filelist->select->name);
545                                        debug(133, "filename: %s", filename);                           
546                                        playrcred(filename, NULL, playinfobarstatus, playertype, flag);
547//                              }
548                        }
549                        else
550                                playrcplay(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
551
552                        if(status.play == 0 && status.pause == 0)
553                        {
554                                drawscreen(skin, 0, 0);
555                                drawscreen(blackscreen, 0, 0);
556                                drawscreen(loadmediadb, 0, 0);
557                                delownerrc(apskin);
558                                getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->name);
559                                addscreenrc(apskin, filelist);
560                                drawscreen(apskin, 0, 0);
561                        }       
562                }
563                else if(rcret == getrcconfigint("rcpower", NULL) && status.play == 1 && videooff == 0)
564                {
565                        videooff = 1;
566                        drawscreen(blackscreen, 0, 0);
567                }
568                else if(rcret == getrcconfigint("rcexit", NULL) && videooff == 1)
569                {
570                        videooff = 0;
571                        drawscreen(skin, 0, 0);
572                }
573                else if(rcret == getrcconfigint("rcstop", NULL) || (rcret == getrcconfigint("rcexit", NULL) && status.play == 1))
574                {
575                        debug(50, "rcstop: stopplayback");
576                        drawscreen(blackscreen, 0, 0);
577                        drawscreen(loadmediadb, 0, 0);
578                        if(status.play == 1 && playertype == 0)
579                        {
580                                char* tmpfilename = ostrcat(filename, NULL, 0, 0);
581                                char* fileseek = ostrcat("/mnt/swapextensions/player/", basename(tmpfilename), 0, 0);
582                                fileseek = ostrcat(fileseek, ".se", 0, 0);
583                                FILE* fbseek = fopen(fileseek, "w");
584                                if(fbseek != NULL)
585                                {
586                                        off64_t pos = playergetpts() / 90000;
587                                        fprintf(fbseek,"%lld", pos);
588                                        fclose(fbseek);
589                                }
590                                free(fileseek), fileseek = NULL;
591                                free(tmpfilename), tmpfilename = NULL;
592                        }
593                       
594//                      servicestop(status.aktservice, 1, 1);
595                        playrcstop(playertype, flag);
596                        drawscreen(blackscreen, 0, 0);
597                        drawscreen(loadmediadb, 0, 0);
598                        sleep(2);
599//                      singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
600                        singlepicstart(defaultmvi, 0);
601
602                        // show skin
603                        setfbtransparent(255);
604
605                        apskin->hidden = NO;
606                        filelist->hidden = NO;
607                        listbox->hidden = YES;
608                        changetext(filelistpath, _(getconfig("mc_vp_path", NULL)));
609                        changetext(b2, _("Filelist-Mode"));
610
611                        // switch filelist
612                        delownerrc(apskin);
613                        addscreenrc(apskin, filelist);
614                        // show skin
615                        drawscreen(apskin, 0, 0);
616
617                        setfbtransparent(255);
618                        clearscreen(loadmediadb);
619                        clearscreen(blackscreen);
620
621                        playinfobarcount = 0;
622                        playinfobarstatus = 1;
623                        status.playspeed = 0;
624                        status.pause = 0;
625                        status.play = 0;
626                        playlist = 0;
627                        playinfobarcount = 0;
628                       
629                        if(playertype == 1)
630                                playerafterendts();
631                        else
632                                playerafterend();
633               
634                        writevfdmenu("VideoPlayer Filelist-Mode");
635                }
636                else if(rcret == getrcconfigint("rcexit", NULL))
637                {
638                        videooff = 0;
639                        exit = 1;
640                        debug(50, "exit - save mc_vp_path: %s", filelistpath->text);
641                        debug(50, "exit - save mc_vp_selectedfile: %s", filelist->select->name);
642                        drawscreen(blackscreen, 0, 0);
643                        drawscreen(loadmediadb, 0, 0);
644
645                        if(playlist == 0)
646                        {
647                                if(filelistpath->text != NULL && ostrcmp(getconfig("mc_vp_path", NULL), filelistpath->text) != 0)
648                                        addconfig("mc_vp_path", filelistpath->text);
649                                if(filelist->select != NULL && filelist->select->name != NULL && ostrcmp(getconfig("mc_vp_selectedfile", NULL), filelist->select->name) != 0)
650                                        addconfig("mc_vp_selectedfile", filelist->select->name);
651                        }
652
653                        if(status.play == 1 && playertype == 0)
654                        {
655                                char* tmpfilename = ostrcat(filename, NULL, 0, 0);
656                                char* fileseek = ostrcat("/mnt/swapextensions/player/", basename(tmpfilename), 0, 0);
657                                fileseek = ostrcat(fileseek, ".se", 0, 0);
658                                FILE* fbseek = fopen(fileseek, "w");
659                                if(fbseek != NULL)
660                                {
661                                        off64_t pos = playergetpts() / 90000;
662                                        fprintf(fbseek,"%lld", pos);
663                                        fclose(fbseek);
664                                }
665                                free(fileseek), fileseek = NULL;
666                                free(tmpfilename), tmpfilename = NULL;
667                        }
668
669//                      setfbtransparent(0);
670                        servicestop(status.aktservice, 1, 1);
671                        playrcstop(playertype, flag);
672                        drawscreen(blackscreen, 0, 0);
673                        drawscreen(loadmediadb, 0, 0);
674                        sleep(2);
675//                      singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
676                        singlepicstart(defaultmvi, 0);
677
678                        // show skin
679                        setfbtransparent(255);
680                        apskin->hidden = NO;
681                        filelist->hidden = NO;
682                        listbox->hidden = YES;
683                        changetext(b2, _("Filelist-Mode"));
684                        changetext(b3, _("Random"));
685                        changetext(b4, _("Repeat"));                                                                           
686                        status.playspeed = 0;
687                        status.pause = 0;
688                        status.play = 0;
689                        status.random = 0;
690                        status.repeat = 0;
691                        playlist = 0;
692                        writevfdmenu("Mediacenter");
693                        playinfobarcount = 0;
694       
695                        printf("exit: view=%d tmpview=%d\n", view, tmpview);
696                        unlink("/tmp/.autoscan");
697                        break;
698                }
699                else if(rcret == getrcconfigint("rcok", NULL))
700                {
701                        if((status.play == 1) || (status.playspeed != 0))
702                        {
703                                playrcok(filename, NULL, playinfobarstatus, playertype, flag);
704                                continue;
705                        }
706
707                        playinfobarcount = 0;
708                        playinfobarstatus = 1;
709                        status.playspeed = 0;
710                        status.pause = 0;
711//                      status.play = 0;
712//                      playlist = 0;
713                        playinfobarcount = 0;
714
715                        if(playlist == 1 && listbox->select != NULL)
716                        {
717                                debug(50, "listbox->select->name: %s", listbox->select->name);
718                                filename = ostrcat("", listbox->select->name, 0, 0);
719
720//                              if(cmpfilenameext(filename, ".ts") == 0 && ostrstr(filename, "://") == NULL && checkbox("VUSOLO2") != 1)
721//                              if(cmpfilenameext(filename, ".ts") == 0 && ostrstr(filename, "://") == NULL)
722//                                      playertype = 1;
723//                              else
724                                        playertype = 0;
725
726                                changetext(b2, _("Playlist-Mode"));
727                       
728                                debug(50, "screensaver title: %s", listbox->select->text);
729                                if(screensaver != NULL && screensaver->type == 0)
730                                        screensaver->value = listbox->select->text;
731
732                                debug(50, "playerstop");
733                                playrcstop(playertype, flag);
734//                              sleep(1);
735//                              drawscreen(infobar, 0, 0);
736
737                                debug(50, "playerstart: %s", filename);
738                                eof = 0;
739
740                                delownerrc(apskin);
741//                              setfbtransparent(255);
742//////////
743                                servicestop(status.aktservice, 1, 1);
744                                drawscreen(skin, 0, 0);
745//                              setfbtransparent(255);
746                                debug(50, "check");
747                                debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
748                                debug(50, "status.play: %d", status.play);
749                                debug(50, "flag: %d", flag);
750///////////
751                                debug(50, "playertype: %d", playertype);
752                                if(playertype == 1)
753                                        playerret = playerstartts(filename, 0);
754                                else
755                                        playerret = playerstart(filename);
756
757                                playwritevfd(filename, NULL);
758
759                                #ifndef SIMULATE
760                                        if(playerret != 0)
761                                        {
762                                                writevfdmenu("VideoPlayer Filelist-Mode");
763                                                status.play = 0;
764                                                playlist = 0;
765                                                status.playspeed = 0;
766                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
767
768                                                changetext(filelistpath, _(getconfig("mc_vp_path", NULL)));
769                                                filelist->hidden = NO;
770                                                listbox->hidden = YES;
771
772                                                addscreenrc(apskin, filelist);
773                                                drawscreen(apskin, 0, 0);
774                                                continue;
775                                        }
776                                #endif
777
778                                if(videooff == 0) screenplayinfobar(filename, NULL, 0, playertype, 0);                 
779                                status.play = 1;
780                               
781                                free(status.playfile); status.playfile = NULL;
782                                status.playfile = ostrcat(filename, "", 0, 0);
783                        }
784                        else if(filelist->select != NULL && filelist->select->input != NULL)
785                        {
786
787                                char* tmpfilename = ostrcat(filelistpath->text, NULL, 0, 0);                   
788
789                                // workaround dont open folder on rcchup
790                                if(skip == 1)
791                                {
792                                        drawscreen(apskin, 0, 0);
793                                        writerc(getrcconfigint("rcok", NULL));
794                                        skip = 0;
795                                }
796                                else if(!ostrncmp("video_ts", string_tolower(basename(tmpfilename)), 8))
797                                {
798                                        struct skin* dvdplayer = getplugin("DVD Player");
799                                        if(dvdplayer != NULL)
800                                        {
801                                                if(textbox(_("Message"), _("Found VIDEO_TS Folder, start with DVD-Player ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 5, 0) == 1)
802                                                {
803                                                        void (*startplugin)(char*, int);
804                                                        startplugin = dlsym(dvdplayer->pluginhandle, "screendvdplay");
805                                                        if(startplugin != NULL)
806                                                        {
807                                                                debug(50, "filelist->select->name: %s", filelist->select->name);
808                                                                filename = createpath(filelistpath->text, filelist->select->name);
809                                                                printf("start dvdplayer plugin\n");
810                                                                startplugin(filename,0);
811                                                        }
812                                                }
813                                                drawscreen(apskin, 0, 0);
814//                                              singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
815                                                singlepicstart(defaultmvi, 0);
816                                        }
817                                        else
818                                        {
819                                                debug(50, "mc_mounter_chk start");
820                                                mc_mounter_chk(filelistpath);
821                                                debug(50, "mc_mounter_chk done");
822
823                                                char* checkautoscan = NULL;
824                                                checkautoscan = readfiletomem("/tmp/.autoscan", 0);
825       
826                                                if(filelistpath->text != NULL && ostrcmp(checkautoscan, filelistpath->text) != 0)
827                                                        unlink("/tmp/.autoscan");
828       
829                                                free(checkautoscan), checkautoscan = NULL;
830                                        }
831                                }
832                                free(tmpfilename), tmpfilename = NULL;
833                        }
834                        else if(filelist->select != NULL && filelist->select->input == NULL)
835                        {
836                                if(filelistpath->text != NULL && ostrcmp(getconfig("mc_vp_path", NULL), filelistpath->text) != 0)
837                                        addconfig("mc_vp_path", filelistpath->text);
838
839                                debug(50, "filelist->select->text: %s", filelist->select->text);
840                                filename = createpath(filelistpath->text, filelist->select->name);
841
842//                              if(cmpfilenameext(filename, ".ts") == 0 && checkbox("VUSOLO2") != 1)           
843//                              if(cmpfilenameext(filename, ".ts") == 0)
844//                                      playertype = 1;
845//                              else
846                                        playertype = 0;
847
848                                if(cmpfilenameext(filename, ".rar") == 0 || cmpfilenameext(filename, ".iso") == 0 || cmpfilenameext(filename, ".img") == 0)
849                                {
850                                        debug(50, "mc_mounter_main filename: %s", filename);
851                                        //addconfig("mc_vp_path", filelistpath->text);
852                                        currentdirectory = ostrcat("", getconfig("mc_vp_path", NULL), 0, 0);
853                                        selectedfile = ostrcat(selectedfile, getconfig("mc_vp_selectedfile", NULL), 0, 0);
854
855                                        mc_mounter_main(0,filename,filelistpath,filelist,apskin,filemask,tmpview,currentdirectory);
856                                        debug(50, "mc_mounter_main done");
857
858//                                      singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
859                                        singlepicstart(defaultmvi, 0);
860                                        continue;
861                                }
862                                else if(cmpfilenameext(filename, ".m3u") == 0 || cmpfilenameext(filename, ".pls") == 0)
863                                {
864                                        showplaylist(apskin, filelistpath, filelist, listbox, b2, 1, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
865
866                                        if(getconfigint("mc_vp_autostart_playlist", NULL) == 0)
867                                                drawscreen(apskin, 0, 0);
868                                        continue;
869
870                                }
871
872                                changetext(b2, _("Filelist-Mode"));
873                       
874                                if(screensaver != NULL && screensaver->type == 0)
875                                        screensaver->value = (void*)filelist->select->text;
876
877                                setfbtransparent(0);
878
879//                              debug(50, "playerstop");
880//                              playrcstop(playertype, flag);
881
882                                delownerrc(apskin);
883
884                                debug(50, "playerstart: %s", filename);
885                                eof = 0;
886
887                                servicestop(status.aktservice, 1, 1);
888                                drawscreen(skin, 0, 0);
889                                drawscreen(loadmediadb, 0, 0);
890                                setfbtransparent(255);
891       
892                                debug(50, "playertype: %d", playertype);
893                                if(playertype == 1)
894                                        playerret = playerstartts(filename, 0);
895                                else
896                                        playerret = playerstart(filename);
897
898                                playwritevfd(filename, NULL);
899
900                                #ifndef SIMULATE
901                                        if(playerret != 0)
902                                        {
903                                                writevfdmenu("VideoPlayer Filelist-Mode");
904                                                status.play = 0;
905                                                status.playspeed = 0;
906                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 0, 0);
907                                                addscreenrc(apskin, filelist);
908//                                              drawscreen(apskin, 0, 0);
909                                                continue;
910                                        }
911                                        else
912                                        {
913                                                if(playertype == 0 && getconfigint("showlastpos", NULL) == 1)
914                                                {
915                                                        char* tmpfilename = ostrcat(filename, NULL, 0, 0);
916                                                        char* fileseek = ostrcat("/mnt/swapextensions/player/", basename(tmpfilename), 0, 0);
917                                                        fileseek = ostrcat(fileseek, ".se", 0, 0);
918       
919                                                        FILE* fbseek = fopen(fileseek, "r");
920                                                        if(fbseek != NULL)
921                                                        {
922                                                                if(textbox(_("Message"), _("Start at last position ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 5, 0) == 1)
923                                                                {
924                                                                        char* skip1 = calloc(1, 20);
925                                                                        if(skip1 != NULL)
926                                                                        {
927                                                                                fscanf(fbseek,"%s",skip1);
928                                                                                playrcjumpf(filename, NULL, atoll(skip1), &playinfobarstatus, &playinfobarcount, playertype, flag);             
929                                                                        }
930                                                                        free(skip1), skip1 = NULL;
931                                                                }
932                                                                fclose(fbseek);
933                                                        }
934                                                        free(fileseek), fileseek = NULL;
935                                                        free(tmpfilename), tmpfilename = NULL;
936                                                }
937                                        }
938               
939                                #endif
940
941                                clearscreen(loadmediadb);
942                                if(videooff == 0) screenplayinfobar(filename, NULL, 0, playertype, 0);
943                                status.play = 1;
944
945                                free(status.playfile); status.playfile = NULL;
946                                status.playfile = ostrcat(filename, "", 0, 0);
947
948                                if(status.mediadbfiles == 0 && getconfigint("mc_vp_autoscan", NULL) == 1 && !file_exist("/tmp/.autoscan"))
949                                {
950                                        if(filelistpath->text != NULL)
951                                        {
952                                                mediadbscan(filelistpath->text, 1000, 1);
953                                                writesys("/tmp/.autoscan", filelistpath->text, 0);
954                                                status.mediadbfiles = findfiles(filelistpath->text, 0, 1, 1, 1); //count only
955                                        }
956                                        else
957                                        {
958                                                mediadbscan(currentdirectory, 1000, 1);
959                                                writesys("/tmp/.autoscan", currentdirectory, 0);
960                                                status.mediadbfiles = findfiles(currentdirectory, 0, 1, 1, 1); //count only
961                                        }
962                                }
963                        }
964                }
965
966                if(eof >=1 || (playertype == 0 && playerisplaying() == 0) || (playertype == 1 && playerisplayingts() == 0))
967                {
968                        if(status.play == 1)
969                        {
970                                char* tmpfilename = ostrcat(filename, NULL, 0, 0);
971                                char* fileseek = ostrcat("/mnt/swapextensions/player/", basename(tmpfilename), 0, 0);
972                                fileseek = ostrcat(fileseek, ".se", 0, 0);
973                                unlink(fileseek);
974                       
975                                setfbtransparent(0);
976                                apskin->hidden = NO;
977                                drawscreen(skin, 0, 0);
978                                playereof(apskin, filelist, listbox, filelistpath, b2, NULL, NULL, NULL, &skip, &eof, &playlist, playertype, flag);
979                        }
980                }
981                if(videooff == 1) drawscreen(blackscreen, 0, 0);
982        }
983
984        deinitscreensaver();
985        status.hangtime = getconfigint("hangtime", NULL);
986        delconfigtmp("dirsort");
987        delconfigtmp("mediadbpath");
988        delconfigtmp("mediadbfile");
989        delconfigtmp("mediadbscandelall");
990        delconfigtmp("mediadbscandelnotfound");
991        delconfigtmp("mediadbscantimeout");
992       
993        delmarkedscreennodes(apskin, FILELISTDELMARK);
994        delownerrc(apskin);
995        clearscreen(apskin);
996
997        free(filename), filename = NULL;
998        free(currentdirectory), currentdirectory = NULL;
999        free(selectedfile), selectedfile = NULL;
1000        free(lastid), lastid = NULL;
1001
1002        free(status.playfile); status.playfile = NULL;
1003        if(tmppolicy != NULL)
1004        {
1005                setpolicy(tmppolicy);
1006                free(tmppolicy);
1007        }
1008
1009        if(playertype == 1)
1010                playerafterendts();
1011        else
1012                playerafterend();
1013
1014
1015        if(status.mediadbthread == NULL)
1016        {
1017                if(status.writemediadb == 1)
1018                        writemediadb(getconfig("mediadbfile", NULL), NULL);
1019                freemediadb(0);
1020        }
1021
1022        clearscreen(blackscreen);
1023        clearscreen(loadmediadb);
1024
1025        system("/bin/umount -fl `mount | grep fuse | grep rarfs | grep -v '/dev/' | cut -d ' ' -f3` > /dev/null 2>&1; killall -9 rarfs > /dev/null 2>&1");
1026        system("/bin/umount -fl `mount | grep fuse | grep -v '/dev/' | cut -d ' ' -f3` > /dev/null 2>&1; /bin/umount -fl `mount | grep iso9660 | cut -d ' ' -f3`  `mount | grep udf | cut -d ' ' -f3` > /dev/null 2>&1; killall -9 rarfs fusesmb curlftpfs > /dev/null 2>&1");
1027        system("umount -a -f -t fuse.rarfs,iso9660,udf,fuse.djmount,fuse.fusesmb,fuse.curlftpfs > /dev/null 2>&1");
1028
1029        free(defaultmvi), defaultmvi = NULL;
1030
1031        writevfdmenu("Mediacenter");
1032        debug(50, "closed");
1033}
1034
1035#endif
Note: See TracBrowser for help on using the repository browser.