• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 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) = 0;
34     virtual void SetProgressRate(double progressRate) = 0;
35     virtual void SetPosterSourceInfo(const std::string& posterUrl) = 0;
36     virtual void SetPosterSourceByPixelMap(RefPtr<PixelMap>& pixMap) = 0;
37     virtual void SetMuted(bool muted) = 0;
38     virtual void SetAutoPlay(bool autoPlay) = 0;
39     virtual void SetControls(bool controls) = 0;
40     virtual void SetObjectFit(ImageFit objectFit) = 0;
41     virtual void SetLoop(bool loop) = 0;
42 
43     virtual void SetOnStart(VideoEventFunc&& onStart) = 0;
44     virtual void SetOnPause(VideoEventFunc&& onPause) = 0;
45     virtual void SetOnFinish(VideoEventFunc&& onFinish) = 0;
46     virtual void SetOnError(VideoEventFunc&& onError) = 0;
47     virtual void SetOnPrepared(VideoEventFunc&& onPrepared) = 0;
48     virtual void SetOnSeeking(VideoEventFunc&& onSeeking) = 0;
49     virtual void SetOnSeeked(VideoEventFunc&& onSeeked) = 0;
50     virtual void SetOnUpdate(VideoEventFunc&& onUpdate) = 0;
51     virtual void SetOnFullScreenChange(VideoEventFunc&& onFullScreenChange) = 0;
52 
53 private:
54     static std::unique_ptr<VideoModel> instance_;
55     static std::mutex mutex_;
56 };
57 
58 } // namespace OHOS::Ace
59 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_VIDEO_VIDEO_MODEL_H
60