diff --git a/frameworks/innerkitsimpl/native/session/src/avplayback_state.cpp b/frameworks/innerkitsimpl/native/session/src/avplayback_state.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c4519c536ad595e17951edee2daafd25de0ce4b2 --- /dev/null +++ b/frameworks/innerkitsimpl/native/session/src/avplayback_state.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "avplayback_state.h" + +namespace OHOS::AVSession { +AVPlaybackState::AVPlaybackState() : Parcelable(true) +{} +AVPlaybackState::AVPlaybackState(int32_t state, float speed, int64_t etime, int64_t btime, int32_t loopMode, bool + isFavorite) + : state_(state), + speed_(speed), + etime_(etime), + btime_(btime), + loopMode_(loopMode), + isFavorite_(isFavorite) +{} + +bool AVPlaybackState::Marshalling(Parcel &parcel) +{ + return false; +} + +AVPlaybackState *AVPlaybackState::Unmarshalling(Parcel &parcel) +{ + return nullptr; +} + +void AVPlaybackState::SetState(int32_t state) +{ + state_ = state; +} + +void AVPlaybackState::SetSpeed(float speed) +{ + speed_ = speed; +} + +void AVPlaybackState::SetElapsedTime(int64_t time) +{ + elapsedTime_ = time; +} + +void AVPlaybackState::SetBufferredTime(int64_t time) +{ + bufferredTime_ = time; +} + +void AVPlaybackState::SetLoopMode(int32_t mode) +{ + loopMode_ = mode; +} + +void AVPlaybackState::SetFavorite(bool isFavorite) +{ + isFavorite_ = isFavorite; +} + +int32_t AVPlaybackState::GetState() +{ + return state_; +} + +float AVPlaybackState::GetSpeed() +{ + return speed_; +} + +int64_t AVPlaybackState::GetElapsedTime() +{ + return elapsedTime_; +} + +int64_t AVPlaybackState::GetBufferredTime() +{ + return bufferredTime_; +} + +int32_t AVPlaybackState::GetLoopMode() +{ + return loopMode_; +} + +bool AVPlaybackState::GetFavorite() +{ + return isFavorite_; +} +} // OHOS::AVSession diff --git a/interfaces/innerkits/native/session/include/avplayback_state.h b/interfaces/innerkits/native/session/include/avplayback_state.h new file mode 100644 index 0000000000000000000000000000000000000000..a7f103e45f20b01dd82f7d8bdc14e80187385816 --- /dev/null +++ b/interfaces/innerkits/native/session/include/avplayback_state.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_AVPLAYBACK_STATE_H +#define OHOS_AVPLAYBACK_STATE_H + +#include + +namespace OHOS::AVSession { +class AVPlaybackState : public Parcelable { +public: + enum { + PLAYBACK_STATE_INVALID = -1, + PLAYBACK_STATE_PREPARING, + PLAYBACK_STATE_PLAYING, + PLAYBACK_STATE_PAUSED, + PLAYBACK_STATE_STOPPED, + PLAYBACK_STATE_MAX + }; + AVPlaybackState() : Parcelable(true) {} + AVPlaybackState(int32_t state, float speed, int64_t etime, int64_t btime, int32_t loopMode, bool + isFavorite); + + static AVPlaybackState* Unmarshalling(Parcel& parcel); + bool Marshalling(Parcel& parcel); + + void SetState(int32_t state); + int32_t GetState(); + + void SetSpeed(float speed); + float GetSpeed(); + + void SetElapsedTime(int64_t time); + int64_t GetElapsedTime(); + + void SetBufferredTime(int64_t time); + int64_t GetBufferredTime(); + + void SetLoopMode(int32_t mode); + int32_t GetLoopMode(); + + void SetFavorite(bool isFavorite); + bool GetFavorite(); + +private: + int32_t state_; + float speed_; + int64_t elapsedTime_; + int64_t bufferredTime_; + int32_t loopMode_; + bool isFavorite_; +}; +} // namespace OHOS::AVSession +#endif // OHOS_AVPLAYBACK_STATE_H