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()
14 ePtr<eServiceCenter> sc;
16 eServiceCenter::getPrivInstance(sc);
18 sc->addServiceFactory(eServiceFactoryMP3::id, this);
20 m_service_info = new eStaticServiceMP3Info();
23 eServiceFactoryMP3::~eServiceFactoryMP3()
25 ePtr<eServiceCenter> sc;
27 eServiceCenter::getPrivInstance(sc);
29 sc->removeServiceFactory(eServiceFactoryMP3::id);
32 DEFINE_REF(eServiceFactoryMP3)
35 RESULT eServiceFactoryMP3::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
38 ptr = new eServiceMP3(ref.path.c_str());
42 RESULT eServiceFactoryMP3::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
48 RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr<iListableService> &ptr)
54 RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
60 RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
67 // eStaticServiceMP3Info
70 // eStaticServiceMP3Info is seperated from eServiceMP3 to give information
71 // about unopened files.
73 // probably eServiceMP3 should use this class as well, and eStaticServiceMP3Info
74 // should have a database backend where ID3-files etc. are cached.
75 // this would allow listing the mp3 database based on certain filters.
77 DEFINE_REF(eStaticServiceMP3Info)
79 eStaticServiceMP3Info::eStaticServiceMP3Info()
83 RESULT eStaticServiceMP3Info::getName(const eServiceReference &ref, std::string &name)
85 name = "MP3 file: " + ref.path;
89 int eStaticServiceMP3Info::getLength(const eServiceReference &ref)
96 void eServiceMP3::test_end()
98 eDebug("end of mp3!");
102 eServiceMP3::eServiceMP3(const char *filename): filename(filename), test(eApp)
105 eDebug("SERVICEMP3 construct!");
108 eServiceMP3::~eServiceMP3()
110 eDebug("SERVICEMP3 destruct!");
111 if (m_state == stRunning)
115 DEFINE_REF(eServiceMP3);
117 RESULT eServiceMP3::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)
119 connection = new eConnection((iPlayableService*)this, m_event.connect(event));
123 RESULT eServiceMP3::start()
125 assert(m_state == stIdle);
129 printf("mp3 starts\n");
130 printf("MP3: %s start\n", filename.c_str());
132 CONNECT(test.timeout, eServiceMP3::test_end);
133 m_event(this, evStart);
137 RESULT eServiceMP3::stop()
139 assert(m_state != stIdle);
140 if (m_state == stStopped)
143 printf("MP3: %s stop\n", filename.c_str());
145 m_event(this, evEnd);
149 RESULT eServiceMP3::pause(ePtr<iPauseableService> &ptr)
155 RESULT eServiceMP3::setSlowMotion(int ratio)
160 RESULT eServiceMP3::setFastForward(int ratio)
166 RESULT eServiceMP3::pause()
168 printf("mp3 pauses!\n");
172 RESULT eServiceMP3::unpause()
174 printf("mp3 unpauses!\n");
178 RESULT eServiceMP3::info(ePtr<iServiceInformation>&i)
184 RESULT eServiceMP3::getName(std::string &name)
186 name = "MP3 File: " + filename;
190 eAutoInitPtr<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3");