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

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

atemio520 fix player stuff

File size: 30.5 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("rcrecord", NULL))
323                {
324                        system("grab -j 100");
325                        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);
326                }
327                else if(rcret == getrcconfigint("rc2", NULL))
328                {
329                        if((status.play == 1) || (status.playspeed != 0))
330                                playrcjumpto(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
331                }
332                else if(rcret == getrcconfigint("rc1", NULL))
333                {
334                        if((status.play == 1) || (status.playspeed != 0))
335                                playrcjumpr(filename, NULL, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
336                }
337                else if(rcret == getrcconfigint("rc4", NULL))
338                {
339                        if((status.play == 1) || (status.playspeed != 0))
340                                playrcjumpr(filename, NULL, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
341                }
342                else if(rcret == getrcconfigint("rc7", NULL))
343                {
344                        if((status.play == 1) || (status.playspeed != 0))
345                                playrcjumpr(filename, NULL, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
346                }
347                else if(rcret == getrcconfigint("rc3", NULL))
348                {
349                        if((status.play == 1) || (status.playspeed != 0))
350                                playrcjumpf(filename, NULL, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
351                }
352                else if(rcret == getrcconfigint("rc6", NULL))
353                {
354                        if((status.play == 1) || (status.playspeed != 0))
355                                playrcjumpf(filename, NULL, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
356                }
357                else if(rcret == getrcconfigint("rc9", NULL))
358                {
359                        if((status.play == 1) || (status.playspeed != 0))
360                                playrcjumpf(filename, NULL, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
361                }
362                else if(rcret == getrcconfigint("rcleft", NULL))
363                {
364                        if((status.play == 1) || (status.playspeed != 0))
365                                playrcjumpr(filename, NULL, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
366                }
367                else if(rcret == getrcconfigint("rcright", NULL))
368                {
369                        if((status.play == 1) || (status.playspeed != 0))
370                                playrcjumpf(filename, NULL, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
371                }
372                else if(rcret == getrcconfigint("rcdown", NULL))
373                {
374                        if((status.play == 1) || (status.playspeed != 0))
375                                playrcjumpr(filename, NULL, 600, &playinfobarstatus, &playinfobarcount, playertype, flag);
376                }
377                else if(rcret == getrcconfigint("rcup", NULL))
378                {
379                        if(status.play == 1 || status.playspeed != 0 || status.pause == 1)
380                                playrcjumpf(filename, NULL, 600, &playinfobarstatus, &playinfobarcount, playertype, flag);
381                }
382
383                else if(rcret == getrcconfigint("rcff", NULL))
384                {
385                        if(status.play == 1 || status.playspeed != 0 || status.pause == 1)
386                                playrcff(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
387                }       
388                else if(rcret == getrcconfigint("rcfr", NULL))
389                {
390                        if((status.play == 1) || (status.playspeed != 0))
391                                playrcfr(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
392                }
393                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))
394                {
395                        if((status.play == 1) || (status.pause == 1) || (status.playspeed != 0))
396                                playrcpause(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
397                }
398                else if(rcret == getrcconfigint("rcplay", NULL))
399                {
400                        if((status.play == 1) || (status.pause == 1) || (status.playspeed != 0))
401                                playrcplay(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
402                }
403                else if(rcret == getrcconfigint("rcnext", NULL))
404                {
405                        if(status.play == 1)
406                                eof = 1;
407                }
408                else if(rcret == getrcconfigint("rcprev", NULL))
409                {
410                        if(status.play == 1)
411                                eof = 2;
412                }
413                else if(rcret == getrcconfigint("rcblue", NULL))
414                {
415                        if(status.play == 1)
416                                playrcblue(filename, NULL, playinfobarstatus, playertype, flag);
417                        else
418                        {
419                                if(status.repeat == 0)
420                                {
421                                        changetext(b4, _("Repeat-On"));
422                                        drawscreen(apskin, 0, 0);
423                                        status.repeat = 1;
424                                }
425                                else
426                                {
427                                        status.repeat = 0;
428                                        changetext(b4, _("Repeat"));
429                                        drawscreen(apskin, 0, 0);
430                                }
431                        }
432                }
433                else if(rcret == getrcconfigint("rcyellow", NULL))
434                {
435                        if(status.play == 1)
436                                playrcyellow(filename, NULL, playinfobarstatus, playertype, flag);                                             
437                        else
438                                playerrandom(apskin, filelist, listbox, b3, playlist, flag);
439                }
440                else if(rcret == getrcconfigint("rcred", NULL))
441                {
442                        if(status.play == 1)
443                                playrcred(filename, NULL, playinfobarstatus, playertype, flag);
444                        else
445                        {
446                                if(playlist == 0)
447                                {
448                                        int sort = screendirsort();
449                                        debug(50, "rcred: tmpsort=%d", sort);
450
451                                        // fixt grey if sorting >10s
452                                        drawscreen(skin, 0, 0);
453       
454                                        addconfiginttmp("dirsort", sort);
455                                        mc_changeview(tmpview, filelist, apskin, flag);
456
457                                        delownerrc(apskin);     
458                                        getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->name);
459                                        addscreenrc(apskin, filelist);
460                                        drawscreen(apskin, 0, 0);
461                                }
462                        }
463                }
464                else if(rcret == getrcconfigint("rcgreen", NULL))
465                {
466                        if(status.play == 1)
467                                playrcgreen(filename, NULL, playinfobarstatus, playertype, flag);
468                        else
469                        {
470                                showplaylist(apskin, filelistpath, filelist, listbox, b2, 0, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
471                                drawscreen(apskin, 0, 0);
472                                continue;                       
473                        }
474                }
475                else if(rcret == getrcconfigint("rctext", NULL) || rcret == getrcconfigint("rcsubtitel", NULL))
476                {               
477                        if(status.play == 1)
478                                playrctext(filename, NULL, playinfobarstatus, playertype, flag);       
479                }
480                else if(rcret == getrcconfigint("rcmenu", NULL))
481                {
482                        if(status.play == 0 && status.pause == 0)
483                        {
484                                refresh = 1;
485                                debug(50, "rcmenu: settings");
486                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
487                                view = getconfigint("mc_vp_view", NULL);
488                                printf("view in: %d\n", view);
489                                printf("tmpview in: %d\n", tmpview);
490
491                                screenmc_videoplayer_settings();
492                                drawscreen(blackscreen, 0, 0);
493                                drawscreen(loadmediadb, 0, 0);                         
494                                if(view != getconfigint("mc_vp_view", NULL))
495                                {
496                                        printf("view changed > change tmpview\n");
497                                        tmpview = getconfigint("mc_vp_view", NULL);
498                                }
499
500                                if(getconfig("mc_vp_dirsort", NULL) != getconfig("dirsort", NULL))
501                                {
502                                        char* tmpstr = NULL;
503                                        tmpstr = ostrcat(getconfig("mc_vp_dirsort", NULL), NULL, 0, 0);
504                                        addconfigtmp("dirsort", tmpstr);
505                                        free(tmpstr), tmpstr = NULL;
506                                }
507
508                                printf("1view in: %d\n", view);
509                                printf("1tmpview in: %d\n", tmpview);
510                               
511                                mc_changeview(tmpview, filelist, apskin, flag);
512
513                                drawscreen(blackscreen, 0, 0);
514                                drawscreen(loadmediadb, 0, 0);
515                                printf("2view in: %d\n", view);
516                                printf("2tmpview in: %d\n", tmpview);
517       
518                                delownerrc(apskin);
519                                getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->name);
520                                addscreenrc(apskin, filelist);
521                                drawscreen(apskin, 0, 0);
522                        }
523                }
524                else if(rcret == getrcconfigint("rcinfo", NULL))
525                {
526                        if(status.play == 0 && status.pause == 0)
527                        {
528                                drawscreen(blackscreen, 0, 0);
529                                if(filelist->select != NULL && filelist->select->input == NULL)
530                                {
531                                        filename = createpath(filelistpath->text, filelist->select->name);
532                                        debug(133, "filename: %s", filename);                           
533                                        playrcred(filename, NULL, playinfobarstatus, playertype, flag);
534                                }
535                        }
536                        else
537                                playrcplay(filename, NULL, &playinfobarstatus, &playinfobarcount, playertype, flag);
538
539                        if(status.play == 0 && status.pause == 0)
540                        {
541                                drawscreen(skin, 0, 0);
542                                drawscreen(blackscreen, 0, 0);
543                                drawscreen(loadmediadb, 0, 0);
544                                delownerrc(apskin);
545                                getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->name);
546                                addscreenrc(apskin, filelist);
547                                drawscreen(apskin, 0, 0);
548                        }       
549                }
550                else if(rcret == getrcconfigint("rcstop", NULL) || (rcret == getrcconfigint("rcexit", NULL) && status.play == 1))
551                {
552                        debug(50, "rcstop: stopplayback");
553                        drawscreen(blackscreen, 0, 0);
554                        drawscreen(loadmediadb, 0, 0);
555                        if(status.play == 1 && playertype == 0)
556                        {
557                                char* tmpfilename = ostrcat(filename, NULL, 0, 0);
558                                char* fileseek = ostrcat("/mnt/swapextensions/player/", basename(tmpfilename), 0, 0);
559                                fileseek = ostrcat(fileseek, ".se", 0, 0);
560                                FILE* fbseek = fopen(fileseek, "w");
561                                if(fbseek != NULL)
562                                {
563                                        off64_t pos = playergetpts() / 90000;
564                                        fprintf(fbseek,"%lld", pos);
565                                        fclose(fbseek);
566                                }
567                                free(fileseek), fileseek = NULL;
568                                free(tmpfilename), tmpfilename = NULL;
569                        }
570                       
571                        servicestop(status.aktservice, 1, 1);
572                        playrcstop(playertype, flag);
573                        drawscreen(blackscreen, 0, 0);
574                        drawscreen(loadmediadb, 0, 0);
575                        sleep(2);
576                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
577
578                        // show skin
579                        setfbtransparent(255);
580
581                        apskin->hidden = NO;
582                        filelist->hidden = NO;
583                        listbox->hidden = YES;
584                        changetext(filelistpath, _(getconfig("mc_vp_path", NULL)));
585                        changetext(b2, _("Filelist-Mode"));
586
587                        // switch filelist
588                        delownerrc(apskin);
589                        addscreenrc(apskin, filelist);
590                        // show skin
591                        drawscreen(apskin, 0, 0);
592
593                        setfbtransparent(255);
594                        clearscreen(loadmediadb);
595                        clearscreen(blackscreen);
596
597                        playinfobarcount = 0;
598                        playinfobarstatus = 1;
599                        status.playspeed = 0;
600                        status.pause = 0;
601                        status.play = 0;
602                        playlist = 0;
603                        playinfobarcount = 0;
604                       
605                        if(playertype == 1)
606                                playerafterendts();
607                        else
608                                playerafterend();
609               
610                        writevfdmenu("VideoPlayer Filelist-Mode");
611                }
612                else if(rcret == getrcconfigint("rcexit", NULL))
613                {
614                        exit = 1;
615                        debug(50, "exit - save mc_vp_path: %s", filelistpath->text);
616                        debug(50, "exit - save mc_vp_selectedfile: %s", filelist->select->name);
617                        drawscreen(blackscreen, 0, 0);
618                        drawscreen(loadmediadb, 0, 0);
619
620                        if(playlist == 0)
621                        {
622                                if(filelistpath->text != NULL && ostrcmp(getconfig("mc_vp_path", NULL), filelistpath->text) != 0)
623                                        addconfig("mc_vp_path", filelistpath->text);
624                                if(filelist->select != NULL && filelist->select->name != NULL && ostrcmp(getconfig("mc_vp_selectedfile", NULL), filelist->select->name) != 0)
625                                        addconfig("mc_vp_selectedfile", filelist->select->name);
626                        }
627
628                        if(status.play == 1 && playertype == 0)
629                        {
630                                char* tmpfilename = ostrcat(filename, NULL, 0, 0);
631                                char* fileseek = ostrcat("/mnt/swapextensions/player/", basename(tmpfilename), 0, 0);
632                                fileseek = ostrcat(fileseek, ".se", 0, 0);
633                                FILE* fbseek = fopen(fileseek, "w");
634                                if(fbseek != NULL)
635                                {
636                                        off64_t pos = playergetpts() / 90000;
637                                        fprintf(fbseek,"%lld", pos);
638                                        fclose(fbseek);
639                                }
640                                free(fileseek), fileseek = NULL;
641                                free(tmpfilename), tmpfilename = NULL;
642                        }
643
644//                      setfbtransparent(0);
645                        servicestop(status.aktservice, 1, 1);
646                        playrcstop(playertype, flag);
647                        drawscreen(blackscreen, 0, 0);
648                        drawscreen(loadmediadb, 0, 0);
649                        sleep(2);
650                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
651
652                        // show skin
653                        setfbtransparent(255);
654                        apskin->hidden = NO;
655                        filelist->hidden = NO;
656                        listbox->hidden = YES;
657                        changetext(b2, _("Filelist-Mode"));
658                        changetext(b3, _("Random"));
659                        changetext(b4, _("Repeat"));                                                                           
660                        status.playspeed = 0;
661                        status.pause = 0;
662                        status.play = 0;
663                        status.random = 0;
664                        status.repeat = 0;
665                        playlist = 0;
666                        writevfdmenu("Mediacenter");
667                        playinfobarcount = 0;
668       
669                        printf("exit: view=%d tmpview=%d\n", view, tmpview);
670                        unlink("/tmp/.autoscan");
671                        break;
672                }
673                else if(rcret == getrcconfigint("rcok", NULL))
674                {
675                        if((status.play == 1) || (status.playspeed != 0))
676                        {
677                                playrcok(filename, NULL, playinfobarstatus, playertype, flag);
678                                continue;
679                        }
680
681                        playinfobarcount = 0;
682                        playinfobarstatus = 1;
683                        status.playspeed = 0;
684                        status.pause = 0;
685//                      status.play = 0;
686//                      playlist = 0;
687                        playinfobarcount = 0;
688
689                        if(playlist == 1 && listbox->select != NULL)
690                        {
691                                debug(50, "listbox->select->name: %s", listbox->select->name);
692                                filename = ostrcat("", listbox->select->name, 0, 0);
693
694                                if(getconfigint("playertype", NULL) == 1 && cmpfilenameext(filename, ".ts") == 0)
695                                        playertype = 1;
696                                else
697                                        playertype = 0;
698
699                                changetext(b2, _("Playlist-Mode"));
700                       
701                                debug(50, "screensaver title: %s", listbox->select->text);
702                                if(screensaver != NULL && screensaver->type == 0)
703                                        screensaver->value = listbox->select->text;
704
705                                debug(50, "playerstop");
706                                playrcstop(playertype, flag);
707//                              sleep(1);
708//                              drawscreen(infobar, 0, 0);
709
710                                debug(50, "playerstart: %s", filename);
711                                eof = 0;
712
713                                delownerrc(apskin);
714//                              setfbtransparent(255);
715//////////
716                                servicestop(status.aktservice, 1, 1);
717                                drawscreen(skin, 0, 0);
718//                              setfbtransparent(255);
719                                debug(50, "check");
720                                debug(50, "autostart_playlist: %d", getconfigint("mc_vp_autostart_playlist", NULL));
721                                debug(50, "status.play: %d", status.play);
722                                debug(50, "flag: %d", flag);
723///////////
724                                debug(50, "playertype: %d", playertype);
725                                if(playertype == 1)
726                                        playerret = playerstartts(filename, 0);
727                                else
728                                        playerret = playerstart(filename);
729
730                                playwritevfd(filename, NULL);
731
732                                #ifndef SIMULATE
733                                        if(playerret != 0)
734                                        {
735                                                writevfdmenu("VideoPlayer Filelist-Mode");
736                                                status.play = 0;
737                                                playlist = 0;
738                                                status.playspeed = 0;
739                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
740
741                                                changetext(filelistpath, _(getconfig("mc_vp_path", NULL)));
742                                                filelist->hidden = NO;
743                                                listbox->hidden = YES;
744
745                                                addscreenrc(apskin, filelist);
746                                                drawscreen(apskin, 0, 0);
747                                                continue;
748                                        }
749                                #endif
750
751                                screenplayinfobar(filename, NULL, 0, playertype, 0);                   
752                                status.play = 1;
753                               
754                                free(status.playfile); status.playfile = NULL;
755                                status.playfile = ostrcat(filename, "", 0, 0);
756                        }
757                        else if(filelist->select != NULL && filelist->select->input != NULL)
758                        {
759
760                                char* tmpfilename = ostrcat(filelistpath->text, NULL, 0, 0);                   
761
762                                // workaround dont open folder on rcchup
763                                if(skip == 1)
764                                {
765                                        drawscreen(apskin, 0, 0);
766                                        writerc(getrcconfigint("rcok", NULL));
767                                        skip = 0;
768                                }
769                                else if(!ostrncmp("video_ts", string_tolower(basename(tmpfilename)), 8))
770                                {
771                                        struct skin* dvdplayer = getplugin("DVD Player");
772                                        if(dvdplayer != NULL)
773                                        {
774                                                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)
775                                                {
776                                                        void (*startplugin)(char*, int);
777                                                        startplugin = dlsym(dvdplayer->pluginhandle, "screendvdplay");
778                                                        if(startplugin != NULL)
779                                                        {
780                                                                debug(50, "filelist->select->name: %s", filelist->select->name);
781                                                                filename = createpath(filelistpath->text, filelist->select->name);
782                                                                printf("start dvdplayer plugin\n");
783                                                                startplugin(filename,0);
784                                                        }
785                                                }
786                                                drawscreen(apskin, 0, 0);
787                                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
788                                        }
789                                        else
790                                        {
791                                                debug(50, "mc_mounter_chk start");
792                                                mc_mounter_chk(filelistpath);
793                                                debug(50, "mc_mounter_chk done");
794
795                                                char* checkautoscan = NULL;
796                                                checkautoscan = readfiletomem("/tmp/.autoscan", 0);
797       
798                                                if(filelistpath->text != NULL && ostrcmp(checkautoscan, filelistpath->text) != 0)
799                                                        unlink("/tmp/.autoscan");
800       
801                                                free(checkautoscan), checkautoscan = NULL;
802                                        }
803                                }
804                                free(tmpfilename), tmpfilename = NULL;
805                        }
806                        else if(filelist->select != NULL && filelist->select->input == NULL)
807                        {
808                                if(filelistpath->text != NULL && ostrcmp(getconfig("mc_vp_path", NULL), filelistpath->text) != 0)
809                                        addconfig("mc_vp_path", filelistpath->text);
810
811                                debug(50, "filelist->select->text: %s", filelist->select->text);
812                                filename = createpath(filelistpath->text, filelist->select->name);
813
814                                if(getconfigint("playertype", NULL) == 1 && cmpfilenameext(filename, ".ts") == 0)               
815                                        playertype = 1;
816                                else
817                                        playertype = 0;
818
819                                if(cmpfilenameext(filename, ".rar") == 0 || cmpfilenameext(filename, ".iso") == 0 || cmpfilenameext(filename, ".img") == 0)
820                                {
821                                        debug(50, "mc_mounter_main filename: %s", filename);
822                                        //addconfig("mc_vp_path", filelistpath->text);
823                                        currentdirectory = ostrcat("", getconfig("mc_vp_path", NULL), 0, 0);
824                                        selectedfile = ostrcat(selectedfile, getconfig("mc_vp_selectedfile", NULL), 0, 0);
825
826                                        mc_mounter_main(0,filename,filelistpath,filelist,apskin,filemask,tmpview,currentdirectory);
827                                        debug(50, "mc_mounter_main done");
828       
829                                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
830                                        continue;
831                                }
832                                else if(cmpfilenameext(filename, ".m3u") == 0 || cmpfilenameext(filename, ".pls") == 0)
833                                {
834                                        showplaylist(apskin, filelistpath, filelist, listbox, b2, 1, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
835
836                                        if(getconfigint("mc_vp_autostart_playlist", NULL) == 0)
837                                                drawscreen(apskin, 0, 0);
838                                        continue;
839
840                                }
841
842                                changetext(b2, _("Filelist-Mode"));
843                       
844                                if(screensaver != NULL && screensaver->type == 0)
845                                        screensaver->value = (void*)filelist->select->text;
846
847                                setfbtransparent(0);
848
849                                debug(50, "playerstop");
850                                playrcstop(playertype, flag);
851
852                                delownerrc(apskin);
853
854                                debug(50, "playerstart: %s", filename);
855                                eof = 0;
856
857                                servicestop(status.aktservice, 1, 1);
858                                drawscreen(skin, 0, 0);
859                                drawscreen(loadmediadb, 0, 0);
860                                setfbtransparent(255);
861       
862                                debug(50, "playertype: %d", playertype);
863                                if(playertype == 1)
864                                        playerret = playerstartts(filename, 0);
865                                else
866                                        playerret = playerstart(filename);
867
868                                playwritevfd(filename, NULL);
869
870                                #ifndef SIMULATE
871                                        if(playerret != 0)
872                                        {
873                                                writevfdmenu("VideoPlayer Filelist-Mode");
874                                                status.play = 0;
875                                                status.playspeed = 0;
876                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
877                                                addscreenrc(apskin, filelist);
878//                                              drawscreen(apskin, 0, 0);
879                                                continue;
880                                        }
881                                        else
882                                        {
883                                                if(playertype == 0 && getconfigint("showlastpos", NULL) == 1)
884                                                {
885                                                        char* tmpfilename = ostrcat(filename, NULL, 0, 0);
886                                                        char* fileseek = ostrcat("/mnt/swapextensions/player/", basename(tmpfilename), 0, 0);
887                                                        fileseek = ostrcat(fileseek, ".se", 0, 0);
888       
889                                                        FILE* fbseek = fopen(fileseek, "r");
890                                                        if(fbseek != NULL)
891                                                        {
892                                                                if(textbox(_("Message"), _("Start at last position ?"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 5, 0) == 1)
893                                                                {
894                                                                        char* skip1 = calloc(1, 20);
895                                                                        if(skip1 != NULL)
896                                                                        {
897                                                                                fscanf(fbseek,"%s",skip1);
898                                                                                playrcjumpf(filename, NULL, atoll(skip1), &playinfobarstatus, &playinfobarcount, playertype, flag);             
899                                                                        }
900                                                                        free(skip1), skip1 = NULL;
901                                                                }
902                                                                fclose(fbseek);
903                                                        }
904                                                        free(fileseek), fileseek = NULL;
905                                                        free(tmpfilename), tmpfilename = NULL;
906                                                }
907                                        }
908               
909                                #endif
910
911                                clearscreen(loadmediadb);
912                                screenplayinfobar(filename, NULL, 0, playertype, 0);
913                                status.play = 1;
914
915                                free(status.playfile); status.playfile = NULL;
916                                status.playfile = ostrcat(filename, "", 0, 0);
917
918                                if(status.mediadbfiles == 0 && getconfigint("mc_vp_autoscan", NULL) == 1 && !file_exist("/tmp/.autoscan"))
919                                {
920                                        if(filelistpath->text != NULL)
921                                        {
922                                                mediadbscan(filelistpath->text, 1000, 1);
923                                                writesys("/tmp/.autoscan", filelistpath->text, 0);
924                                                status.mediadbfiles = findfiles(filelistpath->text, 0, 1, 1, 1); //count only
925                                        }
926                                        else
927                                        {
928                                                mediadbscan(currentdirectory, 1000, 1);
929                                                writesys("/tmp/.autoscan", currentdirectory, 0);
930                                                status.mediadbfiles = findfiles(currentdirectory, 0, 1, 1, 1); //count only
931                                        }
932                                }
933                        }
934                }
935
936                if(eof >=1 || (playertype == 0 && playerisplaying() == 0) || (playertype == 1 && playerisplayingts() == 0))
937                {
938                        if(status.play == 1)
939                        {
940                                char* tmpfilename = ostrcat(filename, NULL, 0, 0);
941                                char* fileseek = ostrcat("/mnt/swapextensions/player/", basename(tmpfilename), 0, 0);
942                                fileseek = ostrcat(fileseek, ".se", 0, 0);
943                                unlink(fileseek);
944                       
945                                setfbtransparent(0);
946                                apskin->hidden = NO;
947                                drawscreen(skin, 0, 0);
948                                playereof(apskin, filelist, listbox, filelistpath, b2, NULL, NULL, NULL, &skip, &eof, &playlist, playertype, flag);
949                        }
950                }
951        }
952
953        deinitscreensaver();
954        status.hangtime = getconfigint("hangtime", NULL);
955        delconfigtmp("dirsort");
956        delconfigtmp("mediadbpath");
957        delconfigtmp("mediadbfile");
958        delconfigtmp("mediadbscandelall");
959        delconfigtmp("mediadbscandelnotfound");
960        delconfigtmp("mediadbscantimeout");
961       
962        delmarkedscreennodes(apskin, FILELISTDELMARK);
963        delownerrc(apskin);
964        clearscreen(apskin);
965
966        free(filename), filename = NULL;
967        free(currentdirectory), currentdirectory = NULL;
968        free(selectedfile), selectedfile = NULL;
969        free(lastid), lastid = NULL;
970
971        free(status.playfile); status.playfile = NULL;
972        if(tmppolicy != NULL)
973        {
974                setpolicy(tmppolicy);
975                free(tmppolicy);
976        }
977
978        if(playertype == 1)
979                playerafterendts();
980        else
981                playerafterend();
982
983
984        if(status.mediadbthread == NULL)
985        {
986                if(status.writemediadb == 1)
987                        writemediadb(getconfig("mediadbfile", NULL), NULL);
988                freemediadb(0);
989        }
990
991        clearscreen(blackscreen);
992        clearscreen(loadmediadb);
993
994        system("umount -a -f -t fuse.rarfs,iso9660,fuse.djmount,fuse.fusesmb,fuse.curlftpfs");
995
996        writevfdmenu("Mediacenter");
997        debug(50, "closed");
998}
999
1000
1001
1002#endif
1003
Note: See TracBrowser for help on using the repository browser.