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