|
a/src/mpdcli.cxx |
|
b/src/mpdcli.cxx |
|
... |
|
... |
241 |
LOGERR("MPDCli::checkForCommand: mpd_response_finish failed" << endl);
|
241 |
LOGERR("MPDCli::checkForCommand: mpd_response_finish failed" << endl);
|
242 |
}
|
242 |
}
|
243 |
|
243 |
|
244 |
return found;
|
244 |
return found;
|
245 |
}
|
245 |
}
|
|
|
246 |
|
|
|
247 |
bool MPDCli::saveState(MpdState& st, int seekms)
|
|
|
248 |
{
|
|
|
249 |
LOGDEB("MPDCli::saveState: seekms " << seekms << endl);
|
|
|
250 |
if (!updStatus()) {
|
|
|
251 |
LOGERR("MPDCli::saveState: can't retrieve current status\n");
|
|
|
252 |
return false;
|
|
|
253 |
}
|
|
|
254 |
st.status = m_stat;
|
|
|
255 |
if (seekms > 0) {
|
|
|
256 |
st.status.songelapsedms = seekms;
|
|
|
257 |
}
|
|
|
258 |
st.queue.clear();
|
|
|
259 |
if (!getQueueData(st.queue)) {
|
|
|
260 |
LOGERR("MPDCli::saveState: can't retrieve current playlist\n");
|
|
|
261 |
return false;
|
|
|
262 |
}
|
|
|
263 |
return true;
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
bool MPDCli::restoreState(const MpdState& st)
|
|
|
267 |
{
|
|
|
268 |
LOGDEB("MPDCli::restoreState: seekms " << st.status.songelapsedms << endl);
|
|
|
269 |
clearQueue();
|
|
|
270 |
for (unsigned int i = 0; i < st.queue.size(); i++) {
|
|
|
271 |
if (insert(st.queue[i].uri, i, st.queue[i]) < 0) {
|
|
|
272 |
LOGERR("MPDCli::restoreState: insert failed\n");
|
|
|
273 |
return false;
|
|
|
274 |
}
|
|
|
275 |
}
|
|
|
276 |
repeat(st.status.rept);
|
|
|
277 |
random(st.status.random);
|
|
|
278 |
single(st.status.single);
|
|
|
279 |
consume(st.status.consume);
|
|
|
280 |
// If songelapsedms is set, we have to start playing to restore it
|
|
|
281 |
if (st.status.songelapsedms > 0 ||
|
|
|
282 |
st.status.state == MpdStatus::MPDS_PLAY) {
|
|
|
283 |
play(st.status.songpos);
|
|
|
284 |
setVolume(st.status.volume);
|
|
|
285 |
if (st.status.songelapsedms > 0)
|
|
|
286 |
seek(st.status.songelapsedms/1000);
|
|
|
287 |
}
|
|
|
288 |
return true;
|
|
|
289 |
}
|
|
|
290 |
|
246 |
|
291 |
|
247 |
bool MPDCli::statSong(UpSong& upsong, int pos, bool isid)
|
292 |
bool MPDCli::statSong(UpSong& upsong, int pos, bool isid)
|
248 |
{
|
293 |
{
|
249 |
//LOGDEB1("MPDCli::statSong. isid " << isid << " id/pos " << pos << endl);
|
294 |
//LOGDEB1("MPDCli::statSong. isid " << isid << " id/pos " << pos << endl);
|
250 |
if (!ok())
|
295 |
if (!ok())
|