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

Last change on this file since 15245 was 15245, checked in by obi, 11 years ago

[titan] update mc

File size: 17.7 KB
Line 
1#ifndef MC_VIDEOPLAYER_H
2#define MC_VIDEOPLAYER_H
3
4extern struct skin* skin;
5extern struct screensaver* screensaver;
6
7void screenmc_videoplayer()
8{
9        char* filename = NULL;
10        char* tmppolicy = NULL;
11        char* currentdirectory = NULL;
12        int rcret = 0, rcwait = 1000, playerret = 0, flag = 1, skip = 0, eof = 0, playinfobarcount = 0, playinfobarstatus = 1, tmpview = 0, playlist = 0, playertype = 0;
13        // workaround for grey background mvi
14        struct skin* blackscreen = getscreen("blackscreen");
15        drawscreen(blackscreen, 0);
16
17        // main screen
18        struct skin* apskin = getscreen("mc_videoplayer");
19        struct skin* filelistpath = getscreennode(apskin, "mc_filelistpath");
20        struct skin* filelist = getscreennode(apskin, "mc_filelist");
21        struct skin* listbox = getscreennode(apskin, "listbox");
22        struct skin* b2 = getscreennode(apskin, "b2");
23        struct skin* b3 = getscreennode(apskin, "b3");
24        struct skin* b4 = getscreennode(apskin, "b4");
25       
26        struct skin* skin_cover = getscreennode(apskin, "cover");
27//      skin_cover->hidden = YES;
28                       
29        currentdirectory = ostrcat(currentdirectory, getconfig("mc_videoplayerpath", NULL), 1, 0);
30
31        // enable listbox and set hidden
32        listbox->aktpage = -1;
33        listbox->aktline = 0;
34        listbox->hidden = YES;
35
36        // read configs
37        int style = getconfigint("style", NULL);
38        int view = getconfigint("view", NULL);
39        int skip13 = getconfigint("skip13", NULL);
40        int skip46 = getconfigint("skip46", NULL);
41        int skip79 = getconfigint("skip79", NULL);
42
43        // save policy
44        tmppolicy = getpolicy();
45       
46        // set allowed filemask
47        char* filemask = NULL;
48        if((status.expertmodus > 0) || (file_exist("/var/swap/etc/.mcfull")))
49                filemask = ostrcat("*.m3u *.pls *.ifo *.rar *.iso *.img *.avi *.dat *.divx *.flv *.mkv *.m4v *.mp4 *.mov *.mpg *.mpeg *.mts *.m2ts *.trp *.ts *.vdr *.vob *.wmv *.rm", NULL, 0, 0);
50        else
51                filemask = ostrcat("*.m3u *.pls *.avi *.mkv *.mpg *.mpeg *.ts", NULL, 0, 0);
52       
53        // disable global transparent/hangtime
54        setfbtransparent(255);
55        status.hangtime = 99999;
56        status.playspeed = 0, status.play = 0, status.pause = 0, status.random = 0;
57
58        debug(50, "start screenmc_videoplayer style=%d, view=%d", style, view);
59
60        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
61
62        if(getconfigint("screensaver", NULL) == 1)
63                initscreensaver();
64
65        tmpview = view;
66        mc_changeview(view, filelist);
67
68        getfilelist(apskin, filelistpath, filelist, currentdirectory, filemask, tmpview, NULL);
69        addscreenrc(apskin, filelist);
70
71        char* savecmd = NULL;
72                       
73        while(1)
74        {
75                rcret = waitrc(apskin, rcwait, 0);
76//              debug(50, "while status play=%d", status.play);
77
78                if((status.play == 1) || (status.playspeed != 0))
79                {
80                        playinfobarcount ++;
81                        if(playinfobarstatus > 0)
82                        {
83                                screenplayinfobar(filename, 0, playertype, 0);
84                        }
85                        if(playinfobarstatus == 1 && playinfobarcount >= getconfigint("infobartimeout", NULL))
86                        {
87                                playinfobarstatus = 0;
88                                screenplayinfobar(NULL, 1, playertype, 0);
89                        }
90                }
91                else if(status.filelistextend == 5 && filelist->select != NULL)
92                {
93                        char* cmd = NULL;
94                        cmd = ostrcat(cmd, filelist->select->filelist->imdbpath, 1, 0);
95                        cmd = ostrcat(cmd, ".jpg", 1, 0);                       
96                        changepic(skin_cover, cmd);
97                        drawscreen(apskin, 0);
98
99                        free(cmd), cmd = NULL;
100                        cmd = ostrcat(cmd, filelist->select->filelist->imdbpath, 1, 0);
101                        cmd = ostrcat(cmd, ".backdrop.mvi", 1, 0);
102
103                        if(!file_exist(cmd)){
104                                free(cmd), cmd = NULL;
105                                cmd = ostrcat(cmd, "/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 1, 0);
106                        }
107
108                        if(savecmd == NULL)
109                        {
110                                singlepicstart(cmd, 0);
111                                free(savecmd), savecmd = NULL;
112                                savecmd = ostrcat(savecmd, cmd, 1, 0);
113                        }
114                        else
115                        {
116                                if(ostrcmp(savecmd, cmd) != 0)
117                                {
118                                        singlepicstart(cmd, 0);
119                                        free(savecmd), savecmd = NULL;
120                                        savecmd = ostrcat(savecmd, cmd, 1, 0);
121                                }
122                        }
123                        free(cmd), cmd = NULL;
124                }
125               
126                if(rcret == getrcconfigint("rc1", NULL))
127                {
128                        if((status.play == 1) || (status.playspeed != 0))
129                                playrcjumpr(filename, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
130                }
131                else if(rcret == getrcconfigint("rc4", NULL))
132                {
133                        if((status.play == 1) || (status.playspeed != 0))
134                                playrcjumpr(filename, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
135                }
136                else if(rcret == getrcconfigint("rc7", NULL))
137                {
138                        if((status.play == 1) || (status.playspeed != 0))
139                                playrcjumpr(filename, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
140                }
141                else if(rcret == getrcconfigint("rc3", NULL))
142                {
143                        if((status.play == 1) || (status.playspeed != 0))
144                                playrcjumpf(filename, skip13, &playinfobarstatus, &playinfobarcount, playertype, flag);
145                }
146                else if(rcret == getrcconfigint("rc6", NULL))
147                {
148                        if((status.play == 1) || (status.playspeed != 0))
149                                playrcjumpf(filename, skip46, &playinfobarstatus, &playinfobarcount, playertype, flag);
150                }
151                else if(rcret == getrcconfigint("rc9", NULL))
152                {
153                        if((status.play == 1) || (status.playspeed != 0))
154                                playrcjumpf(filename, skip79, &playinfobarstatus, &playinfobarcount, playertype, flag);
155                }
156                else if(rcret == getrcconfigint("rcleft", NULL))
157                {
158                        if((status.play == 1) || (status.playspeed != 0))
159                                playrcjumpr(filename, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
160                }
161                else if(rcret == getrcconfigint("rcright", NULL))
162                {
163                        if((status.play == 1) || (status.playspeed != 0))
164                                playrcjumpf(filename, 60, &playinfobarstatus, &playinfobarcount, playertype, flag);
165                }
166                else if(rcret == getrcconfigint("rcdown", NULL))
167                {
168                        if((status.play == 1) || (status.playspeed != 0))
169                                playrcjumpr(filename, 600, &playinfobarstatus, &playinfobarcount, playertype, flag);
170                }
171                else if(rcret == getrcconfigint("rcup", NULL))
172                {
173                        if((status.play == 1) || (status.playspeed != 0))
174                                playrcjumpf(filename, 600, &playinfobarstatus, &playinfobarcount, playertype, flag);
175                }
176
177                else if(rcret == getrcconfigint("rcff", NULL))
178                {
179                        if((status.play == 1) || (status.playspeed != 0))
180                                playrcff(filename, &playinfobarstatus, &playinfobarcount, playertype, flag);
181                }       
182                else if(rcret == getrcconfigint("rcfr", NULL))
183                {
184                        if((status.play == 1) || (status.playspeed != 0))
185                                playrcfr(filename, &playinfobarstatus, &playinfobarcount, playertype, flag);
186                }
187                else if(rcret == getrcconfigint("rcplay", NULL))
188                {
189                        if((status.play == 1) || (status.playspeed != 0))
190                                playrcplay(filename, &playinfobarstatus, &playinfobarcount, playertype, flag);
191                }
192                else if(rcret == getrcconfigint("rcpause", NULL))
193                {
194                        if((status.play == 1) || (status.pause == 1))
195                                playrcpause(filename, &playinfobarstatus, &playinfobarcount, playertype, flag);
196                }
197                else if(rcret == getrcconfigint("rcnext", NULL))
198                {
199                        if(status.play == 1)
200                                eof = 1;
201                }
202                else if(rcret == getrcconfigint("rcprev", NULL))
203                {
204                        if(status.play == 1)
205                                eof = 2;
206                }
207                else if(rcret == getrcconfigint("rcblue", NULL))
208                {
209                        if(status.play == 1)
210                                playrcblue(filename, playinfobarstatus, playertype, flag);
211                        else
212                        {
213                                if(status.repeat == 0)
214                                {
215                                        changetext(b4, _("Repeat-On"));
216                                        drawscreen(apskin, 0);
217                                        status.repeat = 1;
218                                }
219                                else
220                                {
221                                        status.repeat = 0;
222                                        changetext(b4, _("Repeat"));
223                                        drawscreen(apskin, 0);
224                                }
225                        }
226                }
227
228                else if(rcret == getrcconfigint("rcyellow", NULL))
229                {
230                        if(status.play == 1)
231                                playrcyellow(filename, playinfobarstatus, playertype, flag);                                           
232                        else
233                                playerrandom(apskin, filelist, listbox, b3, playlist, flag);
234                }
235                else if(rcret == getrcconfigint("rcred", NULL))
236                {
237                        if(status.play == 1)
238                                playrcred(filename, playinfobarstatus, playertype, flag);
239                        else
240                        {
241                                if(playlist == 0)
242                                {
243                                        int sort = screenmc_sort();
244                                        debug(50, "rcred: tmpsort=%d", sort);
245
246                                        addconfiginttmp("dirsort", sort);
247//                                      mc_changeview(tmpview, filelist);
248                                        getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->text);
249                                }
250                        }
251                }
252                else if(rcret == getrcconfigint("rcgreen", NULL))
253                {
254                        if(status.play == 1)
255                                playrcgreen(filename, playinfobarstatus, playertype, flag);
256                        else
257                        {
258                                showplaylist(apskin, filelistpath, filelist, listbox, b2, 0, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
259                                drawscreen(apskin, 0);
260                                continue;                       
261                        }
262                }
263                else if(rcret == getrcconfigint("rctext", NULL) || rcret == getrcconfigint("rcsubtitel", NULL))
264                {               
265                        if(status.play == 1)
266                                playrctext(filename, playinfobarstatus, playertype, flag);     
267                }
268                else if(rcret == getrcconfigint("rcmenu", NULL))
269                {
270                        if(status.play == 0 && status.pause == 0)
271                        {
272                                debug(50, "rcmenu: settings");
273                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
274                                view = getconfigint("view", NULL);
275                                screenmc_videoplayer_settings();
276                               
277                                if(view != getconfigint("view", NULL))
278                                {
279                                        printf("view changed > change tmpview\n");
280                                        tmpview = getconfigint("view", NULL);
281                                }
282                               
283                                mc_changeview(tmpview, filelist);
284
285                                delownerrc(apskin);     
286                                getfilelist(apskin, filelistpath, filelist, filelistpath->text, filemask, tmpview, filelist->select->text);
287                                addscreenrc(apskin, filelist);
288
289                                drawscreen(apskin, 0);
290                        }
291                }
292                else if(rcret == getrcconfigint("rcinfo", NULL))
293                {
294                        printf("Title: %s\n", playergetinfo("Title"));
295                        printf("Artist: %s\n", playergetinfo("Artist"));
296                        printf("Album: %s\n", playergetinfo("Album"));
297                        printf("Year: %s\n", playergetinfo("Year"));
298                        printf("Genre: %s\n", playergetinfo("Genre"));
299                        printf("Comment: %s\n", playergetinfo("Comment"));
300                        printf("Track: %s\n", playergetinfo("Track"));
301                        printf("Copyright: %s\n", playergetinfo("Copyright"));
302                        printf("TestLibEplayer: %s\n", playergetinfo("TestLibEplayer"));
303                }
304                else if(rcret == getrcconfigint("rcstop", NULL))
305                {
306
307//                      if((status.play == 1) || (status.pause == 1))
308//                      {
309                                debug(50, "rcstop: stopplayback");
310                                playrcstop(playertype, flag);
311                                singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
312       
313                                apskin->hidden = NO;
314                                filelist->hidden = NO;
315                                listbox->hidden = YES;
316                                changetext(filelistpath, _(getconfig("mc_videoplayerpath", NULL)));
317                                changetext(b2, _("Filelist-Mode"));
318
319                                // switch filelist
320                                delownerrc(apskin);
321                                addscreenrc(apskin, filelist);
322                                // show skin
323                                setfbtransparent(255);
324                                drawscreen(apskin, 0);
325
326                                sleep(1);
327
328                                playinfobarcount = 0;
329                                playinfobarstatus = 1;
330                                status.playspeed = 0;
331                                status.pause = 0;
332                                status.play = 0;
333                                playlist = 0;
334                                playinfobarcount = 0;
335                               
336                                if(playertype == 1)
337                                        playerafterendts();
338                                else
339                                        playerafterend();
340                       
341                                writevfd("VideoPlayer Filelist-Mode");
342//                      }
343                }
344                else if(rcret == getrcconfigint("rcexit", NULL))
345                {
346                        debug(50, "exit - save mc_videoplayerpath: %s", filelistpath->text);
347                        if(playlist == 0)
348                        {
349                                if(ostrcmp(getconfig("mc_videoplayerpath", NULL), filelistpath->text) != 0)
350                                        addconfig("mc_videoplayerpath", filelistpath->text);
351                        }
352
353                        playrcstop(playertype, flag);
354                        // show skin
355                        setfbtransparent(255);
356                        sleep(1);
357                        apskin->hidden = NO;
358                        filelist->hidden = NO;
359                        listbox->hidden = YES;
360                        changetext(b2, _("Filelist-Mode"));
361                        changetext(b3, _("Random"));
362                        changetext(b4, _("Repeat"));                                                                           
363                        status.playspeed = 0;
364                        status.pause = 0;
365                        status.play = 0;
366                        status.random = 0;
367                        status.repeat = 0;
368                        playlist = 0;
369                        writevfd("Mediacenter");
370                        playinfobarcount = 0;
371        printf("exit: view=%d tmpview=%d\n", view, tmpview);                   
372                        status.filelistextend = 0;
373                        break;
374                }
375                else if(rcret == getrcconfigint("rcok", NULL))
376                {
377                        if((status.play == 1) || (status.playspeed != 0))
378                        {
379                                playrcok(filename, playinfobarstatus, playertype, flag);
380                                continue;
381                        }
382
383                        playinfobarcount = 0;
384                        playinfobarstatus = 1;
385                        status.playspeed = 0;
386                        status.pause = 0;
387//                      status.play = 0;
388//                      playlist = 0;
389                        playinfobarcount = 0;
390
391                        if(playlist == 1 && listbox->select != NULL)
392                        {
393                                debug(50, "listbox->select->name: %s", listbox->select->name);
394                                filename = ostrcat("", listbox->select->name, 0, 0);
395
396                                if(getconfigint("playertype", NULL) == 1 && (cmpfilenameext(filename, ".ts") == 0 || cmpfilenameext(filename, ".mts") == 0 || cmpfilenameext(filename, ".m2ts") == 0))
397                                        playertype = 1;
398                                else
399                                        playertype = 0;
400
401                                changetext(b2, _("Playlist-Mode"));
402                       
403                                debug(50, "screensaver title: %s", listbox->select->text);
404                                if(screensaver != NULL && screensaver->type == 0)
405                                        screensaver->value = listbox->select->text;
406
407                                debug(50, "playerstop");
408                                playrcstop(playertype, flag);
409//                              sleep(1);
410//                              drawscreen(infobar, 0);
411
412                                debug(50, "playerstart: %s", filename);
413                                eof = 0;
414
415                                delownerrc(apskin);
416                                setfbtransparent(255);
417//////////
418                                servicestop(status.aktservice, 1, 1);
419                                drawscreen(skin, 0);
420                                setfbtransparent(255);
421                                debug(50, "check");
422                                debug(50, "autostart_playlist: %d", getconfigint("vp_autostart_playlist", NULL));
423                                debug(50, "status.play: %d", status.play);
424                                debug(50, "flag: %d", flag);
425///////////
426                                debug(50, "playertype: %d", playertype);
427                                if(playertype == 1)
428                                        playerret = playerstartts(filename, 0);
429                                else
430                                        playerret = playerstart(filename);
431
432                                playwritevfd(filename);
433
434                                #ifndef SIMULATE
435                                        if(playerret != 0)
436                                        {
437                                                writevfd("VideoPlayer Filelist-Mode");
438                                                status.play = 0;
439                                                playlist = 0;
440                                                status.playspeed = 0;
441                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
442
443                                                changetext(filelistpath, _(getconfig("mc_videoplayerpath", NULL)));
444                                                filelist->hidden = NO;
445                                                listbox->hidden = YES;
446
447                                                addscreenrc(apskin, filelist);
448                                                drawscreen(apskin, 0);
449                                                continue;
450                                        }
451                                #endif
452
453                                screenplayinfobar(filename, 0, playertype, 0);                 
454                                status.play = 1;
455                               
456                                free(status.playfile); status.playfile = NULL;
457                                status.playfile = ostrcat(filename, "", 0, 0);
458                        }
459                        else if(filelist->select != NULL && filelist->select->input != NULL)
460                        {
461                                // workaround dont open folder on rcchup
462                                if(skip == 1)
463                                {
464                                        drawscreen(apskin, 0);
465                                        writerc(getrcconfigint("rcok", NULL));
466                                        skip = 0;
467                                }
468                                else
469                                {
470                                        debug(50, "mc_mounter_chk start");
471                                        mc_mounter_chk(filelistpath);
472                                        debug(50, "mc_mounter_chk done");
473                                }
474                        }
475                        else if(filelist->select != NULL && filelist->select->input == NULL)
476                        {
477                                if(ostrcmp(getconfig("mc_videoplayerpath", NULL), filelistpath->text) != 0)
478                                        addconfig("mc_videoplayerpath", filelistpath->text);
479
480                                debug(50, "filelist->select->text: %s", filelist->select->text);
481                                filename = createpath(filelistpath->text, filelist->select->name);
482                                printf("name: %s\n",filelist->select->name);
483                                printf("text: %s\n",filelist->select->text);
484
485
486                                if(getconfigint("playertype", NULL) == 1 && (cmpfilenameext(filename, ".ts") == 0 || cmpfilenameext(filename, ".mts") == 0 || cmpfilenameext(filename, ".m2ts") == 0))         
487                                        playertype = 1;
488                                else
489                                        playertype = 0;
490
491                                if(!strncmp(".rar",filename+strlen(filename)-4,4) || !strncmp(".iso",filename+strlen(filename)-4,4) || !strncmp(".img",filename+strlen(filename)-4,4))
492                                {
493                                        debug(50, "mc_mounter_main filename: %s", filename);
494                                        //addconfig("mc_videoplayerpath", filelistpath->text);
495                                        currentdirectory = ostrcat("", getconfig("mc_videoplayerpath", NULL), 0, 0);
496
497                                        mc_mounter_main(0,filename,filelistpath,filelist,apskin,filemask,tmpview,currentdirectory);
498                                        debug(50, "mc_mounter_main done");
499       
500                                        singlepicstart("/var/usr/local/share/titan/plugins/mc/skin/default.mvi", 0);
501                                        continue;
502                                }
503                                else if(!strncmp(".m3u",filename+strlen(filename)-4,4) || !strncmp(".pls",filename+strlen(filename)-4,4))
504                                {
505                                        showplaylist(apskin, filelistpath, filelist, listbox, b2, 1, &playlist, &eof, &filename, &currentdirectory, &playertype, flag);
506
507                                        if(getconfigint("vp_autostart_playlist", NULL) == 0)
508                                                drawscreen(apskin, 0);
509                                        continue;
510
511                                }
512
513                                changetext(b2, _("Filelist-Mode"));
514                       
515                                if(screensaver != NULL && screensaver->type == 0)
516                                        screensaver->value = (void*)filelist->select->text;
517
518                                debug(50, "playerstop");
519                                playrcstop(playertype, flag);
520//                              sleep(1);
521
522                                servicestop(status.aktservice, 1, 1);
523                                drawscreen(skin, 0);
524
525                                delownerrc(apskin);
526                                setfbtransparent(255);
527
528                                debug(50, "playerstart: %s", filename);
529                                eof = 0;
530
531                                debug(50, "playertype: %d", playertype);
532                                if(playertype == 1)
533                                        playerret = playerstartts(filename, 0);
534                                else
535                                        playerret = playerstart(filename);
536
537                                playwritevfd(filename);
538
539                                #ifndef SIMULATE
540                                        if(playerret != 0)
541                                        {
542                                                writevfd("VideoPlayer Filelist-Mode");
543                                                status.play = 0;
544                                                status.playspeed = 0;
545                                                textbox(_("Message"), _("Can't start playback !"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0);
546                                                addscreenrc(apskin, filelist);
547//                                              drawscreen(apskin, 0);
548                                                continue;
549                                        }
550                                #endif
551                                screenplayinfobar(filename, 0, playertype, 0);
552                                status.play = 1;
553
554                                free(status.playfile); status.playfile = NULL;
555                                status.playfile = ostrcat(filename, "", 0, 0);
556                        }
557                }
558
559                if(eof >=1 || (playertype == 0 && playerisplaying() == 0) || (playertype == 1 && playerisplayingts() == 0))
560                {
561                        if(status.play == 1)
562                        {
563                                setfbtransparent(0);
564                                apskin->hidden = NO;
565                                drawscreen(skin, 0);
566                                playereof(apskin, filelist, listbox, filelistpath, b2, NULL, NULL, NULL, &skip, &eof, &playlist, playertype, flag);
567                        }
568                }
569        }
570
571        deinitscreensaver();
572        status.hangtime = getconfigint("hangtime", NULL);
573        delconfigtmp("dirsort");
574
575        delmarkedscreennodes(apskin, FILELISTDELMARK);
576        delownerrc(apskin);
577        clearscreen(apskin);
578        if(style == 1)
579        {
580                delmarkedpic(1010);
581                delmarkedpic(1011);
582                delmarkedpic(1012);
583                delmarkedpic(1013);
584        }
585
586        free(filename), filename = NULL;
587        free(currentdirectory), currentdirectory = NULL;
588
589        free(status.playfile); status.playfile = NULL;
590        if(tmppolicy != NULL)
591        {
592                setpolicy(tmppolicy);
593                free(tmppolicy);
594        }
595
596        if(playertype == 1)
597                playerafterendts();
598        else
599                playerafterend();
600
601                       
602        writevfd("Mediacenter");
603        debug(50, "closed");
604}
605
606
607
608#endif
609
Note: See TracBrowser for help on using the repository browser.