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