1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef COMPONENT_EXT_MOVING_PHOTO_MOVING_PHOTO_CONTROLLER_H
17 #define COMPONENT_EXT_MOVING_PHOTO_MOVING_PHOTO_CONTROLLER_H
18 
19 #include <functional>
20 
21 #include "base/memory/ace_type.h"
22 
23 namespace OHOS::Ace::NG {
24 
25 class MovingPhotoController : public virtual AceType {
26     DECLARE_ACE_TYPE(MovingPhotoController, AceType)
27 
28 public:
29     MovingPhotoController() = default;
30     ~MovingPhotoController() override = default;
31 
32     using StartPlaybackImpl = std::function<void()>;
33     using StopPlaybackImpl = std::function<void()>;
34 
SetStartPlaybackImpl(StartPlaybackImpl && startPlaybackImpl)35     void SetStartPlaybackImpl(StartPlaybackImpl&& startPlaybackImpl)
36     {
37         startPlaybackImpl_ = std::move(startPlaybackImpl);
38     }
39 
StartPlayback()40     void StartPlayback()
41     {
42         if (startPlaybackImpl_) {
43             startPlaybackImpl_();
44         }
45     }
46 
SetStopPlaybackImpl(StopPlaybackImpl && stopPlaybackImpl)47     void SetStopPlaybackImpl(StopPlaybackImpl&& stopPlaybackImpl)
48     {
49         stopPlaybackImpl_ = std::move(stopPlaybackImpl);
50     }
51 
StopPlayback()52     void StopPlayback()
53     {
54         if (stopPlaybackImpl_) {
55             stopPlaybackImpl_();
56         }
57     }
58 
59 private:
60     StartPlaybackImpl startPlaybackImpl_;
61     StopPlaybackImpl stopPlaybackImpl_;
62 };
63 
64 } // namespace OHOS::Ace::NG
65 
66 #endif // COMPONENT_EXT_MOVING_PHOTO_MOVING_PHOTO_CONTROLLER_H