svvitch
digital signage player
|
00001 #include "Content.h" 00002 00003 #include <Poco/NumberFormatter.h> 00004 #include <Poco/NumberParser.h> 00005 00006 00007 Content::Content(Renderer& renderer, int splitType, float x, float y, float w, float h): 00008 _log(Poco::Logger::get("")), _renderer(renderer), _splitType(splitType), _duration(0), _current(0), _x(x), _y(y), _w(w), _h(h), _playing(false), 00009 activeClose(this, &Content::close) 00010 { 00011 } 00012 00013 Content::‾Content() { 00014 initialize(); 00015 _properties.clear(); 00016 } 00017 00018 void Content::initialize() { 00019 } 00020 00021 bool Content::open(const MediaItemPtr media, const int offset) { 00022 _mediaID = media->id(); 00023 return true; 00024 } 00025 00026 const string Content::opened() const { 00027 return _mediaID; 00028 } 00029 00030 void Content::play() { 00031 _playing = true; 00032 } 00033 00034 void Content::pause() { 00035 } 00036 00037 void Content::stop() { 00038 _playing = false; 00039 } 00040 00041 bool Content::useFastStop() { 00042 return false; 00043 } 00044 00045 void Content::rewind() { 00046 _current = 0; 00047 } 00048 00052 const bool Content::playing() const { 00053 return _playing; 00054 } 00055 00056 const bool Content::finished() { 00057 return false; 00058 } 00059 00061 void Content::close() { 00062 _mediaID.clear(); 00063 } 00064 00066 void Content::notifyKey(const int keycode, const bool shift, const bool ctrl) { 00067 _keycode = keycode; 00068 _shift = shift; 00069 _ctrl = ctrl; 00070 } 00071 00073 void Content::process(const DWORD& frame) { 00074 } 00075 00077 void Content::draw(const DWORD& frame) { 00078 } 00079 00081 void Content::preview(const DWORD& frame) { 00082 } 00083 00087 const int Content::current() const { 00088 return _current; 00089 } 00090 00094 const int Content::duration() const { 00095 return _duration; 00096 } 00097 00098 00099 void Content::setPosition(float x, float y) { 00100 _x = x; 00101 _y = y; 00102 } 00103 00104 void Content::getPosition(float& x, float& y) { 00105 x = _x; 00106 y = _y; 00107 } 00108 00109 void Content::setBounds(float w, float h) { 00110 _w = w; 00111 _h = h; 00112 } 00113 00114 const bool Content::contains(float x, float y) const { 00115 return x >= _x && y >= _y && x <= _x + _w && y <= _y + _h; 00116 } 00117 00118 void Content::set(const string& key, const string& value) { 00119 if (_properties.find(key) != _properties.end()) _properties.erase(key); 00120 _properties[key] = value; 00121 } 00122 00123 void Content::set(const string& key, const float& value) { 00124 set(key, Poco::NumberFormatter::format(value)); 00125 } 00126 00127 void Content::set(const string& key, const unsigned int& value) { 00128 set(key, Poco::NumberFormatter::format(value)); 00129 } 00130 00131 const string& Content::get(const string& key, const string& defaultValue) const { 00132 HashMap<string, string>::ConstIterator it = _properties.find(key); 00133 if (it != _properties.end()) { 00134 return it->second; 00135 } 00136 return defaultValue; 00137 } 00138 00139 const DWORD Content::getDW(const string& key, const DWORD& defaultValue) const { 00140 const string value = get(key); 00141 if (!value.empty()) { 00142 try { 00143 return (DWORD)Poco::NumberParser::parse64(value); 00144 } catch (Poco::SyntaxException& ex) { 00145 } 00146 } 00147 return defaultValue; 00148 } 00149 00150 const int Content::getI(const string& key, const int& defaultValue) const { 00151 const string value = get(key); 00152 if (!value.empty()) { 00153 try { 00154 return Poco::NumberParser::parse(value); 00155 } catch (Poco::SyntaxException& ex) { 00156 } 00157 } 00158 return defaultValue; 00159 } 00160 00161 const float Content::getF(const string& key, const float& defaultValue) const { 00162 const string value = get(key); 00163 if (!value.empty()) { 00164 try { 00165 return (float)Poco::NumberParser::parseFloat(value); 00166 } catch (Poco::SyntaxException& ex) { 00167 } 00168 } 00169 return defaultValue; 00170 }