Skip to content

Commit

Permalink
Set CurrentState & PlaybackSpeed in MediaPlayback cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinpan1 committed Aug 21, 2024
1 parent b3bcc66 commit 12dc458
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 12dc458

Please sign in to comment.