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"
79 class MediaListHolder {
81 MediaListHolder(MediaList *l) {
90 Log::getInstance()->log("##MLH",Log::DEBUG,"ref %p now %d",_list,_ref);
94 Log::getInstance()->log("##MLH",Log::DEBUG,"unref %p now %d",_list,_ref);
95 if (_ref == 0) delete this;
98 if (_list) delete _list;
105 class MediaDirectory {
111 MediaListHolder *holder;
113 void setMediaType(ULONG n) {mtype=n;}
114 void setSortorder(int s) {
117 void setSelection(int s) {
123 bool move(ULONG mv) {
124 if (! holder) return false;
126 case VMediaList::MV_NEXT:
127 if (selection < ((int)holder->list()->size() -1)) {
132 case VMediaList::MV_PREV:
142 ULONG getMediaType(){return mtype;}
146 const MediaURI * getURI() {
149 const char * getDisplayName() {
150 if (! uri || ! uri->getDisplayName()) return "/";
151 return uri->getDisplayName();
153 //get the holder (increment refcount)
154 MediaListHolder *getHolder() {
155 if ( !holder) return NULL;
159 //assign a holder to the directory (auto ref)
160 void assignHolder(MediaListHolder *h) {
161 if (holder) holder->unref();
167 //constructor with copy!
168 MediaDirectory(const MediaURI *u) : selection(0),
169 sortorder(0),mtype(MEDIA_TYPE_ALL),holder(NULL){
175 MediaDirectory(MediaDirectory &c) {
176 setSelection(c.getSelection());
177 setMediaType(c.getMediaType());
178 setSortorder(c.getSortorder());
179 uri=new MediaURI(c.getURI());
180 holder=c.getHolder();
184 if (holder) holder->unref();
188 typedef vector<MediaDirectory*> MDirList;
198 list.push_back(new MediaDirectory(NULL));
200 DirList(DirList *cp) {
202 for (MDirList::iterator it=cp->list.begin();it<cp->list.end();it++) {
203 list.push_back(new MediaDirectory(*(*it)));
207 list.push_back(new MediaDirectory(NULL));
210 startlevel=cp->startlevel;
211 if (startlevel > current) startlevel=current;
214 MDirList::iterator it;
215 for (it=list.begin();it<list.end();it++) {
219 MediaDirectory *getCurrent() {
220 return list[current];
222 const MediaURI * getURI() {
223 return getCurrent()->getURI();
233 int append(const MediaURI *uri) {
234 if (! uri) return current;
235 MediaDirectory* md=new MediaDirectory(uri);
244 void setStartLevel() {
247 bool isOnStartLevel() {
248 return (startlevel == current);
254 class MediaSorterName
257 bool operator() (const Media* a, const Media* b)
259 if (b->getMediaType() == MEDIA_TYPE_DIR &&
260 a->getMediaType() != MEDIA_TYPE_DIR)
262 if ( b->getMediaType() != MEDIA_TYPE_DIR &&
263 a->getMediaType() == MEDIA_TYPE_DIR)
265 int c = strcmp(b->getFileName(), a->getFileName());
266 if (c > 0) return true;
271 //a sorter with a randomly initialized order
272 class MediaSorterRandom
275 MediaSorterRandom(int start) {
278 bool operator() (const Media* a, const Media* b)
280 if (b->getMediaType() == MEDIA_TYPE_DIR &&
281 a->getMediaType() != MEDIA_TYPE_DIR)
283 if ( b->getMediaType() != MEDIA_TYPE_DIR &&
284 a->getMediaType() == MEDIA_TYPE_DIR)
286 unsigned char suma=sum(a->getFileName(),(unsigned char)mystart);
287 unsigned char sumb=sum(b->getFileName(),(unsigned char)mystart);
288 if (sumb > suma) return true;
292 unsigned char sum(const char *name,unsigned char start) {
293 for (;*name!=0;name++) start=start ^ (unsigned char)*name;
300 struct MediaSorterTime
302 bool operator() (const Media* a, const Media* b)
304 if (b->getMediaType() == MEDIA_TYPE_DIR &&
305 a->getMediaType() != MEDIA_TYPE_DIR)
307 if ( b->getMediaType() != MEDIA_TYPE_DIR &&
308 a->getMediaType() == MEDIA_TYPE_DIR)
310 if (b->getTime()>a->getTime()) return true;
316 VMediaList::VMediaList()
318 boxstack = BoxStack::getInstance();
320 Log::getInstance()->log("VMediaList::VMediaList", Log::DEBUG, "start");
321 dirlist=new DirList();
323 Log::getInstance()->log("VMediaList::VMediaList", Log::DEBUG, "dirlist=%p,curren=%p",dirlist,dirlist->getCurrent());
324 dirlist->getCurrent()->setSortorder(SORT_NAME);
327 if (Video::getInstance()->getFormat() == Video::PAL)
333 setTitleBarColour(Colour::TITLEBARBACKGROUND);
335 sl.setPosition(10, 30 + 5);
336 sl.setSize(area.w - 20, area.h - 30 - 15 - 30);
345 const char *dmstring=MediaOptions::getInstance()->getStringOption("DirectoryPlayMode");
347 if (strcmp(dmstring,"count") == 0) dirmode=M_COUNT;
348 else if (strcmp(dmstring,"audio") == 0) dirmode=M_AUDIO;
349 else if (strcmp(dmstring,"picture") == 0) dirmode=M_PICTURE;
352 //init additional providers
353 LocalMediaFile::init();
357 VMediaList::~VMediaList()
359 Log::getInstance()->log("VMediaList::~VMediaList", Log::DEBUG, "start");
360 Timers::getInstance()->cancelTimer(this,1);
361 Timers::getInstance()->cancelTimer(this,2);
364 if (audiodirlist) delete audiodirlist;
365 Log::getInstance()->log("VMediaList::~VMediaList", Log::DEBUG, "finished");
368 void VMediaList::removeViewer() {
370 BoxStack::getInstance()->remove(viewer);
375 VMediaView * VMediaList::getViewer() {
377 viewer=VMediaView::createViewer(this);
383 void VMediaList::playAudio(bool all,bool activate, bool showInfo) {
384 MediaListHolder *h=dirlist->getCurrent()->getHolder();
386 VMediaView *player=getViewer();
387 //OK make a copy of the current active list for audio playing
388 if (audiodirlist) delete audiodirlist;
389 audiodirlist=new DirList(dirlist);
390 player->play(all,activate,MV_NONE,showInfo);
394 void VMediaList::updateAll() {
395 BoxStack::getInstance()->update(this);
396 if (viewer) BoxStack::getInstance()->update(viewer);
397 BoxStack::getInstance()->update(NULL);
403 int VMediaList::getNumEntries(ULONG mediaType,int lowerThen,bool noAudioList) {
404 MediaListHolder *h=dirlist->getCurrent()->getHolder();
405 Log::getInstance()->log("VMediaList",Log::DEBUG,"getNumEntries type=%lu,lt=%d,na=%d,h=%p,l=%p",
406 mediaType,lowerThen,(int)noAudioList,h,(h?h->list():0));
408 if (mediaType == MEDIA_TYPE_ALL && lowerThen < 0) {
410 return h->list()->size();
412 if (lowerThen < 0) lowerThen=h->list()->size();
414 MediaList *ml=h->list();
416 if (mediaType == MEDIA_TYPE_AUDIO) {
417 //OK we look into the separate audiolist (if we have it...)
418 if (audiodirlist && ! noAudioList) {
419 MediaListHolder *ah=audiodirlist->getCurrent()->getHolder();
426 for (int i=0;i<(int)(ml->size()) && i <= lowerThen;i++) {
427 if ((*ml)[i]->getMediaType() & mediaType) rt++;
432 void VMediaList::setList(MediaListHolder* tlist)
434 dirlist->getCurrent()->assignHolder(tlist);
436 sortList(dirlist->getCurrent()->getSortorder());
437 updateSelectList(dirlist->getCurrent()->getSelection());
441 void VMediaList::updateSelectList(){
442 updateSelectList(-1);
444 void VMediaList::updateSelectList(int currentNumber){
445 MediaListHolder *h=dirlist->getCurrent()->getHolder();
447 char tempA[Media::TIMEBUFLEN];
448 Log::getInstance()->log("VMediaList::updateSelectList", Log::DEBUG, "media=%p",h);
451 ULONG currentSelection=0;
452 if (sl.getNumOptions() >= 1 && currentNumber < 0) {
453 currentSelection=sl.getCurrentOptionData();
461 for (UINT i = 0; i < h->list()->size(); i++)
463 media = (*h->list())[i];
464 if (media->getMediaType() == MEDIA_TYPE_DIR) {
465 sprintf(str, "%04u %s [%s]", i,media->getTimeString(tempA), media->getDisplayName());
466 //Log::getInstance()->log("VMediaList", Log::DEBUG, "add to select list %s",str);
467 media->index = sl.addOption(str, (ULONG)media, first);
470 sprintf(str, "%04u %s %s", i,media->getTimeString(tempA), media->getDisplayName());
471 //Log::getInstance()->log("VMediaList", Log::DEBUG, "add to select list %s",str);
472 media->index = sl.addOption(str, (ULONG)media, first);
477 if (currentNumber >= 0) sl.hintSetCurrent(currentNumber);
478 else sl.hintSetCurrent(0);
479 if (currentSelection != 0) {
481 //position to the previous selection
482 for (int i=0;i<sl.getNumOptions();i++) {
483 sl.hintSetCurrent(i);
484 if (sl.getCurrentOptionData() == currentSelection) {
489 if (! found) sl.hintSetCurrent(0);
492 if (sl.getNumOptions() > 0)
499 void VMediaList::draw()
501 Log::getInstance()->log("VMediaList::draw", Log::DEBUG, "namestr=%s",dirlist->getCurrent()->getDisplayName());
503 SNPRINTF(title, 398, tr("Media - %s"), dirlist->getCurrent()->getDisplayName());
509 sl.setVisible(false);
511 drawText(tr("Loading..."), 240, 180, Colour::LIGHTTEXT);
515 //if (sl.getNumOptions() > 0) sl.draw();
519 // Put the status stuff at the bottom
524 w.nextSymbol = WSymbol::UP;
525 w.setPosition(20, 385);
528 w.nextSymbol = WSymbol::DOWN;
529 w.setPosition(50, 385);
532 w.nextSymbol = WSymbol::SKIPBACK;
533 w.setPosition(85, 385);
536 w.nextSymbol = WSymbol::SKIPFORWARD;
537 w.setPosition(115, 385);
540 w.nextSymbol = WSymbol::PLAY;
541 w.setPosition(150, 385);
548 void VMediaList::doShowingBar()
550 int topOption = sl.getTopOption() + 1;
551 if (sl.getNumOptions() == 0) topOption = 0;
554 const char* strmode=NULL;
566 SNPRINTF(showing, 250,tr("%i to %i of %i"),
567 topOption, sl.getBottomOption(), sl.getNumOptions());
570 // b.setSurfaceOffset(220, 385);
571 // b.setDimensions(160, 25);
572 // b.fillColour(Colour::VIEWBACKGROUND);
573 // b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
575 rectangle(200, 384, 18, 16, Colour::VIDEOBLUE);
576 rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
577 drawText(strmode, 220, 385, Colour::LIGHTTEXT);
578 drawText(showing, 280, 385, Colour::LIGHTTEXT);
579 if (sl.getCurrentOptionData() != 0) Log::getInstance()->log("VMediaList",Log::DEBUG,"selected %s",((Media *)sl.getCurrentOptionData())->getDisplayName());
582 //find the next entry in the media list
583 //return the index in the list (starting with 0)
584 //return -1 if none found
585 int VMediaList::findNextEntry(int current, MediaList *list,ULONG ltype, ULONG move,bool wrap) {
586 if (! list) return -1;
587 if (current < 0) current=0;
588 if (current >= (int)list->size()) current=list->size()-1;
612 if (next >= (int)list->size()) {
620 if (next == current && move != MV_NONE) {
623 if (((*list)[next])->getMediaType() != ltype) {
637 Media * VMediaList::getMedia(ULONG ltype,ULONG move) {
639 MediaList *list=NULL;
640 MediaListHolder *h=NULL;
641 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia, t=%lu, mv=%lu",ltype,move);
643 //the currently active one (dirlist->getCurrent()->getHolder())
644 //and potentially a second one for audio (audiolist)
645 //currently (no recursive playing) we should always have an attached medialist in the audiolist
646 if (ltype == MEDIA_TYPE_AUDIO && audiodirlist != NULL ) {
647 h=audiodirlist->getCurrent()->getHolder();
649 Log::getInstance()->log("VMediaList",Log::ERR,"getMedia AUDIO empty medialist");
652 int nentry=findNextEntry(audiodirlist->getCurrent()->getSelection(),h->list(),ltype,move,false);
654 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia AUDIO no next entry");
658 audiodirlist->getCurrent()->setSelection(nentry);
660 rt=new Media((*list)[nentry]);
662 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia AUDIO next entry %d",nentry);
665 h=dirlist->getCurrent()->getHolder();
667 Log::getInstance()->log("VMediaList",Log::ERR,"getMedia PICTURE empty medialist");
670 int nentry=findNextEntry(dirlist->getCurrent()->getSelection(),h->list(),ltype,move,false);
672 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia type=%lu no next entry",ltype);
676 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia type=%lu next entry %d",ltype,nentry);
677 dirlist->getCurrent()->setSelection(nentry);
678 updateSelection(true);
681 rt=new Media((*list)[nentry]);
683 if (! rt->getURI()) {
684 MediaURI *uri=list->getURI(rt);
691 void VMediaList::updateSelection(bool toSelectList) {
693 dirlist->getCurrent()->setSelection(sl.getCurrentOption());
695 sl.hintSetCurrent(dirlist->getCurrent()->getSelection());
700 Media * VMediaList::getCurrentMedia(DirList *dl) {
701 if (! dl) return NULL;
702 MediaDirectory *d=dirlist->getCurrent();
703 if (! d) return NULL;
704 MediaListHolder *h=d->getHolder();
705 if (! h) return NULL;
706 if (d->getSelection() < 0 || d->getSelection() >= (int)h->list()->size()) return NULL;
707 Media *rt= (*h->list())[d->getSelection()];
713 int VMediaList::handleCommand(int command)
720 sl.hintSetCurrent(0);
724 boxstack->update(this);
735 boxstack->update(this);
738 case Remote::DF_DOWN:
746 boxstack->update(this);
749 case Remote::SKIPBACK:
756 boxstack->update(this);
759 case Remote::SKIPFORWARD:
766 boxstack->update(this);
774 boxstack->update(this);
777 sortList(SORT_RANDOM);
778 boxstack->update(this);
782 boxstack->update(this);
790 if (dirlist) media = getCurrentMedia(dirlist);
791 if (media == NULL) return 2;
792 Log::getInstance()->log("VMediaList", Log::DEBUG, "activated %lu", media->index);
793 switch(media->getMediaType())
798 Log::getInstance()->log("VMediaList", Log::DEBUG, "create child for %s",media->getFileName());
799 if (media->getFileName() == NULL ) return 2;
800 if (command == Remote::PLAY) {
801 dirlist->setStartLevel();
804 bool rt=changeDirectory(media);
805 if (command == Remote::PLAY && rt) {
813 case MEDIA_TYPE_AUDIO:
814 Log::getInstance()->log("VMediaList", Log::DEBUG, "play audio file %s",
815 media->getFileName());
816 if (dirmode != M_NONE && command == Remote::PLAY)
819 playAudio(command==Remote::PLAY,true,true);
821 case MEDIA_TYPE_VIDEO: {
822 Log::getInstance()->log("VMediaList", Log::DEBUG, "play video file %s",
823 media->getFileName());
825 if (! media->getURI()) {
827 MediaListHolder *h=dirlist->getCurrent()->getHolder();
829 Log::getInstance()->log("VMediaList", Log::ERR, "no media List");
832 MediaURI *u=h->list()->getURI(media);
838 VVideoMedia *v=new VVideoMedia(media,this);
839 BoxStack::getInstance()->add(v);
840 BoxStack::getInstance()->update(v);
844 case MEDIA_TYPE_PICTURE:
845 Log::getInstance()->log("VMediaList", Log::DEBUG, "show picture file %s",
846 media->getFileName());
847 if (dirmode != M_NONE && command == Remote::PLAY)
850 getViewer()->showPicture(MV_NONE,command==Remote::PLAY,true);
853 Log::getInstance()->log("VMediaList", Log::DEBUG, "unknown media type %d file %s",
854 media->getMediaType(),media->getFileName());
858 VVideoLive* v = new VVideoLive(dirlist->getCurrent()->getHolder(), media->type, this);
864 v->medianelChange(VVideoLive::NUMBER, media->number);
871 if (dirlist->getLevel() < 1) return 4;
876 // stop command getting to any more views
880 //go to the next level dir
881 //if OK - delete current medialist
882 bool VMediaList::changeDirectory(Media *media) {
883 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd to %s",media->getFileName());
885 dirlist->getCurrent()->setSortorder(sortOrder);
886 if (dirlist->getLevel() > 200) {
887 Log::getInstance()->log("VMediaList",Log::ERR,"above 300 levels, stop here...");
890 MediaListHolder *h=dirlist->getCurrent()->getHolder();
891 dirlist->getCurrent()->assignHolder(NULL); //prepare old holder for deletion
895 MediaURI *uri=h->list()->getURI(media);
896 dirlist->append(uri);
898 //same sort order for next level
899 dirlist->getCurrent()->setSortorder(sortOrder);
902 h->unref(); //this deletes now the old list
903 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd OK");
906 //we were no able to load the new list - so go back to our current list
908 dirlist->getCurrent()->assignHolder(h); //OK so we saved our list...
910 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd failed");
914 void VMediaList::directoryDone() {
915 if (! playingAll) return;
916 //go up until we are on the startlevel
917 Log::getInstance()->log("VMediaList", Log::DEBUG, "DirectoryDone ");
918 while ( ! dirlist->isOnStartLevel()) {
921 if (dirlist->isOnStartLevel()) break;
922 if (dirlist->getCurrent()->move(MV_NEXT))
925 if ( dirlist->isOnStartLevel()) {
928 Log::getInstance()->log("VMediaList", Log::DEBUG, "finished playing all l=%lu",dirlist->getLevel());
931 updateSelection(true);
935 bool VMediaList::playAll() {
936 if (dirmode == M_NONE) return false;
940 dirlist->setStartLevel();
944 Media *media=getCurrentMedia(dirlist);
947 Log::getInstance()->log("VMediaList", Log::DEBUG, "empty dir when calling playall");
949 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
952 Media *mcopy=new Media(media);
953 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all name=%s,t=%lu, started=%d",
954 mcopy->getDisplayName(),mcopy->getMediaType(),(int)started);
955 while (mcopy->getMediaType()==MEDIA_TYPE_DIR) {
956 //recurse to the next directory
957 bool rt=changeDirectory(mcopy);
959 //OK succesfully changed dir
960 int entries=getNumEntries(MEDIA_TYPE_AUDIO|MEDIA_TYPE_DIR|MEDIA_TYPE_PICTURE);
961 Log::getInstance()->log("VMediaList", Log::DEBUG, "cd OK, entries=%d",entries);
962 media=getCurrentMedia(dirlist);
963 if (entries==0 || media == NULL) {
964 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all name=%s empty",mcopy->getDisplayName());
966 //trigger directory end with the ability of user intervention
967 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
972 if (media->getMediaType()==MEDIA_TYPE_DIR) {
973 //send a defered event to give the user a chance to interrupt
974 //will again call playAll (but this does not chage the start level)
975 Timers::getInstance()->setTimerD(this,2,0,10000000l); //10ms
982 //unable to change to the directory
983 if (dirlist->getCurrent()->move(MV_NEXT)) {
984 //OK there is still a next medium here
985 updateSelection(true);
986 media=getCurrentMedia(dirlist);
988 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
992 mcopy=new Media(media);
995 //hmm - no entries here any more
1002 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all on level %d, sele=%d",
1003 dirlist->getLevel(),dirlist->getCurrent()->getSelection());
1005 enum Dirmode currentMode=dirmode;
1006 //OK now we handled all directories - now deal with the current one
1007 //1st determine the number of entries
1008 int aentries=getNumEntries(MEDIA_TYPE_AUDIO,-1,true);
1009 int pentries=getNumEntries(MEDIA_TYPE_PICTURE,-1,true);
1010 if (aentries == 0 && pentries == 0) {
1014 if (currentMode == M_COUNT) {
1015 if (aentries > pentries) currentMode=M_AUDIO;
1016 else currentMode=M_PICTURE;
1018 Log::getInstance()->log("VMediaList", Log::DEBUG, "mode=%d,ae=%d,pe=%d",currentMode,aentries,pentries);
1019 //now find the matching entries and start playing
1020 MediaListHolder *h=dirlist->getCurrent()->getHolder();
1022 Log::getInstance()->log("VMediaList", Log::ERR, "playing all empty medialist");
1027 Media *mpicture=NULL;
1028 int audioselection=-1;
1029 int pictureselection=-1;
1030 for (int i=dirlist->getCurrent()->getSelection();i<(int)h->list()->size();i++) {
1031 Media *m=(*h->list())[i];
1032 if (m->getMediaType() == MEDIA_TYPE_AUDIO && maudio == NULL) {
1036 if (m->getMediaType() == MEDIA_TYPE_PICTURE && mpicture == NULL) {
1040 if (maudio != NULL && mpicture != NULL) break;
1042 //OK now we found the first media for both - start players
1043 if (maudio != NULL) {
1044 dirlist->getCurrent()->setSelection(audioselection);
1045 playAudio(true,currentMode==M_AUDIO,mpicture==NULL); //this makes now a copy of dirlist...
1047 if (mpicture != NULL) {
1048 dirlist->getCurrent()->setSelection(pictureselection);
1049 getViewer()->showPicture(MV_NONE,true,currentMode==M_PICTURE);
1052 updateSelection(true);
1063 void VMediaList::processMessage(Message* m)
1065 if (m->message == Message::MOUSE_MOVE)
1067 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
1071 boxstack->update(this);
1074 else if (m->message == Message::MOUSE_LBDOWN)
1076 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
1078 boxstack->handleCommand(Remote::OK); //simulate OK press
1081 { //check if press is outside this view! then simulate cancel
1082 int x=(m->parameter>>16)-getScreenX();
1083 int y=(m->parameter&0xFFFF)-getScreenY();
1084 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
1086 boxstack->handleCommand(Remote::BACK); //simulate cancel press
1090 else if (m->message == Message::PLAYER_EVENT) {
1091 switch (m->parameter) {
1102 int VMediaList::createList() {
1103 Log::getInstance()->log("VMediaList::createList", Log::DEBUG, "");
1104 VMediaList *vmn=new VMediaList();
1105 //show the "loading" indicator
1106 BoxStack::getInstance()->add(vmn);
1109 BoxStack::getInstance()->remove(vmn);
1114 void VMediaList::sortList(int newSort) {
1115 MediaListHolder *h=dirlist->getCurrent()->getHolder();
1117 Log::getInstance()->log("VMediaList::sortList", Log::DEBUG, "p=%p,sort=%d,osort=%d, size=%d",this,newSort,sortOrder,h->list()->size());
1118 if (sortOrder == newSort) return;
1119 if (h->list()->begin() != h->list()->end()) {
1122 ::sort(h->list()->begin(),h->list()->end(),MediaSorterTime());
1125 ::sort(h->list()->begin(),h->list()->end(),MediaSorterName());
1128 ::sort(h->list()->begin(),h->list()->end(),MediaSorterRandom(time(NULL)));
1135 Log::getInstance()->log("VMediaList::sortList", Log::DEBUG, "done ");
1139 int VMediaList::load() {
1143 boxstack->update(this);
1144 MediaPlayer * mp=MediaPlayer::getInstance();
1145 Log::getInstance()->log("VMediaList::load", Log::DEBUG, "load list for %p",dirlist->getURI());
1146 MediaDirectory *md=dirlist->getCurrent();
1149 mn=mp->getMediaList(md->getURI());
1152 mn=mp->getRootList();
1155 MediaListHolder *h=new MediaListHolder(mn);
1160 boxstack->update(this);
1164 Log::getInstance()->log("VMediaList", Log::ERR, "unable to get MediaList for %p",dirlist->getURI());
1166 VInfo* vi = new VInfo();
1167 vi->setSize(400, 150);
1171 vi->setTitleBarOn(0);
1173 if (Video::getInstance()->getFormat() == Video::PAL)
1174 vi->setPosition(170, 200);
1176 vi->setPosition(160, 150);
1177 vi->setOneLiner(tr("unable to get media list"));
1180 Message* m = new Message();
1181 m->message = Message::ADD_VIEW;
1183 m->parameter = (ULONG)vi;
1184 Command::getInstance()->postMessageNoLock(m);
1189 const char * VMediaList::getDirname(ULONG mtype) const {
1190 if (mtype == MEDIA_TYPE_AUDIO && audiodirlist) {
1191 return audiodirlist->getCurrent()->getDisplayName();
1193 return dirlist->getCurrent()->getDisplayName();
1196 void VMediaList::timercall(int ref) {
1197 if (ref == 1 || ref == 2 ) {
1198 //send a directory done event
1199 Message* m = new Message();
1200 m->message = Message::PLAYER_EVENT;
1203 Command::getInstance()->postMessageFromOuterSpace(m);