--- GET PLAYBACK STATUS ---
| 206 | |
| 207 | // --- GET PLAYBACK STATUS --- |
| 208 | std::map<std::string, NymphPair>* getPlaybackStatus() { |
| 209 | // Set the playback status. |
| 210 | // We're sending back whether we are playing something currently. If so, also includes: |
| 211 | // * duration of media in seconds. |
| 212 | // * position in the media, in seconds with remainder. |
| 213 | // * title of the media, if available. |
| 214 | // * artist of the media, if available. |
| 215 | std::map<std::string, NymphPair>* pairs = new std::map<std::string, NymphPair>(); |
| 216 | NymphPair pair; |
| 217 | std::string* key; |
| 218 | if (ffplay.playbackActive()) { |
| 219 | // Distinguish between playing and paused for the player. |
| 220 | if (playerPaused) { |
| 221 | key = new std::string("status"); |
| 222 | pair.key = new NymphType(key, true); |
| 223 | pair.value = new NymphType((uint32_t) NYMPH_PLAYBACK_STATUS_PAUSED); |
| 224 | pairs->insert(std::pair<std::string, NymphPair>(*key, pair)); |
| 225 | } |
| 226 | else { |
| 227 | key = new std::string("status"); |
| 228 | pair.key = new NymphType(key, true); |
| 229 | pair.value = new NymphType((uint32_t) NYMPH_PLAYBACK_STATUS_PLAYING); |
| 230 | pairs->insert(std::pair<std::string, NymphPair>(*key, pair)); |
| 231 | } |
| 232 | |
| 233 | key = new std::string("playing"); |
| 234 | pair.key = new NymphType(key, true); |
| 235 | pair.value = new NymphType(true); |
| 236 | pairs->insert(std::pair<std::string, NymphPair>(*key, pair)); |
| 237 | |
| 238 | key = new std::string("stopped"); |
| 239 | pair.key = new NymphType(key, true); |
| 240 | pair.value = new NymphType(false); |
| 241 | pairs->insert(std::pair<std::string, NymphPair>(*key, pair)); |
| 242 | |
| 243 | key = new std::string("duration"); |
| 244 | pair.key = new NymphType(key, true); |
| 245 | //pair.value = new NymphType(FileMetaInfo::getDuration()); |
| 246 | pair.value = new NymphType(file_meta.getDuration()); |
| 247 | pairs->insert(std::pair<std::string, NymphPair>(*key, pair)); |
| 248 | |
| 249 | key = new std::string("position"); |
| 250 | pair.key = new NymphType(key, true); |
| 251 | //pair.value = new NymphType(FileMetaInfo::getPosition()); |
| 252 | //pair.value = new NymphType(file_meta.getPosition()); |
| 253 | pair.value = new NymphType(file_meta.position); |
| 254 | pairs->insert(std::pair<std::string, NymphPair>(*key, pair)); |
| 255 | |
| 256 | key = new std::string("title"); |
| 257 | pair.key = new NymphType(key, true); |
| 258 | //std::string* val = new std::string(FileMetaInfo::getTitle()); |
| 259 | std::string* val = new std::string(file_meta.getTitle()); |
| 260 | pair.value = new NymphType(val, true); |
| 261 | pairs->insert(std::pair<std::string, NymphPair>(*key, pair)); |
| 262 | |
| 263 | key = new std::string("artist"); |
| 264 | pair.key = new NymphType(key, true); |
| 265 | //val = new std::string(FileMetaInfo::getArtist()); |