1 /* 2 * Copyright (c) 2021-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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_VIDEO_VIDEO_MODEL_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_VIDEO_VIDEO_MODEL_H 18 19 #include <mutex> 20 21 #include "base/image/pixel_map.h" 22 #include "core/components/common/layout/constants.h" 23 #include "core/components/video/video_controller_v2.h" 24 25 namespace OHOS::Ace { 26 using VideoEventFunc = std::function<void(const std::string&)>; 27 class ACE_FORCE_EXPORT VideoModel { 28 public: 29 static VideoModel* GetInstance(); 30 virtual ~VideoModel() = default; 31 32 virtual void Create(const RefPtr<VideoControllerV2>& videoController) = 0; 33 virtual void SetSrc(const std::string& src, const std::string& bundleName, const std::string& moduleName) = 0; 34 virtual void SetProgressRate(double progressRate) = 0; 35 virtual void SetPosterSourceInfo(const std::string& posterUrl, const std::string &bundleName, 36 const std::string &moduleName) = 0; 37 virtual void SetPosterSourceByPixelMap(RefPtr<PixelMap>& pixMap) = 0; 38 virtual void SetMuted(bool muted) = 0; 39 virtual void SetAutoPlay(bool autoPlay) = 0; 40 virtual void SetControls(bool controls) = 0; 41 virtual void SetObjectFit(ImageFit objectFit) = 0; 42 virtual void SetLoop(bool loop) = 0; 43 44 virtual void SetOnStart(VideoEventFunc&& onStart) = 0; 45 virtual void SetOnPause(VideoEventFunc&& onPause) = 0; 46 virtual void SetOnFinish(VideoEventFunc&& onFinish) = 0; 47 virtual void SetOnError(VideoEventFunc&& onError) = 0; 48 virtual void SetOnPrepared(VideoEventFunc&& onPrepared) = 0; 49 virtual void SetOnSeeking(VideoEventFunc&& onSeeking) = 0; 50 virtual void SetOnSeeked(VideoEventFunc&& onSeeked) = 0; 51 virtual void SetOnUpdate(VideoEventFunc&& onUpdate) = 0; 52 virtual void SetOnFullScreenChange(VideoEventFunc&& onFullScreenChange) = 0; SetOnStop(VideoEventFunc && onStop)53 virtual void SetOnStop(VideoEventFunc&& onStop) {}; EnableAnalyzer(bool enable)54 virtual void EnableAnalyzer(bool enable) {} SetImageAnalyzerConfig(void * config)55 virtual void SetImageAnalyzerConfig(void* config) {} SetImageAIOptions(void * options)56 virtual void SetImageAIOptions(void* options) {} 57 private: 58 static std::unique_ptr<VideoModel> instance_; 59 static std::mutex mutex_; 60 }; 61 62 } // namespace OHOS::Ace 63 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_VIDEO_VIDEO_MODEL_H 64