• 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 #include "core/components_ng/pattern/video/video_full_screen_node.h"
17 
18 #include "core/components_ng/pattern/image/image_pattern.h"
19 #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h"
20 #include "core/components_ng/pattern/video/video_full_screen_pattern.h"
21 
22 namespace OHOS::Ace::NG {
InitVideoFullScreenNode(const RefPtr<VideoNode> & video)23 void VideoFullScreenNode::InitVideoFullScreenNode(const RefPtr<VideoNode>& video)
24 {
25     CHECK_NULL_VOID(video);
26     if (video->HasMediaColumnNode()) {
27         auto mediaColumnId = GetMediaColumnId();
28         auto mediaColumNode = FrameNode::GetOrCreateFrameNode(
29             V2::COLUMN_ETS_TAG, mediaColumnId, []() { return AceType::MakeRefPtr<LinearLayoutPattern>(true); });
30         CHECK_NULL_VOID(mediaColumNode);
31         AddChild(mediaColumNode);
32     }
33     if (video->HasPreviewImageNode()) {
34         int32_t imageId = ElementRegister::GetInstance()->MakeUniqueId();
35         auto previewNode = FrameNode::GetOrCreateFrameNode(
36             V2::IMAGE_ETS_TAG, imageId, []() { return AceType::MakeRefPtr<ImagePattern>(); });
37         CHECK_NULL_VOID(previewNode);
38         AddChild(previewNode);
39     }
40     if (video->HasControllerRowNode()) {
41         int32_t controlRowId = GetControllerRowId();
42         auto fullScreenPattern = AceType::DynamicCast<VideoFullScreenPattern>(GetPattern());
43         CHECK_NULL_VOID(fullScreenPattern);
44         auto controlRowNode = fullScreenPattern->CreateControlBar(controlRowId);
45         CHECK_NULL_VOID(controlRowNode);
46         AddChild(controlRowNode);
47     }
48 }
49 
CreateFullScreenNode(const std::string & tag,int32_t nodeId,const RefPtr<Pattern> & pattern)50 RefPtr<VideoFullScreenNode> VideoFullScreenNode::CreateFullScreenNode(
51     const std::string& tag, int32_t nodeId, const RefPtr<Pattern>& pattern)
52 {
53     auto fullScreenNode = AceType::MakeRefPtr<VideoFullScreenNode>(tag, nodeId, pattern, false);
54     ElementRegister::GetInstance()->AddUINode(fullScreenNode);
55     fullScreenNode->InitializePatternAndContext();
56     return fullScreenNode;
57 }
58 } // namespace OHOS::Ace::NG