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

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

fix dvdplayer and po

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