• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_PATTERNS_VIDEO_VIDEO_FULL_SCREEN_PATTERN_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_VIDEO_VIDEO_FULL_SCREEN_PATTERN_H
18 
19 #include "core/components/video/video_controller_v2.h"
20 #include "core/components_ng/manager/focus/focus_view.h"
21 #include "core/components_ng/pattern/video/video_node.h"
22 #include "core/components_ng/pattern/video/video_pattern.h"
23 
24 namespace OHOS::Ace::NG {
25 class VideoFullScreenPattern : public VideoPattern, public FocusView {
26     DECLARE_ACE_TYPE(VideoFullScreenPattern, VideoPattern);
27 
28 public:
29     VideoFullScreenPattern() = delete;
VideoFullScreenPattern(const RefPtr<VideoControllerV2> & videoController)30     explicit VideoFullScreenPattern(const RefPtr<VideoControllerV2>& videoController) : VideoPattern(videoController) {}
31     ~VideoFullScreenPattern() override = default;
32     void InitFullScreenParam(const RefPtr<VideoPattern>& video, const RefPtr<RenderSurface>& renderSurface,
33         const RefPtr<MediaPlayer>& mediaPlayer, const RefPtr<RenderContext>& context);
34     void RequestFullScreen(const RefPtr<VideoNode>& videoNode);
35 
36     bool ExitFullScreen();
37 
OnBackPressed()38     bool OnBackPressed() override
39     {
40         ExitFullScreen();
41         return true;
42     }
43 
GetRouteOfFirstScope()44     std::list<int32_t> GetRouteOfFirstScope() override
45     {
46         return {};
47     }
48 
GetVideoPattern()49     const RefPtr<VideoPattern> GetVideoPattern()
50     {
51         return videoPattern_.Upgrade();
52     }
53 
CreateEventHub()54     RefPtr<EventHub> CreateEventHub() override
55     {
56         return eventHub_;
57     }
58 
59     void SetEventHub(const RefPtr<EventHub>& eventHub);
60 
61     void UpdateState();
62 
CreateLayoutProperty()63     RefPtr<LayoutProperty> CreateLayoutProperty() override
64     {
65         auto videoPattern = videoPattern_.Upgrade();
66         if (!videoPattern) {
67             return MakeRefPtr<VideoLayoutProperty>();
68         }
69         auto layoutProperty = videoPattern->GetLayoutProperty<VideoLayoutProperty>()->Clone();
70         DynamicCast<VideoLayoutProperty>(layoutProperty)->fullScreenReset();
71         return layoutProperty;
72     }
73 
IsFullScreen()74     bool IsFullScreen() const override
75     {
76         // full screen state check from origin video fullScreenNodeId_
77         auto videoPattern = videoPattern_.Upgrade();
78         CHECK_NULL_RETURN(videoPattern, false);
79         return videoPattern->IsFullScreen();
80     }
81 
82 private:
83     WeakPtr<VideoPattern> videoPattern_;
84     RefPtr<EventHub> eventHub_;
85     RefPtr<GestureEventHub> originGestureEventHub_;
86 };
87 } // namespace OHOS::Ace::NG
88 #endif