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