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_MODEL_NG_H
17 #define COMPONENT_EXT_MOVING_PHOTO_MOVING_PHOTO_MODEL_NG_H
18 
19 #include "movingphoto_event_hub.h"
20 #include "movingphoto_controller.h"
21 #include "movingphoto_utils.h"
22 #include "core/components_ng/base/frame_node.h"
23 
24 namespace OHOS::Ace::NG {
25 
26 class ACE_EXPORT MovingPhotoModelNG {
27 public:
28     static MovingPhotoModelNG* GetInstance();
29     virtual ~MovingPhotoModelNG() = default;
30 
31     void Create(const RefPtr<MovingPhotoController>& controller);
32     void SetImageSrc(const std::string& src);
33     void SetImageSrcByPixelMap(RefPtr<PixelMap>& pixMap);
34     void SetMuted(bool muted);
35     void SetObjectFit(ImageFit objectFit);
36     void SetOnComplete(MovingPhotoEventFunc&& onComplete);
37     void SetOnStart(MovingPhotoEventFunc&& onStart);
38     void SetOnStop(MovingPhotoEventFunc&& onStop);
39     void SetOnPause(MovingPhotoEventFunc&& onPause);
40     void SetOnFinish(MovingPhotoEventFunc&& onFinish);
41     void SetOnError(MovingPhotoEventFunc&& onError);
42     void AutoPlayPeriod(int64_t startTime, int64_t endTime);
43     void AutoPlay(bool isAutoPlay);
44     void RepeatPlay(bool isRepeatPlay);
45     void SetMovingPhotoFormat(MovingPhotoFormat format);
46     void SetDynamicRangeMode(DynamicRangeMode rangeMode);
47 
48 private:
49     static std::unique_ptr<MovingPhotoModelNG> instance_;
50     static std::mutex mutex_;
51 };
52 
53 } // namespace OHOS::Ace::NG
54 #endif // COMPONENT_EXT_MOVING_PHOTO_MOVING_PHOTO_MODEL_NG_H
55