2 Copyright 2004-2005 Chris Tallon, Andreas Vogel
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 Hints for the directory playing:
23 depending on the configValue directoryMode: none|audio|picture|count
24 it will be decided what to do if a directory is selected with [PLAY]:
25 none: as currently - simply go into
26 audio: start picture viewer and audio, audio on top
27 picture: start picture viewer and audio, picture on top
28 count: count occurence of both types, decide for audio/picture
29 Synchronization is done via the "directoryDone" call,
30 this is issued if the Viewer top engine has finished it's list
32 We will the go back one level and continue
33 Currently we will traverse to new directories only at the beginning
34 or the real end of each dir.
35 This is handled only by playAll (never by getMedia).
36 As we sort always in a way that all directories come first this should be OK.
37 there are 2 situations where we give the user a chance to interrupt (this is handled
38 by starting a 10ms timer and afterwrads sending a PLAYER_EVENT with the timer ref as
40 empty directory found - timer 1 - call directoryDone
41 after changing to a new directory the first entry is again a directory - timer 2 - playAll
43 directoryPlaying: globally set as long as we play a dir, reset on any key press here
44 startLevel: in DirList - set to the level where we started playing, if we are
45 back to this playing is finished
46 configuredDirmode: configured mode
58 #include "vmedialist.h"
60 #include "vmediaview.h"
61 #include "vvideomedia.h"
72 #include "mediaplayer.h"
74 #include "localmediafile.h"
75 #include "mediaoptions.h"
78 class MediaListHolder {
80 MediaListHolder(MediaList *l) {
89 Log::getInstance()->log("##MLH",Log::DEBUG,"ref %p now %d",_list,_ref);
93 Log::getInstance()->log("##MLH",Log::DEBUG,"unref %p now %d",_list,_ref);
94 if (_ref == 0) delete this;
97 if (_list) delete _list;
104 class MediaDirectory {
110 MediaListHolder *holder;
112 void setMediaType(ULONG n) {mtype=n;}
113 void setSortorder(int s) {
116 void setSelection(int s) {
122 bool move(ULONG mv) {
123 if (! holder) return false;
125 case VMediaList::MV_NEXT:
126 if (selection < ((int)holder->list()->size() -1)) {
131 case VMediaList::MV_PREV:
141 ULONG getMediaType(){return mtype;}
145 const MediaURI * getURI() {
148 const char * getDisplayName() {
149 if (! uri || ! uri->getDisplayName()) return "/";
150 return uri->getDisplayName();
152 //get the holder (increment refcount)
153 MediaListHolder *getHolder() {
154 if ( !holder) return NULL;
158 //assign a holder to the directory (auto ref)
159 void assignHolder(MediaListHolder *h) {
160 if (holder) holder->unref();
166 //constructor with copy!
167 MediaDirectory(const MediaURI *u) : selection(0),
168 sortorder(0),mtype(MEDIA_TYPE_ALL),holder(NULL){
174 MediaDirectory(MediaDirectory &c) {
175 setSelection(c.getSelection());
176 setMediaType(c.getMediaType());
177 setSortorder(c.getSortorder());
178 uri=new MediaURI(c.getURI());
179 holder=c.getHolder();
183 if (holder) holder->unref();
187 typedef std::vector<MediaDirectory*> MDirList;
197 list.push_back(new MediaDirectory(NULL));
199 DirList(DirList *cp) {
201 for (MDirList::iterator it=cp->list.begin();it<cp->list.end();it++) {
202 list.push_back(new MediaDirectory(*(*it)));
206 list.push_back(new MediaDirectory(NULL));
209 startlevel=cp->startlevel;
210 if (startlevel > current) startlevel=current;
213 MDirList::iterator it;
214 for (it=list.begin();it<list.end();it++) {
218 MediaDirectory *getCurrent() {
219 return list[current];
221 const MediaURI * getURI() {
222 return getCurrent()->getURI();
232 int append(const MediaURI *uri) {
233 if (! uri) return current;
234 MediaDirectory* md=new MediaDirectory(uri);
243 void setStartLevel() {
246 bool isOnStartLevel() {
247 return (startlevel == current);
253 class MediaSorterName
256 bool operator() (const Media* a, const Media* b)
258 if (b->getMediaType() == MEDIA_TYPE_DIR &&
259 a->getMediaType() != MEDIA_TYPE_DIR)
261 if ( b->getMediaType() != MEDIA_TYPE_DIR &&
262 a->getMediaType() == MEDIA_TYPE_DIR)
264 int c = strcmp(b->getFileName(), a->getFileName());
265 if (c > 0) return true;
270 //a sorter with a randomly initialized order
271 class MediaSorterRandom
274 MediaSorterRandom(int start) {
277 bool operator() (const Media* a, const Media* b)
279 if (b->getMediaType() == MEDIA_TYPE_DIR &&
280 a->getMediaType() != MEDIA_TYPE_DIR)
282 if ( b->getMediaType() != MEDIA_TYPE_DIR &&
283 a->getMediaType() == MEDIA_TYPE_DIR)
285 unsigned char suma=sum(a->getFileName(),(unsigned char)mystart);
286 unsigned char sumb=sum(b->getFileName(),(unsigned char)mystart);
287 if (sumb > suma) return true;
291 unsigned char sum(const char *name,unsigned char start) {
292 for (;*name!=0;name++) start=start ^ (unsigned char)*name;
299 struct MediaSorterTime
301 bool operator() (const Media* a, const Media* b)
303 if (b->getMediaType() == MEDIA_TYPE_DIR &&
304 a->getMediaType() != MEDIA_TYPE_DIR)
306 if ( b->getMediaType() != MEDIA_TYPE_DIR &&
307 a->getMediaType() == MEDIA_TYPE_DIR)
309 if (b->getTime()>a->getTime()) return true;
315 VMediaList::VMediaList()
317 boxstack = BoxStack::getInstance();
319 Log::getInstance()->log("VMediaList::VMediaList", Log::DEBUG, "start");
320 dirlist=new DirList();
322 Log::getInstance()->log("VMediaList::VMediaList", Log::DEBUG, "dirlist=%p,curren=%p",dirlist,dirlist->getCurrent());
323 dirlist->getCurrent()->setSortorder(SORT_NAME);
326 if (Video::getInstance()->getFormat() == Video::PAL)
332 setTitleBarColour(DrawStyle::TITLEBARBACKGROUND);
334 sl.setPosition(10, 30 + 5);
335 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
344 const char *dmstring=MediaOptions::getInstance()->getStringOption("DirectoryPlayMode");
346 if (strcmp(dmstring,"count") == 0) dirmode=M_COUNT;
347 else if (strcmp(dmstring,"audio") == 0) dirmode=M_AUDIO;
348 else if (strcmp(dmstring,"picture") == 0) dirmode=M_PICTURE;
351 //init additional providers
353 LocalMediaFile::init();
358 VMediaList::~VMediaList()
360 Log::getInstance()->log("VMediaList::~VMediaList", Log::DEBUG, "start");
361 Timers::getInstance()->cancelTimer(this,1);
362 Timers::getInstance()->cancelTimer(this,2);
365 if (audiodirlist) delete audiodirlist;
366 Log::getInstance()->log("VMediaList::~VMediaList", Log::DEBUG, "finished");
369 void VMediaList::removeViewer() {
371 BoxStack::getInstance()->remove(viewer);
376 VMediaView * VMediaList::getViewer() {
378 viewer=VMediaView::createViewer(this);
384 void VMediaList::playAudio(bool all,bool activate, bool showInfo) {
385 MediaListHolder *h=dirlist->getCurrent()->getHolder();
387 VMediaView *player=getViewer();
388 //OK make a copy of the current active list for audio playing
389 if (audiodirlist) delete audiodirlist;
390 audiodirlist=new DirList(dirlist);
391 player->play(all,activate,MV_NONE,showInfo);
395 void VMediaList::updateAll() {
396 BoxStack::getInstance()->update(this);
397 if (viewer) BoxStack::getInstance()->update(viewer);
398 BoxStack::getInstance()->update(NULL);
404 int VMediaList::getNumEntries(ULONG mediaType,int lowerThen,bool noAudioList) {
405 MediaListHolder *h=dirlist->getCurrent()->getHolder();
406 Log::getInstance()->log("VMediaList",Log::DEBUG,"getNumEntries type=%lu,lt=%d,na=%d,h=%p,l=%p",
407 mediaType,lowerThen,(int)noAudioList,h,(h?h->list():0));
409 if (mediaType == MEDIA_TYPE_ALL && lowerThen < 0) {
411 return h->list()->size();
413 if (lowerThen < 0) lowerThen=h->list()->size();
415 MediaList *ml=h->list();
417 if (mediaType == MEDIA_TYPE_AUDIO) {
418 //OK we look into the separate audiolist (if we have it...)
419 if (audiodirlist && ! noAudioList) {
420 MediaListHolder *ah=audiodirlist->getCurrent()->getHolder();
427 for (int i=0;i<(int)(ml->size()) && i <= lowerThen;i++) {
428 if ((*ml)[i]->getMediaType() & mediaType) rt++;
433 void VMediaList::setList(MediaListHolder* tlist)
435 dirlist->getCurrent()->assignHolder(tlist);
437 sortList(dirlist->getCurrent()->getSortorder());
438 updateSelectList(dirlist->getCurrent()->getSelection());
442 void VMediaList::updateSelectList(){
443 updateSelectList(-1);
445 void VMediaList::updateSelectList(int currentNumber){
446 MediaListHolder *h=dirlist->getCurrent()->getHolder();
448 char tempA[Media::TIMEBUFLEN];
449 Log::getInstance()->log("VMediaList::updateSelectList", Log::DEBUG, "media=%p",h);
452 ULONG currentSelection=0;
453 if (sl.getNumOptions() >= 1 && currentNumber < 0) {
454 currentSelection=sl.getCurrentOptionData();
462 for (UINT i = 0; i < h->list()->size(); i++)
464 media = (*h->list())[i];
465 if (media->getMediaType() == MEDIA_TYPE_DIR) {
466 sprintf(str, "%04u %s [%s]", i,media->getTimeString(tempA), media->getDisplayName());
467 //Log::getInstance()->log("VMediaList", Log::DEBUG, "add to select list %s",str);
468 media->index = sl.addOption(str, (ULONG)media, first);
471 sprintf(str, "%04u %s %s", i,media->getTimeString(tempA), media->getDisplayName());
472 //Log::getInstance()->log("VMediaList", Log::DEBUG, "add to select list %s",str);
473 media->index = sl.addOption(str, (ULONG)media, first);
478 if (currentNumber >= 0) sl.hintSetCurrent(currentNumber);
479 else sl.hintSetCurrent(0);
480 if (currentSelection != 0) {
482 //position to the previous selection
483 for (int i=0;i<sl.getNumOptions();i++) {
484 sl.hintSetCurrent(i);
485 if (sl.getCurrentOptionData() == currentSelection) {
490 if (! found) sl.hintSetCurrent(0);
493 if (sl.getNumOptions() > 0)
500 void VMediaList::draw()
502 Log::getInstance()->log("VMediaList::draw", Log::DEBUG, "namestr=%s",dirlist->getCurrent()->getDisplayName());
504 SNPRINTF(title, 398, tr("Media - %s"), dirlist->getCurrent()->getDisplayName());
510 sl.setVisible(false);
512 drawText(tr("Loading..."), 240, 180, DrawStyle::LIGHTTEXT);
516 //if (sl.getNumOptions() > 0) sl.draw();
520 // Put the status stuff at the bottom
525 w.nextSymbol = WSymbol::UP;
526 w.setPosition(20, 385);
529 w.nextSymbol = WSymbol::DOWN;
530 w.setPosition(50, 385);
533 w.nextSymbol = WSymbol::SKIPBACK;
534 w.setPosition(85, 385);
537 w.nextSymbol = WSymbol::SKIPFORWARD;
538 w.setPosition(115, 385);
541 w.nextSymbol = WSymbol::PLAY;
542 w.setPosition(150, 385);
549 void VMediaList::doShowingBar()
551 int topOption = sl.getTopOption() + 1;
552 if (sl.getNumOptions() == 0) topOption = 0;
555 const char* strmode=NULL;
567 SNPRINTF(showing, 250,tr("%i to %i of %i"),
568 topOption, sl.getBottomOption(), sl.getNumOptions());
571 // b.setSurfaceOffset(220, 385);
572 // b.setDimensions(160, 25);
573 // b.fillColour(DrawStyle::VIEWBACKGROUND);
574 // b.drawText(showing, 0, 0, DrawStyle::LIGHTTEXT);
576 rectangle(200, 384, 18, 16, DrawStyle::VIDEOBLUE);
577 rectangle(220, 385, 220+160, 385+25, DrawStyle::VIEWBACKGROUND);
578 drawText(strmode, 220, 385, DrawStyle::LIGHTTEXT);
579 drawText(showing, 280, 385, DrawStyle::LIGHTTEXT);
580 if (sl.getCurrentOptionData() != 0) Log::getInstance()->log("VMediaList",Log::DEBUG,"selected %s",((Media *)sl.getCurrentOptionData())->getDisplayName());
583 //find the next entry in the media list
584 //return the index in the list (starting with 0)
585 //return -1 if none found
586 int VMediaList::findNextEntry(int current, MediaList *list,ULONG ltype, ULONG move,bool wrap) {
587 if (! list) return -1;
588 if (current < 0) current=0;
589 if (current >= (int)list->size()) current=list->size()-1;
613 if (next >= (int)list->size()) {
621 if (next == current && move != MV_NONE) {
624 if (((*list)[next])->getMediaType() != ltype) {
638 Media * VMediaList::getMedia(ULONG ltype,ULONG move) {
640 MediaList *list=NULL;
641 MediaListHolder *h=NULL;
642 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia, t=%lu, mv=%lu",ltype,move);
644 //the currently active one (dirlist->getCurrent()->getHolder())
645 //and potentially a second one for audio (audiolist)
646 //currently (no recursive playing) we should always have an attached medialist in the audiolist
647 if (ltype == MEDIA_TYPE_AUDIO && audiodirlist != NULL ) {
648 h=audiodirlist->getCurrent()->getHolder();
650 Log::getInstance()->log("VMediaList",Log::ERR,"getMedia AUDIO empty medialist");
653 int nentry=findNextEntry(audiodirlist->getCurrent()->getSelection(),h->list(),ltype,move,false);
655 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia AUDIO no next entry");
659 audiodirlist->getCurrent()->setSelection(nentry);
661 rt=new Media((*list)[nentry]);
663 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia AUDIO next entry %d",nentry);
666 h=dirlist->getCurrent()->getHolder();
668 Log::getInstance()->log("VMediaList",Log::ERR,"getMedia PICTURE empty medialist");
671 int nentry=findNextEntry(dirlist->getCurrent()->getSelection(),h->list(),ltype,move,false);
673 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia type=%lu no next entry",ltype);
677 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia type=%lu next entry %d",ltype,nentry);
678 dirlist->getCurrent()->setSelection(nentry);
679 updateSelection(true);
682 rt=new Media((*list)[nentry]);
684 if (! rt->getURI()) {
685 MediaURI *uri=list->getURI(rt);
692 void VMediaList::updateSelection(bool toSelectList) {
694 dirlist->getCurrent()->setSelection(sl.getCurrentOption());
696 sl.hintSetCurrent(dirlist->getCurrent()->getSelection());
701 Media * VMediaList::getCurrentMedia(DirList *dl) {
702 if (! dl) return NULL;
703 MediaDirectory *d=dirlist->getCurrent();
704 if (! d) return NULL;
705 MediaListHolder *h=d->getHolder();
706 if (! h) return NULL;
707 if (d->getSelection() < 0 || d->getSelection() >= (int)h->list()->size()) return NULL;
708 Media *rt= (*h->list())[d->getSelection()];
714 int VMediaList::handleCommand(int command)
721 sl.hintSetCurrent(0);
725 boxstack->update(this);
736 boxstack->update(this);
739 case Remote::DF_DOWN:
747 boxstack->update(this);
750 case Remote::SKIPBACK:
757 boxstack->update(this);
760 case Remote::SKIPFORWARD:
767 boxstack->update(this);
775 boxstack->update(this);
778 sortList(SORT_RANDOM);
779 boxstack->update(this);
783 boxstack->update(this);
791 if (dirlist) media = getCurrentMedia(dirlist);
792 if (media == NULL) return 2;
793 Log::getInstance()->log("VMediaList", Log::DEBUG, "activated %lu", media->index);
794 switch(media->getMediaType())
799 Log::getInstance()->log("VMediaList", Log::DEBUG, "create child for %s",media->getFileName());
800 if (media->getFileName() == NULL ) return 2;
801 if (command == Remote::PLAY) {
802 dirlist->setStartLevel();
805 bool rt=changeDirectory(media);
806 if (command == Remote::PLAY && rt) {
814 case MEDIA_TYPE_AUDIO:
815 Log::getInstance()->log("VMediaList", Log::DEBUG, "play audio file %s",
816 media->getFileName());
817 if (dirmode != M_NONE && command == Remote::PLAY)
820 playAudio(command==Remote::PLAY,true,true);
822 case MEDIA_TYPE_VIDEO: {
823 #ifndef WIN32 //Only DVB style MPEG is supported by the Windows Part!
824 Log::getInstance()->log("VMediaList", Log::DEBUG, "play video file %s",
825 media->getFileName());
827 if (! media->getURI()) {
829 MediaListHolder *h=dirlist->getCurrent()->getHolder();
831 Log::getInstance()->log("VMediaList", Log::ERR, "no media List");
834 MediaURI *u=h->list()->getURI(media);
840 VVideoMedia *v=new VVideoMedia(media,this);
841 BoxStack::getInstance()->add(v);
842 BoxStack::getInstance()->update(v);
847 case MEDIA_TYPE_PICTURE:
848 Log::getInstance()->log("VMediaList", Log::DEBUG, "show picture file %s",
849 media->getFileName());
850 if (dirmode != M_NONE && command == Remote::PLAY)
853 getViewer()->showPicture(MV_NONE,command==Remote::PLAY,true);
856 Log::getInstance()->log("VMediaList", Log::DEBUG, "unknown media type %d file %s",
857 media->getMediaType(),media->getFileName());
861 VVideoLive* v = new VVideoLive(dirlist->getCurrent()->getHolder(), media->type, this);
867 v->medianelChange(VVideoLive::NUMBER, media->number);
874 if (dirlist->getLevel() < 1) return 4;
879 // stop command getting to any more views
883 //go to the next level dir
884 //if OK - delete current medialist
885 bool VMediaList::changeDirectory(Media *media) {
886 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd to %s",media->getFileName());
888 dirlist->getCurrent()->setSortorder(sortOrder);
889 if (dirlist->getLevel() > 200) {
890 Log::getInstance()->log("VMediaList",Log::ERR,"above 300 levels, stop here...");
893 MediaListHolder *h=dirlist->getCurrent()->getHolder();
894 dirlist->getCurrent()->assignHolder(NULL); //prepare old holder for deletion
898 MediaURI *uri=h->list()->getURI(media);
899 dirlist->append(uri);
901 //same sort order for next level
902 dirlist->getCurrent()->setSortorder(sortOrder);
905 h->unref(); //this deletes now the old list
906 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd OK");
909 //we were no able to load the new list - so go back to our current list
911 dirlist->getCurrent()->assignHolder(h); //OK so we saved our list...
913 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd failed");
917 void VMediaList::directoryDone() {
918 if (! playingAll) return;
919 //go up until we are on the startlevel
920 Log::getInstance()->log("VMediaList", Log::DEBUG, "DirectoryDone ");
921 while ( ! dirlist->isOnStartLevel()) {
924 if (dirlist->isOnStartLevel()) break;
925 if (dirlist->getCurrent()->move(MV_NEXT))
928 if ( dirlist->isOnStartLevel()) {
931 Log::getInstance()->log("VMediaList", Log::DEBUG, "finished playing all l=%lu",dirlist->getLevel());
934 updateSelection(true);
938 bool VMediaList::playAll() {
939 if (dirmode == M_NONE) return false;
943 dirlist->setStartLevel();
947 Media *media=getCurrentMedia(dirlist);
950 Log::getInstance()->log("VMediaList", Log::DEBUG, "empty dir when calling playall");
952 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
955 Media *mcopy=new Media(media);
956 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all name=%s,t=%lu, started=%d",
957 mcopy->getDisplayName(),mcopy->getMediaType(),(int)started);
958 while (mcopy->getMediaType()==MEDIA_TYPE_DIR) {
959 //recurse to the next directory
960 bool rt=changeDirectory(mcopy);
962 //OK succesfully changed dir
963 int entries=getNumEntries(MEDIA_TYPE_AUDIO|MEDIA_TYPE_DIR|MEDIA_TYPE_PICTURE);
964 Log::getInstance()->log("VMediaList", Log::DEBUG, "cd OK, entries=%d",entries);
965 media=getCurrentMedia(dirlist);
966 if (entries==0 || media == NULL) {
967 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all name=%s empty",mcopy->getDisplayName());
969 //trigger directory end with the ability of user intervention
970 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
975 if (media->getMediaType()==MEDIA_TYPE_DIR) {
976 //send a defered event to give the user a chance to interrupt
977 //will again call playAll (but this does not chage the start level)
978 Timers::getInstance()->setTimerD(this,2,0,10000000l); //10ms
985 //unable to change to the directory
986 if (dirlist->getCurrent()->move(MV_NEXT)) {
987 //OK there is still a next medium here
988 updateSelection(true);
989 media=getCurrentMedia(dirlist);
991 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
995 mcopy=new Media(media);
998 //hmm - no entries here any more
1005 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all on level %d, sele=%d",
1006 dirlist->getLevel(),dirlist->getCurrent()->getSelection());
1008 enum Dirmode currentMode=dirmode;
1009 //OK now we handled all directories - now deal with the current one
1010 //1st determine the number of entries
1011 int aentries=getNumEntries(MEDIA_TYPE_AUDIO,-1,true);
1012 int pentries=getNumEntries(MEDIA_TYPE_PICTURE,-1,true);
1013 if (aentries == 0 && pentries == 0) {
1017 if (currentMode == M_COUNT) {
1018 if (aentries > pentries) currentMode=M_AUDIO;
1019 else currentMode=M_PICTURE;
1021 Log::getInstance()->log("VMediaList", Log::DEBUG, "mode=%d,ae=%d,pe=%d",currentMode,aentries,pentries);
1022 //now find the matching entries and start playing
1023 MediaListHolder *h=dirlist->getCurrent()->getHolder();
1025 Log::getInstance()->log("VMediaList", Log::ERR, "playing all empty medialist");
1030 Media *mpicture=NULL;
1031 int audioselection=-1;
1032 int pictureselection=-1;
1033 for (int i=dirlist->getCurrent()->getSelection();i<(int)h->list()->size();i++) {
1034 Media *m=(*h->list())[i];
1035 if (m->getMediaType() == MEDIA_TYPE_AUDIO && maudio == NULL) {
1039 if (m->getMediaType() == MEDIA_TYPE_PICTURE && mpicture == NULL) {
1043 if (maudio != NULL && mpicture != NULL) break;
1045 //OK now we found the first media for both - start players
1046 if (maudio != NULL) {
1047 dirlist->getCurrent()->setSelection(audioselection);
1048 playAudio(true,currentMode==M_AUDIO,mpicture==NULL); //this makes now a copy of dirlist...
1050 if (mpicture != NULL) {
1051 dirlist->getCurrent()->setSelection(pictureselection);
1052 getViewer()->showPicture(MV_NONE,true,currentMode==M_PICTURE);
1055 updateSelection(true);
1066 void VMediaList::processMessage(Message* m)
1068 if (m->message == Message::MOUSE_MOVE)
1070 if (sl.mouseMove((m->parameter.num>>16)-getScreenX(),(m->parameter.num&0xFFFF)-getScreenY()))
1074 boxstack->update(this);
1078 else if (m->message == Message::MOUSE_LBDOWN)
1080 if (sl.mouseLBDOWN((m->parameter.num>>16)-getScreenX(),(m->parameter.num&0xFFFF)-getScreenY()))
1083 boxstack->handleCommand(Remote::OK); //simulate OK press
1086 { //check if press is outside this view! then simulate cancel
1087 int x=(m->parameter.num>>16)-getScreenX();
1088 int y=(m->parameter.num&0xFFFF)-getScreenY();
1089 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
1091 boxstack->handleCommand(Remote::BACK); //simulate cancel press
1095 else if (m->message == Message::PLAYER_EVENT) {
1096 switch (m->parameter.num) {
1107 int VMediaList::createList() {
1108 Log::getInstance()->log("VMediaList::createList", Log::DEBUG, "");
1109 VMediaList *vmn=new VMediaList();
1110 //show the "loading" indicator
1111 BoxStack::getInstance()->add(vmn);
1114 BoxStack::getInstance()->remove(vmn);
1119 void VMediaList::sortList(int newSort) {
1120 MediaListHolder *h=dirlist->getCurrent()->getHolder();
1122 Log::getInstance()->log("VMediaList::sortList", Log::DEBUG, "p=%p,sort=%d,osort=%d, size=%d",this,newSort,sortOrder,h->list()->size());
1123 if (sortOrder == newSort) return;
1124 if (h->list()->begin() != h->list()->end()) {
1127 ::sort(h->list()->begin(),h->list()->end(),MediaSorterTime());
1130 ::sort(h->list()->begin(),h->list()->end(),MediaSorterName());
1133 ::sort(h->list()->begin(),h->list()->end(),MediaSorterRandom(time(NULL)));
1140 Log::getInstance()->log("VMediaList::sortList", Log::DEBUG, "done ");
1144 int VMediaList::load() {
1148 boxstack->update(this);
1149 MediaPlayer * mp=MediaPlayer::getInstance();
1150 Log::getInstance()->log("VMediaList::load", Log::DEBUG, "load list for %p",dirlist->getURI());
1151 MediaDirectory *md=dirlist->getCurrent();
1154 mn=mp->getMediaList(md->getURI());
1157 mn=mp->getRootList();
1160 MediaListHolder *h=new MediaListHolder(mn);
1165 boxstack->update(this);
1169 Log::getInstance()->log("VMediaList", Log::ERR, "unable to get MediaList for %p",dirlist->getURI());
1171 VInfo* vi = new VInfo();
1172 vi->setSize(400, 150);
1176 vi->setTitleBarOn(0);
1178 if (Video::getInstance()->getFormat() == Video::PAL)
1179 vi->setPosition(170, 200);
1181 vi->setPosition(160, 150);
1182 vi->setOneLiner(tr("unable to get media list"));
1185 Message* m = new Message();
1186 m->message = Message::ADD_VIEW;
1188 m->parameter.num = (ULONG)vi;
1189 Command::getInstance()->postMessageNoLock(m);
1194 const char * VMediaList::getDirname(ULONG mtype) const {
1195 if (mtype == MEDIA_TYPE_AUDIO && audiodirlist) {
1196 return audiodirlist->getCurrent()->getDisplayName();
1198 return dirlist->getCurrent()->getDisplayName();
1201 void VMediaList::timercall(int ref) {
1202 if (ref == 1 || ref == 2 ) {
1203 //send a directory done event
1204 Message* m = new Message();
1205 m->message = Message::PLAYER_EVENT;
1207 m->parameter.num = ref;
1208 Command::getInstance()->postMessageFromOuterSpace(m);