363 MH_INFO(
"Acquired display ON state");
369 MH_INFO(
"Released display ON state");
376 MH_INFO() <<
"Acquired new system state:" << state;
383 MH_INFO() <<
"Released system state:" << state;
388 onStateChanged(m_engine->state());
398 if (m_engine->state() == Engine::State::playing) {
399 MH_INFO(
"Streams changed, updating power/display locks");
400 request_power_state();
415 m_trackList->setCurrentPosition(m_engine->position());
416 Q_EMIT q->positionChanged();
431 const auto md = m_engine->trackMetadata();
432 update_mpris_metadata(md.first, md.second);
441 Q_EMIT q->endOfStream();
470 if (m_engine->state() != gstreamer::Engine::State::stopped)
472 MH_INFO(
"End of tracklist reached, stopping playback");
481 const bool auto_play = m_engine->playbackStatus() == media::Player::playing;
483 const QUrl uri = m_trackList->query_uri_for_track(id);
486 MH_INFO(
"Setting next track on playbin (on_go_to_track signal): %s",
487 qUtf8Printable(uri.toString()));
488 MH_INFO(
"\twith a Track::Id: %s", qUtf8Printable(id));
489 static const bool do_pipeline_reset = true;
490 m_engine->open_resource_for_uri(uri, do_pipeline_reset);
495 MH_DEBUG(
"Restoring playing state");
503 MH_TRACE(
"** Track was added, handling in PlayerImplementation");
504 if (!m_doingOpenUri && m_trackList->tracks().count() == 1)
505 open_first_track_from_tracklist(id);
507 update_mpris_properties();
511 q, [
this](
const QVector<QUrl> &tracks)
513 MH_TRACE(
"** Track was added, handling in PlayerImplementation");
520 if (not tracks.isEmpty() and m_trackList->tracks().count() == tracks.count())
521 open_first_track_from_tracklist(tracks.front().toString());
523 update_mpris_properties();
526 QObject::connect(m_trackList.data(),
528 q, [
this]() { update_mpris_properties(); });
530 QObject::connect(m_trackList.data(),
532 q, [
this]() { update_mpris_properties(); });
534 QObject::connect(m_trackList.data(),
536 q, [
this]() { update_mpris_properties(); });
538 QObject::connect(m_trackList.data(),
540 q, [
this]() { update_mpris_properties(); });
543 m_clientDeathObserver->registerForDeathNotifications(m_client);
544 QObject::connect(m_clientDeathObserver.data(),
546 q, [
this](
const media::Player::Client &died)
551 if (died.key != m_client.key)
554 m_abandonTimer.start();
557 m_abandonTimer.setSingleShot(
true);
558 m_abandonTimer.setInterval(1000);
559 m_abandonTimer.callOnTimeout(q, [
this]() { on_client_died(); });
561 m_wakeLockTimer.setSingleShot(
true);
562 int wakelockTimeout =
563 qEnvironmentVariableIsSet(
"MEDIA_HUB_WAKELOCK_TIMEOUT") ?
564 qEnvironmentVariableIntValue(
"MEDIA_HUB_WAKELOCK_TIMEOUT") : 4000;
565 m_wakeLockTimer.setInterval(wakelockTimeout);
566 m_wakeLockTimer.setTimerType(Qt::VeryCoarseTimer);
567 m_wakeLockTimer.callOnTimeout(q, [
this]() {