Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 12dc458

Browse files
committedAug 21, 2024·
Set CurrentState & PlaybackSpeed in MediaPlayback cluster
1 parent b3bcc66 commit 12dc458

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎examples/chef/common/clusters/media-playback/MediaPlaybackManager.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ using chip::app::AttributeValueEncoder;
3333
using chip::app::CommandResponseHelper;
3434
using chip::Protocols::InteractionModel::Status;
3535

36+
MediaPlaybackManager::MediaPlaybackManager(chip::EndpointId endpoint) : mEndpoint(endpoint)
37+
{
38+
// Sync the attributes from attribute storage
39+
Status status = Attributes::CurrentState::Get(endpoint, &mCurrentState);
40+
if (Status::Success != status)
41+
{
42+
ChipLogError(Zcl, "Unable to save CurrentStage attribute, err:0x%x", to_underlying(status));
43+
mCurrentState = chip::app::Clusters::MediaPlayback::PlaybackStateEnum::kPlaying;
44+
}
45+
46+
status = Attributes::PlaybackSpeed::Get(endpoint, &mPlaybackSpeed);
47+
if (Status::Success != status)
48+
{
49+
ChipLogError(Zcl, "Unable to save PlaybackSpeed attribute, err:0x%x", to_underlying(status));
50+
mPlaybackSpeed = 1.0;
51+
}
52+
};
53+
3654
PlaybackStateEnum MediaPlaybackManager::HandleGetCurrentState()
3755
{
3856
return mCurrentState;

‎examples/chef/common/clusters/media-playback/MediaPlaybackManager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MediaPlaybackManager : public chip::app::Clusters::MediaPlayback::Delegate
3030
using Feature = chip::app::Clusters::MediaPlayback::Feature;
3131

3232
public:
33-
MediaPlaybackManager(chip::EndpointId endpoint) : mEndpoint(endpoint){};
33+
MediaPlaybackManager(chip::EndpointId endpoint);
3434

3535
chip::app::Clusters::MediaPlayback::PlaybackStateEnum HandleGetCurrentState() override;
3636
uint64_t HandleGetStartTime() override;

0 commit comments

Comments
 (0)
Please sign in to comment.