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
354 LocalMediaFile::init();
359 VMediaList::~VMediaList()
361 Log::getInstance()->log("VMediaList::~VMediaList", Log::DEBUG, "start");
362 Timers::getInstance()->cancelTimer(this,1);
363 Timers::getInstance()->cancelTimer(this,2);
366 if (audiodirlist) delete audiodirlist;
367 Log::getInstance()->log("VMediaList::~VMediaList", Log::DEBUG, "finished");
370 void VMediaList::removeViewer() {
372 BoxStack::getInstance()->remove(viewer);
377 VMediaView * VMediaList::getViewer() {
379 viewer=VMediaView::createViewer(this);
385 void VMediaList::playAudio(bool all,bool activate, bool showInfo) {
386 MediaListHolder *h=dirlist->getCurrent()->getHolder();
388 VMediaView *player=getViewer();
389 //OK make a copy of the current active list for audio playing
390 if (audiodirlist) delete audiodirlist;
391 audiodirlist=new DirList(dirlist);
392 player->play(all,activate,MV_NONE,showInfo);
396 void VMediaList::updateAll() {
397 BoxStack::getInstance()->update(this);
398 if (viewer) BoxStack::getInstance()->update(viewer);
399 BoxStack::getInstance()->update(NULL);
405 int VMediaList::getNumEntries(ULONG mediaType,int lowerThen,bool noAudioList) {
406 MediaListHolder *h=dirlist->getCurrent()->getHolder();
407 Log::getInstance()->log("VMediaList",Log::DEBUG,"getNumEntries type=%lu,lt=%d,na=%d,h=%p,l=%p",
408 mediaType,lowerThen,(int)noAudioList,h,(h?h->list():0));
410 if (mediaType == MEDIA_TYPE_ALL && lowerThen < 0) {
412 return h->list()->size();
414 if (lowerThen < 0) lowerThen=h->list()->size();
416 MediaList *ml=h->list();
418 if (mediaType == MEDIA_TYPE_AUDIO) {
419 //OK we look into the separate audiolist (if we have it...)
420 if (audiodirlist && ! noAudioList) {
421 MediaListHolder *ah=audiodirlist->getCurrent()->getHolder();
428 for (int i=0;i<(int)(ml->size()) && i <= lowerThen;i++) {
429 if ((*ml)[i]->getMediaType() & mediaType) rt++;
434 void VMediaList::setList(MediaListHolder* tlist)
436 dirlist->getCurrent()->assignHolder(tlist);
438 sortList(dirlist->getCurrent()->getSortorder());
439 updateSelectList(dirlist->getCurrent()->getSelection());
443 void VMediaList::updateSelectList(){
444 updateSelectList(-1);
446 void VMediaList::updateSelectList(int currentNumber){
447 MediaListHolder *h=dirlist->getCurrent()->getHolder();
449 char tempA[Media::TIMEBUFLEN];
450 Log::getInstance()->log("VMediaList::updateSelectList", Log::DEBUG, "media=%p",h);
453 ULONG currentSelection=0;
454 if (sl.getNumOptions() >= 1 && currentNumber < 0) {
455 currentSelection=sl.getCurrentOptionData();
463 for (UINT i = 0; i < h->list()->size(); i++)
465 media = (*h->list())[i];
466 if (media->getMediaType() == MEDIA_TYPE_DIR) {
467 sprintf(str, "%04u %s [%s]", i,media->getTimeString(tempA), media->getDisplayName());
468 //Log::getInstance()->log("VMediaList", Log::DEBUG, "add to select list %s",str);
469 media->index = sl.addOption(str, (ULONG)media, first);
472 sprintf(str, "%04u %s %s", i,media->getTimeString(tempA), media->getDisplayName());
473 //Log::getInstance()->log("VMediaList", Log::DEBUG, "add to select list %s",str);
474 media->index = sl.addOption(str, (ULONG)media, first);
479 if (currentNumber >= 0) sl.hintSetCurrent(currentNumber);
480 else sl.hintSetCurrent(0);
481 if (currentSelection != 0) {
483 //position to the previous selection
484 for (int i=0;i<sl.getNumOptions();i++) {
485 sl.hintSetCurrent(i);
486 if (sl.getCurrentOptionData() == currentSelection) {
491 if (! found) sl.hintSetCurrent(0);
494 if (sl.getNumOptions() > 0)
501 void VMediaList::draw()
503 Log::getInstance()->log("VMediaList::draw", Log::DEBUG, "namestr=%s",dirlist->getCurrent()->getDisplayName());
505 SNPRINTF(title, 398, tr("Media - %s"), dirlist->getCurrent()->getDisplayName());
511 sl.setVisible(false);
513 drawText(tr("Loading..."), 240, 180, Colour::LIGHTTEXT);
517 //if (sl.getNumOptions() > 0) sl.draw();
521 // Put the status stuff at the bottom
526 w.nextSymbol = WSymbol::UP;
527 w.setPosition(20, 385);
530 w.nextSymbol = WSymbol::DOWN;
531 w.setPosition(50, 385);
534 w.nextSymbol = WSymbol::SKIPBACK;
535 w.setPosition(85, 385);
538 w.nextSymbol = WSymbol::SKIPFORWARD;
539 w.setPosition(115, 385);
542 w.nextSymbol = WSymbol::PLAY;
543 w.setPosition(150, 385);
550 void VMediaList::doShowingBar()
552 int topOption = sl.getTopOption() + 1;
553 if (sl.getNumOptions() == 0) topOption = 0;
556 const char* strmode=NULL;
568 SNPRINTF(showing, 250,tr("%i to %i of %i"),
569 topOption, sl.getBottomOption(), sl.getNumOptions());
572 // b.setSurfaceOffset(220, 385);
573 // b.setDimensions(160, 25);
574 // b.fillColour(Colour::VIEWBACKGROUND);
575 // b.drawText(showing, 0, 0, Colour::LIGHTTEXT);
577 rectangle(200, 384, 18, 16, Colour::VIDEOBLUE);
578 rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
579 drawText(strmode, 220, 385, Colour::LIGHTTEXT);
580 drawText(showing, 280, 385, Colour::LIGHTTEXT);
581 if (sl.getCurrentOptionData() != 0) Log::getInstance()->log("VMediaList",Log::DEBUG,"selected %s",((Media *)sl.getCurrentOptionData())->getDisplayName());
584 //find the next entry in the media list
585 //return the index in the list (starting with 0)
586 //return -1 if none found
587 int VMediaList::findNextEntry(int current, MediaList *list,ULONG ltype, ULONG move,bool wrap) {
588 if (! list) return -1;
589 if (current < 0) current=0;
590 if (current >= (int)list->size()) current=list->size()-1;
614 if (next >= (int)list->size()) {
622 if (next == current && move != MV_NONE) {
625 if (((*list)[next])->getMediaType() != ltype) {
639 Media * VMediaList::getMedia(ULONG ltype,ULONG move) {
641 MediaList *list=NULL;
642 MediaListHolder *h=NULL;
643 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia, t=%lu, mv=%lu",ltype,move);
645 //the currently active one (dirlist->getCurrent()->getHolder())
646 //and potentially a second one for audio (audiolist)
647 //currently (no recursive playing) we should always have an attached medialist in the audiolist
648 if (ltype == MEDIA_TYPE_AUDIO && audiodirlist != NULL ) {
649 h=audiodirlist->getCurrent()->getHolder();
651 Log::getInstance()->log("VMediaList",Log::ERR,"getMedia AUDIO empty medialist");
654 int nentry=findNextEntry(audiodirlist->getCurrent()->getSelection(),h->list(),ltype,move,false);
656 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia AUDIO no next entry");
660 audiodirlist->getCurrent()->setSelection(nentry);
662 rt=new Media((*list)[nentry]);
664 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia AUDIO next entry %d",nentry);
667 h=dirlist->getCurrent()->getHolder();
669 Log::getInstance()->log("VMediaList",Log::ERR,"getMedia PICTURE empty medialist");
672 int nentry=findNextEntry(dirlist->getCurrent()->getSelection(),h->list(),ltype,move,false);
674 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia type=%lu no next entry",ltype);
678 Log::getInstance()->log("VMediaList",Log::DEBUG,"getMedia type=%lu next entry %d",ltype,nentry);
679 dirlist->getCurrent()->setSelection(nentry);
680 updateSelection(true);
683 rt=new Media((*list)[nentry]);
685 if (! rt->getURI()) {
686 MediaURI *uri=list->getURI(rt);
693 void VMediaList::updateSelection(bool toSelectList) {
695 dirlist->getCurrent()->setSelection(sl.getCurrentOption());
697 sl.hintSetCurrent(dirlist->getCurrent()->getSelection());
702 Media * VMediaList::getCurrentMedia(DirList *dl) {
703 if (! dl) return NULL;
704 MediaDirectory *d=dirlist->getCurrent();
705 if (! d) return NULL;
706 MediaListHolder *h=d->getHolder();
707 if (! h) return NULL;
708 if (d->getSelection() < 0 || d->getSelection() >= (int)h->list()->size()) return NULL;
709 Media *rt= (*h->list())[d->getSelection()];
715 int VMediaList::handleCommand(int command)
722 sl.hintSetCurrent(0);
726 boxstack->update(this);
737 boxstack->update(this);
740 case Remote::DF_DOWN:
748 boxstack->update(this);
751 case Remote::SKIPBACK:
758 boxstack->update(this);
761 case Remote::SKIPFORWARD:
768 boxstack->update(this);
776 boxstack->update(this);
779 sortList(SORT_RANDOM);
780 boxstack->update(this);
784 boxstack->update(this);
792 if (dirlist) media = getCurrentMedia(dirlist);
793 if (media == NULL) return 2;
794 Log::getInstance()->log("VMediaList", Log::DEBUG, "activated %lu", media->index);
795 switch(media->getMediaType())
800 Log::getInstance()->log("VMediaList", Log::DEBUG, "create child for %s",media->getFileName());
801 if (media->getFileName() == NULL ) return 2;
802 if (command == Remote::PLAY) {
803 dirlist->setStartLevel();
806 bool rt=changeDirectory(media);
807 if (command == Remote::PLAY && rt) {
815 case MEDIA_TYPE_AUDIO:
816 Log::getInstance()->log("VMediaList", Log::DEBUG, "play audio file %s",
817 media->getFileName());
818 if (dirmode != M_NONE && command == Remote::PLAY)
821 playAudio(command==Remote::PLAY,true,true);
823 case MEDIA_TYPE_VIDEO: {
824 #ifndef WIN32 //Only DVB style MPEG is supported by the Windows Part!
825 Log::getInstance()->log("VMediaList", Log::DEBUG, "play video file %s",
826 media->getFileName());
828 if (! media->getURI()) {
830 MediaListHolder *h=dirlist->getCurrent()->getHolder();
832 Log::getInstance()->log("VMediaList", Log::ERR, "no media List");
835 MediaURI *u=h->list()->getURI(media);
841 VVideoMedia *v=new VVideoMedia(media,this);
842 BoxStack::getInstance()->add(v);
843 BoxStack::getInstance()->update(v);
848 case MEDIA_TYPE_PICTURE:
849 Log::getInstance()->log("VMediaList", Log::DEBUG, "show picture file %s",
850 media->getFileName());
851 if (dirmode != M_NONE && command == Remote::PLAY)
854 getViewer()->showPicture(MV_NONE,command==Remote::PLAY,true);
857 Log::getInstance()->log("VMediaList", Log::DEBUG, "unknown media type %d file %s",
858 media->getMediaType(),media->getFileName());
862 VVideoLive* v = new VVideoLive(dirlist->getCurrent()->getHolder(), media->type, this);
868 v->medianelChange(VVideoLive::NUMBER, media->number);
875 if (dirlist->getLevel() < 1) return 4;
880 // stop command getting to any more views
884 //go to the next level dir
885 //if OK - delete current medialist
886 bool VMediaList::changeDirectory(Media *media) {
887 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd to %s",media->getFileName());
889 dirlist->getCurrent()->setSortorder(sortOrder);
890 if (dirlist->getLevel() > 200) {
891 Log::getInstance()->log("VMediaList",Log::ERR,"above 300 levels, stop here...");
894 MediaListHolder *h=dirlist->getCurrent()->getHolder();
895 dirlist->getCurrent()->assignHolder(NULL); //prepare old holder for deletion
899 MediaURI *uri=h->list()->getURI(media);
900 dirlist->append(uri);
902 //same sort order for next level
903 dirlist->getCurrent()->setSortorder(sortOrder);
906 h->unref(); //this deletes now the old list
907 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd OK");
910 //we were no able to load the new list - so go back to our current list
912 dirlist->getCurrent()->assignHolder(h); //OK so we saved our list...
914 Log::getInstance()->log("VMediaList",Log::DEBUG,"cd failed");
918 void VMediaList::directoryDone() {
919 if (! playingAll) return;
920 //go up until we are on the startlevel
921 Log::getInstance()->log("VMediaList", Log::DEBUG, "DirectoryDone ");
922 while ( ! dirlist->isOnStartLevel()) {
925 if (dirlist->isOnStartLevel()) break;
926 if (dirlist->getCurrent()->move(MV_NEXT))
929 if ( dirlist->isOnStartLevel()) {
932 Log::getInstance()->log("VMediaList", Log::DEBUG, "finished playing all l=%lu",dirlist->getLevel());
935 updateSelection(true);
939 bool VMediaList::playAll() {
940 if (dirmode == M_NONE) return false;
944 dirlist->setStartLevel();
948 Media *media=getCurrentMedia(dirlist);
951 Log::getInstance()->log("VMediaList", Log::DEBUG, "empty dir when calling playall");
953 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
956 Media *mcopy=new Media(media);
957 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all name=%s,t=%lu, started=%d",
958 mcopy->getDisplayName(),mcopy->getMediaType(),(int)started);
959 while (mcopy->getMediaType()==MEDIA_TYPE_DIR) {
960 //recurse to the next directory
961 bool rt=changeDirectory(mcopy);
963 //OK succesfully changed dir
964 int entries=getNumEntries(MEDIA_TYPE_AUDIO|MEDIA_TYPE_DIR|MEDIA_TYPE_PICTURE);
965 Log::getInstance()->log("VMediaList", Log::DEBUG, "cd OK, entries=%d",entries);
966 media=getCurrentMedia(dirlist);
967 if (entries==0 || media == NULL) {
968 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all name=%s empty",mcopy->getDisplayName());
970 //trigger directory end with the ability of user intervention
971 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
976 if (media->getMediaType()==MEDIA_TYPE_DIR) {
977 //send a defered event to give the user a chance to interrupt
978 //will again call playAll (but this does not chage the start level)
979 Timers::getInstance()->setTimerD(this,2,0,10000000l); //10ms
986 //unable to change to the directory
987 if (dirlist->getCurrent()->move(MV_NEXT)) {
988 //OK there is still a next medium here
989 updateSelection(true);
990 media=getCurrentMedia(dirlist);
992 Timers::getInstance()->setTimerD(this,1,0,10000000l); //10ms
996 mcopy=new Media(media);
999 //hmm - no entries here any more
1000 //so we have to stop
1006 Log::getInstance()->log("VMediaList", Log::DEBUG, "playing all on level %d, sele=%d",
1007 dirlist->getLevel(),dirlist->getCurrent()->getSelection());
1009 enum Dirmode currentMode=dirmode;
1010 //OK now we handled all directories - now deal with the current one
1011 //1st determine the number of entries
1012 int aentries=getNumEntries(MEDIA_TYPE_AUDIO,-1,true);
1013 int pentries=getNumEntries(MEDIA_TYPE_PICTURE,-1,true);
1014 if (aentries == 0 && pentries == 0) {
1018 if (currentMode == M_COUNT) {
1019 if (aentries > pentries) currentMode=M_AUDIO;
1020 else currentMode=M_PICTURE;
1022 Log::getInstance()->log("VMediaList", Log::DEBUG, "mode=%d,ae=%d,pe=%d",currentMode,aentries,pentries);
1023 //now find the matching entries and start playing
1024 MediaListHolder *h=dirlist->getCurrent()->getHolder();
1026 Log::getInstance()->log("VMediaList", Log::ERR, "playing all empty medialist");
1031 Media *mpicture=NULL;
1032 int audioselection=-1;
1033 int pictureselection=-1;
1034 for (int i=dirlist->getCurrent()->getSelection();i<(int)h->list()->size();i++) {
1035 Media *m=(*h->list())[i];
1036 if (m->getMediaType() == MEDIA_TYPE_AUDIO && maudio == NULL) {
1040 if (m->getMediaType() == MEDIA_TYPE_PICTURE && mpicture == NULL) {
1044 if (maudio != NULL && mpicture != NULL) break;
1046 //OK now we found the first media for both - start players
1047 if (maudio != NULL) {
1048 dirlist->getCurrent()->setSelection(audioselection);
1049 playAudio(true,currentMode==M_AUDIO,mpicture==NULL); //this makes now a copy of dirlist...
1051 if (mpicture != NULL) {
1052 dirlist->getCurrent()->setSelection(pictureselection);
1053 getViewer()->showPicture(MV_NONE,true,currentMode==M_PICTURE);
1056 updateSelection(true);
1067 void VMediaList::processMessage(Message* m)
1069 if (m->message == Message::MOUSE_MOVE)
1071 if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
1075 boxstack->update(this);
1079 else if (m->message == Message::MOUSE_LBDOWN)
1081 if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY()))
1084 boxstack->handleCommand(Remote::OK); //simulate OK press
1087 { //check if press is outside this view! then simulate cancel
1088 int x=(m->parameter>>16)-getScreenX();
1089 int y=(m->parameter&0xFFFF)-getScreenY();
1090 if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight())
1092 boxstack->handleCommand(Remote::BACK); //simulate cancel press
1096 else if (m->message == Message::PLAYER_EVENT) {
1097 switch (m->parameter) {
1108 int VMediaList::createList() {
1109 Log::getInstance()->log("VMediaList::createList", Log::DEBUG, "");
1110 VMediaList *vmn=new VMediaList();
1111 //show the "loading" indicator
1112 BoxStack::getInstance()->add(vmn);
1115 BoxStack::getInstance()->remove(vmn);
1120 void VMediaList::sortList(int newSort) {
1121 MediaListHolder *h=dirlist->getCurrent()->getHolder();
1123 Log::getInstance()->log("VMediaList::sortList", Log::DEBUG, "p=%p,sort=%d,osort=%d, size=%d",this,newSort,sortOrder,h->list()->size());
1124 if (sortOrder == newSort) return;
1125 if (h->list()->begin() != h->list()->end()) {
1128 ::sort(h->list()->begin(),h->list()->end(),MediaSorterTime());
1131 ::sort(h->list()->begin(),h->list()->end(),MediaSorterName());
1134 ::sort(h->list()->begin(),h->list()->end(),MediaSorterRandom(time(NULL)));
1141 Log::getInstance()->log("VMediaList::sortList", Log::DEBUG, "done ");
1145 int VMediaList::load() {
1149 boxstack->update(this);
1150 MediaPlayer * mp=MediaPlayer::getInstance();
1151 Log::getInstance()->log("VMediaList::load", Log::DEBUG, "load list for %p",dirlist->getURI());
1152 MediaDirectory *md=dirlist->getCurrent();
1155 mn=mp->getMediaList(md->getURI());
1158 mn=mp->getRootList();
1161 MediaListHolder *h=new MediaListHolder(mn);
1166 boxstack->update(this);
1170 Log::getInstance()->log("VMediaList", Log::ERR, "unable to get MediaList for %p",dirlist->getURI());
1172 VInfo* vi = new VInfo();
1173 vi->setSize(400, 150);
1177 vi->setTitleBarOn(0);
1179 if (Video::getInstance()->getFormat() == Video::PAL)
1180 vi->setPosition(170, 200);
1182 vi->setPosition(160, 150);
1183 vi->setOneLiner(tr("unable to get media list"));
1186 Message* m = new Message();
1187 m->message = Message::ADD_VIEW;
1189 m->parameter = (ULONG)vi;
1190 Command::getInstance()->postMessageNoLock(m);
1195 const char * VMediaList::getDirname(ULONG mtype) const {
1196 if (mtype == MEDIA_TYPE_AUDIO && audiodirlist) {
1197 return audiodirlist->getCurrent()->getDisplayName();
1199 return dirlist->getCurrent()->getDisplayName();
1202 void VMediaList::timercall(int ref) {
1203 if (ref == 1 || ref == 2 ) {
1204 //send a directory done event
1205 Message* m = new Message();
1206 m->message = Message::PLAYER_EVENT;
1209 Command::getInstance()->postMessageFromOuterSpace(m);