1 #include <lib/base/eerror.h>
2 #include <lib/base/object.h>
3 #include <lib/base/ebase.h>
5 #include <lib/service/servicemp3.h>
6 #include <lib/service/service.h>
7 #include <lib/base/init_num.h>
8 #include <lib/base/init.h>
12 eServiceFactoryMP3::eServiceFactoryMP3(): ref(0)
14 ePtr<eServiceCenter> sc;
16 eServiceCenter::getInstance(sc);
18 sc->addServiceFactory(eServiceFactoryMP3::id, this);
21 eServiceFactoryMP3::~eServiceFactoryMP3()
23 ePtr<eServiceCenter> sc;
25 eServiceCenter::getInstance(sc);
27 sc->removeServiceFactory(eServiceFactoryMP3::id);
30 DEFINE_REF(eServiceFactoryMP3)
33 RESULT eServiceFactoryMP3::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
36 ptr = new eServiceMP3(ref.path.c_str());
40 RESULT eServiceFactoryMP3::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
46 RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr<iListableService> &ptr)
55 void eServiceMP3::test_end()
57 eDebug("end of mp3!");
61 eServiceMP3::eServiceMP3(const char *filename): ref(0), filename(filename), test(eApp)
64 eDebug("SERVICEMP3 construct!");
67 eServiceMP3::~eServiceMP3()
69 eDebug("SERVICEMP3 destruct!");
70 if (m_state == stRunning)
74 DEFINE_REF(eServiceMP3);
76 RESULT eServiceMP3::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)
78 connection = new eConnection(this, m_event.connect(event));
82 RESULT eServiceMP3::start()
84 assert(m_state == stIdle);
88 printf("mp3 starts\n");
89 printf("MP3: %s start\n", filename.c_str());
91 CONNECT(test.timeout, eServiceMP3::test_end);
92 m_event(this, evStart);
96 RESULT eServiceMP3::stop()
98 assert(m_state != stIdle);
99 if (m_state == stStopped)
102 printf("MP3: %s stop\n", filename.c_str());
104 m_event(this, evEnd);
108 RESULT eServiceMP3::getIPausableService(ePtr<iPauseableService> &ptr) { ptr=this; return 0; }
111 RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; }
112 RESULT eServiceMP3::unpause() { printf("mp3 unpauses!\n"); return 0; }
114 RESULT eServiceMP3::getIServiceInformation(ePtr<iServiceInformation>&i) { i = this; return 0; }
116 RESULT eServiceMP3::getName(eString &name)
118 name = "MP3 File: " + filename;
122 eAutoInitPtr<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3");