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

Last change on this file since 32753 was 32753, checked in by obi, 9 years ago

testfix mc black bg after stop

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