diff --git a/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp index 4a6dc687a7ef1e..1f370b13f4a364 100644 --- a/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp +++ b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp @@ -33,6 +33,24 @@ using chip::app::AttributeValueEncoder; using chip::app::CommandResponseHelper; using chip::Protocols::InteractionModel::Status; +MediaPlaybackManager::MediaPlaybackManager(chip::EndpointId endpoint) : mEndpoint(endpoint) +{ + // Sync the attributes from attribute storage + Status status = Attributes::CurrentState::Get(endpoint, &mCurrentState); + if (Status::Success != status) + { + ChipLogError(Zcl, "Unable to save CurrentStage attribute, err:0x%x", to_underlying(status)); + mCurrentState = chip::app::Clusters::MediaPlayback::PlaybackStateEnum::kPlaying; + } + + status = Attributes::PlaybackSpeed::Get(endpoint, &mPlaybackSpeed); + if (Status::Success != status) + { + ChipLogError(Zcl, "Unable to save PlaybackSpeed attribute, err:0x%x", to_underlying(status)); + mPlaybackSpeed = 1.0; + } +}; + PlaybackStateEnum MediaPlaybackManager::HandleGetCurrentState() { return mCurrentState; diff --git a/examples/chef/common/clusters/media-playback/MediaPlaybackManager.h b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.h index 33ba87c6b6e4a7..d083a6c2e5777d 100644 --- a/examples/chef/common/clusters/media-playback/MediaPlaybackManager.h +++ b/examples/chef/common/clusters/media-playback/MediaPlaybackManager.h @@ -30,7 +30,7 @@ class MediaPlaybackManager : public chip::app::Clusters::MediaPlayback::Delegate using Feature = chip::app::Clusters::MediaPlayback::Feature; public: - MediaPlaybackManager(chip::EndpointId endpoint) : mEndpoint(endpoint){}; + MediaPlaybackManager(chip::EndpointId endpoint); chip::app::Clusters::MediaPlayback::PlaybackStateEnum HandleGetCurrentState() override; uint64_t HandleGetStartTime() override;