• 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 #include "frameworks/bridge/declarative_frontend/jsview/js_video.h"
17 
18 #include "base/log/ace_scoring_log.h"
19 #include "bridge/common/utils/engine_helper.h"
20 #include "bridge/declarative_frontend/jsview/js_utils.h"
21 #include "bridge/declarative_frontend/jsview/js_video_controller.h"
22 #include "bridge/declarative_frontend/jsview/models/video_model_impl.h"
23 #include "core/components_ng/base/view_stack_processor.h"
24 #include "core/components_ng/pattern/video/video_model_ng.h"
25 #ifdef SUPPORT_JSSTACK
26 #include "xpower_event_jsvm.h"
27 #endif
28 
29 namespace OHOS::Ace {
GetInstance()30 VideoModel* VideoModel::GetInstance()
31 {
32 #ifdef NG_BUILD
33     static NG::VideoModelNG instance;
34     return &instance;
35 #else
36     if (Container::IsCurrentUseNewPipeline()) {
37         static NG::VideoModelNG instance;
38         return &instance;
39     } else {
40         static Framework::VideoModelImpl instance;
41         return &instance;
42     }
43 #endif
44 }
45 } // namespace OHOS::Ace
46 
47 namespace OHOS::Ace::Framework {
48 
Create(const JSCallbackInfo & info)49 void JSVideo::Create(const JSCallbackInfo& info)
50 {
51     if (!info[0]->IsObject()) {
52         return;
53     }
54     JSRef<JSObject> videoObj = JSRef<JSObject>::Cast(info[0]);
55     JSRef<JSVal> srcValue = videoObj->GetProperty("src");
56     JSRef<JSVal> posterOptionsValue = videoObj->GetProperty("posterOptions");
57     JSRef<JSVal> previewUriValue = videoObj->GetProperty("previewUri");
58     JSRef<JSVal> currentProgressRateValue = videoObj->GetProperty("currentProgressRate");
59 
60     auto controllerObj = videoObj->GetProperty("controller");
61     RefPtr<VideoControllerV2> videoController = nullptr;
62     if (controllerObj->IsObject()) {
63         auto* jsVideoController = JSRef<JSObject>::Cast(controllerObj)->Unwrap<JSVideoController>();
64         if (jsVideoController) {
65             jsVideoController->SetInstanceId(Container::CurrentId());
66             videoController = jsVideoController->GetController();
67         }
68     }
69     VideoModel::GetInstance()->Create(videoController);
70 
71     // Parse the src, if it is invalid, use the empty string.
72     std::string bundleNameSrc;
73     std::string moduleNameSrc;
74     std::string src;
75     int32_t resId = 0;
76     ParseJsMediaWithBundleName(srcValue, src, bundleNameSrc, moduleNameSrc, resId);
77     VideoModel::GetInstance()->SetSrc(src, bundleNameSrc, moduleNameSrc);
78 
79     bool showFirstFrame = false;
80     ParseJsPosterOptions(posterOptionsValue, showFirstFrame);
81     VideoModel::GetInstance()->SetShowFirstFrame(showFirstFrame);
82 
83     // Parse the rate, if it is invalid, set it as 1.0.
84     double currentProgressRate = 1.0;
85     ParseJsDouble(currentProgressRateValue, currentProgressRate);
86     VideoModel::GetInstance()->SetProgressRate(currentProgressRate);
87 
88     auto aiOptions = videoObj->GetProperty("imageAIOptions");
89     if (aiOptions->IsObject()) {
90         auto engine = EngineHelper::GetCurrentEngine();
91         CHECK_NULL_VOID(engine);
92         NativeEngine* nativeEngine = engine->GetNativeEngine();
93         CHECK_NULL_VOID(nativeEngine);
94         panda::Local<JsiValue> value = aiOptions.Get().GetLocalHandle();
95         JSValueWrapper valueWrapper = value;
96         ScopeRAII scope(reinterpret_cast<napi_env>(nativeEngine));
97         napi_value optionsValue = nativeEngine->ValueToNapiValue(valueWrapper);
98         VideoModel::GetInstance()->SetImageAIOptions(optionsValue);
99     }
100 
101     std::string previewUri;
102     std::string bundleName;
103     std::string moduleName;
104     GetJsMediaBundleInfo(previewUriValue, bundleName, moduleName);
105     if (previewUriValue->IsUndefined() || previewUriValue->IsNull()) {
106         // When it is undefined, just set the empty image.
107         VideoModel::GetInstance()->SetPosterSourceInfo(previewUri, "", "");
108         return;
109     }
110     auto noPixMap = ParseJsMedia(previewUriValue, previewUri);
111     if (noPixMap) {
112         // Src is a string or resource
113         VideoModel::GetInstance()->SetPosterSourceInfo(previewUri, bundleName, moduleName);
114     } else {
115         // Src is a pixelmap.
116 #if defined(PIXEL_MAP_SUPPORTED)
117         RefPtr<PixelMap> pixMap = CreatePixelMapFromNapiValue(previewUriValue);
118         VideoModel::GetInstance()->SetPosterSourceByPixelMap(pixMap);
119 #endif
120     }
121 }
122 
ParseJsPosterOptions(const JSRef<JSVal> & jsValue,bool & result)123 bool JSVideo::ParseJsPosterOptions(const JSRef<JSVal>& jsValue, bool& result)
124 {
125     if (!jsValue->IsObject()) {
126         return false;
127     }
128     JSRef<JSObject> jsObj = JSRef<JSObject>::Cast(jsValue);
129     JSRef<JSVal> showFirstFrame = jsObj->GetProperty("showFirstFrame");
130     return ParseJsBool(showFirstFrame, result);
131 }
132 
JsMuted(const JSCallbackInfo & info)133 void JSVideo::JsMuted(const JSCallbackInfo& info)
134 {
135     bool muted = false;
136     if (info[0]->IsBoolean()) {
137         muted = info[0]->ToBoolean();
138 #ifdef SUPPORT_JSSTACK
139         HiviewDFX::ReportXPowerJsStackSysEvent(info.GetVm(), "VOLUME_CHANGE", "SRC=Video");
140 #endif
141     }
142     VideoModel::GetInstance()->SetMuted(muted);
143 }
144 
JsAutoPlay(const JSCallbackInfo & info)145 void JSVideo::JsAutoPlay(const JSCallbackInfo& info)
146 {
147     bool autoPlay = false;
148     if (info[0]->IsBoolean()) {
149         autoPlay = info[0]->ToBoolean();
150 #ifdef SUPPORT_JSSTACK
151         HiviewDFX::ReportXPowerJsStackSysEvent(info.GetVm(), "STREAM_CHANGE", "SRC=Video");
152 #endif
153     }
154     VideoModel::GetInstance()->SetAutoPlay(autoPlay);
155 }
156 
JsControls(const JSCallbackInfo & info)157 void JSVideo::JsControls(const JSCallbackInfo& info)
158 {
159     bool controls = true;
160     if (info[0]->IsBoolean()) {
161         controls = info[0]->ToBoolean();
162     }
163     VideoModel::GetInstance()->SetControls(controls);
164 }
165 
JsLoop(const JSCallbackInfo & info)166 void JSVideo::JsLoop(const JSCallbackInfo& info)
167 {
168     bool loop = false;
169     if (info[0]->IsBoolean()) {
170         loop = info[0]->ToBoolean();
171     }
172     VideoModel::GetInstance()->SetLoop(loop);
173 }
174 
JsObjectFit(const JSCallbackInfo & info)175 void JSVideo::JsObjectFit(const JSCallbackInfo& info)
176 {
177     ImageFit imageFit = ImageFit::COVER;
178     // The default value of Imagefit is FILL, but in the video the default value is COVER.
179     // So the default value need to be converted.
180     if (info[0]->IsUndefined()) {
181         VideoModel::GetInstance()->SetObjectFit(imageFit);
182         return;
183     }
184     if (info[0]->IsNumber()) {
185         imageFit = static_cast<ImageFit>(info[0]->ToNumber<int>());
186     }
187     VideoModel::GetInstance()->SetObjectFit(imageFit);
188 }
189 
JsSurfaceBackgroundColor(const JSCallbackInfo & info)190 void JSVideo::JsSurfaceBackgroundColor(const JSCallbackInfo& info)
191 {
192     Color backgroundColor = Color::BLACK;
193     if (ParseColorMetricsToColor(info[0], backgroundColor) && backgroundColor != Color::TRANSPARENT) {
194         backgroundColor = Color::BLACK;
195     }
196 
197     VideoModel::GetInstance()->SetSurfaceBackgroundColor(backgroundColor);
198 }
199 
JsSetShortcutKeyEnabled(const JSCallbackInfo & info)200 void JSVideo::JsSetShortcutKeyEnabled(const JSCallbackInfo& info)
201 {
202     VideoModel::GetInstance()->SetShortcutKeyEnabled(info[0]->IsBoolean() ? info[0]->ToBoolean() : false);
203 }
204 
JsOnStart(const JSCallbackInfo & info)205 void JSVideo::JsOnStart(const JSCallbackInfo& info)
206 {
207     if (!info[0]->IsFunction()) {
208         return;
209     }
210     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
211     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
212     auto onStart = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
213                        const std::string& param) {
214         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
215         ACE_SCORING_EVENT("Video.onStart");
216         PipelineContext::SetCallBackNode(node);
217         std::vector<std::string> keys = { "start" };
218         func->Execute(keys, param);
219     };
220     VideoModel::GetInstance()->SetOnStart(std::move(onStart));
221 }
222 
JsOnPause(const JSCallbackInfo & info)223 void JSVideo::JsOnPause(const JSCallbackInfo& info)
224 {
225     if (!info[0]->IsFunction()) {
226         return;
227     }
228     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
229     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
230     auto onPause = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
231                        const std::string& param) {
232         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
233         ACE_SCORING_EVENT("Video.onPause");
234         PipelineContext::SetCallBackNode(node);
235         std::vector<std::string> keys = { "pause" };
236         func->Execute(keys, param);
237     };
238     VideoModel::GetInstance()->SetOnPause(std::move(onPause));
239 }
240 
JsOnFinish(const JSCallbackInfo & info)241 void JSVideo::JsOnFinish(const JSCallbackInfo& info)
242 {
243     if (!info[0]->IsFunction()) {
244         return;
245     }
246     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
247     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
248     auto onFinish = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
249                         const std::string& param) {
250         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
251         ACE_SCORING_EVENT("Video.onFinish");
252         PipelineContext::SetCallBackNode(node);
253         std::vector<std::string> keys = { "finish" };
254         func->Execute(keys, param);
255     };
256     VideoModel::GetInstance()->SetOnFinish(std::move(onFinish));
257 }
258 
JsOnStop(const JSCallbackInfo & info)259 void JSVideo::JsOnStop(const JSCallbackInfo& info)
260 {
261     if (!info[0]->IsFunction()) {
262         return;
263     }
264     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
265     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
266     auto onStop = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
267                         const std::string& param) {
268         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
269         ACE_SCORING_EVENT("Video.onStop");
270         PipelineContext::SetCallBackNode(node);
271         std::vector<std::string> keys = { "stop" };
272         func->Execute(keys, param);
273     };
274     VideoModel::GetInstance()->SetOnStop(std::move(onStop));
275 }
276 
JsOnFullscreenChange(const JSCallbackInfo & info)277 void JSVideo::JsOnFullscreenChange(const JSCallbackInfo& info)
278 {
279     if (!info[0]->IsFunction()) {
280         return;
281     }
282     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
283     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
284     auto OnFullScreenChange = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
285                                   const std::string& param) {
286         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
287         ACE_SCORING_EVENT("Video.OnFullScreenChange");
288         PipelineContext::SetCallBackNode(node);
289         std::vector<std::string> keys = { "fullscreen" };
290         func->Execute(keys, param);
291     };
292     VideoModel::GetInstance()->SetOnFullScreenChange(std::move(OnFullScreenChange));
293 }
294 
JsOnPrepared(const JSCallbackInfo & info)295 void JSVideo::JsOnPrepared(const JSCallbackInfo& info)
296 {
297     if (!info[0]->IsFunction()) {
298         return;
299     }
300     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
301     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
302     auto onPrepared = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
303                           const std::string& param) {
304         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
305         ACE_SCORING_EVENT("Video.onPrepared");
306         PipelineContext::SetCallBackNode(node);
307         std::vector<std::string> keys = { "duration" };
308         func->Execute(keys, param);
309     };
310     VideoModel::GetInstance()->SetOnPrepared(std::move(onPrepared));
311 }
312 
JsOnSeeking(const JSCallbackInfo & info)313 void JSVideo::JsOnSeeking(const JSCallbackInfo& info)
314 {
315     if (!info[0]->IsFunction()) {
316         return;
317     }
318     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
319     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
320     auto onSeeking = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
321                          const std::string& param) {
322         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
323         ACE_SCORING_EVENT("Video.onSeeking");
324         PipelineContext::SetCallBackNode(node);
325         std::vector<std::string> keys = { "time" };
326         func->Execute(keys, param);
327     };
328     VideoModel::GetInstance()->SetOnSeeking(std::move(onSeeking));
329 }
330 
JsOnSeeked(const JSCallbackInfo & info)331 void JSVideo::JsOnSeeked(const JSCallbackInfo& info)
332 {
333     if (!info[0]->IsFunction()) {
334         return;
335     }
336     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
337     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
338     auto onSeeked = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
339                         const std::string& param) {
340         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
341         ACE_SCORING_EVENT("Video.onSeeked");
342         PipelineContext::SetCallBackNode(node);
343         std::vector<std::string> keys = { "time" };
344         func->Execute(keys, param);
345     };
346     VideoModel::GetInstance()->SetOnSeeked(std::move(onSeeked));
347 }
348 
JsOnUpdate(const JSCallbackInfo & info)349 void JSVideo::JsOnUpdate(const JSCallbackInfo& info)
350 {
351     if (!info[0]->IsFunction()) {
352         return;
353     }
354     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
355     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
356     auto onUpdate = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
357                         const std::string& param) {
358         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
359         ACE_SCORING_EVENT("Video.onUpdate");
360         PipelineContext::SetCallBackNode(node);
361         std::vector<std::string> keys = { "time" };
362         func->Execute(keys, param);
363     };
364     VideoModel::GetInstance()->SetOnUpdate(std::move(onUpdate));
365 }
366 
JsOnError(const JSCallbackInfo & info)367 void JSVideo::JsOnError(const JSCallbackInfo& info)
368 {
369     if (!info[0]->IsFunction()) {
370         return;
371     }
372     auto jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
373     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
374     auto onError = [execCtx = info.GetExecutionContext(), func = std::move(jsFunc), node = targetNode](
375                        const std::string& param) {
376         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
377         ACE_SCORING_EVENT("Video.onError");
378         PipelineContext::SetCallBackNode(node);
379         std::vector<std::string> keys = { "error" };
380         func->Execute(keys, param);
381     };
382     VideoModel::GetInstance()->SetOnError(std::move(onError));
383 }
384 
GetEventMarker(const JSCallbackInfo & info,const std::vector<std::string> & keys)385 EventMarker JSVideo::GetEventMarker(const JSCallbackInfo& info, const std::vector<std::string>& keys)
386 {
387     if (!info[0]->IsFunction()) {
388         return EventMarker();
389     }
390 
391     RefPtr<JsFunction> jsFunc = AceType::MakeRefPtr<JsFunction>(JSRef<JSObject>(), JSRef<JSFunc>::Cast(info[0]));
392     WeakPtr<NG::FrameNode> targetNode = AceType::WeakClaim(NG::ViewStackProcessor::GetInstance()->GetMainFrameNode());
393     auto eventMarker = EventMarker([execCtx = info.GetExecutionContext(), func = std::move(jsFunc), keys,
394                                        node = targetNode](const std::string& param) {
395         JAVASCRIPT_EXECUTION_SCOPE_WITH_CHECK(execCtx);
396         PipelineContext::SetCallBackNode(node);
397         func->Execute(keys, param);
398     });
399     return eventMarker;
400 }
401 
EnableAnalyzer(bool enable)402 void JSVideo::EnableAnalyzer(bool enable)
403 {
404     VideoModel::GetInstance()->EnableAnalyzer(enable);
405 }
406 
AnalyzerConfig(const JSCallbackInfo & info)407 void JSVideo::AnalyzerConfig(const JSCallbackInfo& info)
408 {
409     auto configParams = info[0];
410     if (configParams->IsNull() || !configParams->IsObject()) {
411         return;
412     }
413     auto engine = EngineHelper::GetCurrentEngine();
414     CHECK_NULL_VOID(engine);
415     NativeEngine* nativeEngine = engine->GetNativeEngine();
416     panda::Local<JsiValue> value = configParams.Get().GetLocalHandle();
417     JSValueWrapper valueWrapper = value;
418     ScopeRAII scope(reinterpret_cast<napi_env>(nativeEngine));
419     napi_value nativeValue = nativeEngine->ValueToNapiValue(valueWrapper);
420     VideoModel::GetInstance()->SetImageAnalyzerConfig(nativeValue);
421 }
422 
JSBind(BindingTarget globalObj)423 void JSVideo::JSBind(BindingTarget globalObj)
424 {
425     JSClass<JSVideo>::Declare("Video");
426     MethodOptions opt = MethodOptions::NONE;
427     JSClass<JSVideo>::StaticMethod("create", &JSVideo::Create, opt);
428     JSClass<JSVideo>::StaticMethod("muted", &JSVideo::JsMuted, opt);
429     JSClass<JSVideo>::StaticMethod("autoPlay", &JSVideo::JsAutoPlay, opt);
430     JSClass<JSVideo>::StaticMethod("controls", &JSVideo::JsControls, opt);
431     JSClass<JSVideo>::StaticMethod("loop", &JSVideo::JsLoop, opt);
432     JSClass<JSVideo>::StaticMethod("objectFit", &JSVideo::JsObjectFit, opt);
433     JSClass<JSVideo>::StaticMethod("surfaceBackgroundColor", &JSVideo::JsSurfaceBackgroundColor, opt);
434     JSClass<JSVideo>::StaticMethod("enableShortcutKey", &JSVideo::JsSetShortcutKeyEnabled, opt);
435 
436     JSClass<JSVideo>::StaticMethod("onStart", &JSVideo::JsOnStart);
437     JSClass<JSVideo>::StaticMethod("onPause", &JSVideo::JsOnPause);
438     JSClass<JSVideo>::StaticMethod("onFinish", &JSVideo::JsOnFinish);
439     JSClass<JSVideo>::StaticMethod("onFullscreenChange", &JSVideo::JsOnFullscreenChange);
440     JSClass<JSVideo>::StaticMethod("onPrepared", &JSVideo::JsOnPrepared);
441     JSClass<JSVideo>::StaticMethod("onSeeking", &JSVideo::JsOnSeeking);
442     JSClass<JSVideo>::StaticMethod("onSeeked", &JSVideo::JsOnSeeked);
443     JSClass<JSVideo>::StaticMethod("onUpdate", &JSVideo::JsOnUpdate);
444     JSClass<JSVideo>::StaticMethod("onError", &JSVideo::JsOnError);
445     JSClass<JSVideo>::StaticMethod("onStop", &JSVideo::JsOnStop);
446     JSClass<JSVideo>::StaticMethod("enableAnalyzer", &JSVideo::EnableAnalyzer);
447     JSClass<JSVideo>::StaticMethod("analyzerConfig", &JSVideo::AnalyzerConfig);
448 
449     JSClass<JSVideo>::StaticMethod("onTouch", &JSInteractableView::JsOnTouch);
450     JSClass<JSVideo>::StaticMethod("onHover", &JSInteractableView::JsOnHover);
451     JSClass<JSVideo>::StaticMethod("onKeyEvent", &JSInteractableView::JsOnKey);
452     JSClass<JSVideo>::StaticMethod("onDeleteEvent", &JSInteractableView::JsOnDelete);
453     JSClass<JSVideo>::StaticMethod("onClick", &JSInteractableView::JsOnClick);
454     JSClass<JSVideo>::StaticMethod("onAttach", &JSInteractableView::JsOnAttach);
455     JSClass<JSVideo>::StaticMethod("onAppear", &JSInteractableView::JsOnAppear);
456     JSClass<JSVideo>::StaticMethod("onDetach", &JSInteractableView::JsOnDetach);
457     JSClass<JSVideo>::StaticMethod("onDisAppear", &JSInteractableView::JsOnDisAppear);
458     JSClass<JSVideo>::StaticMethod("remoteMessage", &JSInteractableView::JsCommonRemoteMessage);
459     // override method
460     JSClass<JSVideo>::StaticMethod("opacity", &JSViewAbstract::JsOpacityPassThrough);
461     JSClass<JSVideo>::StaticMethod("transition", &JSViewAbstract::JsTransitionPassThrough);
462     JSClass<JSVideo>::InheritAndBind<JSViewAbstract>(globalObj);
463 }
464 
465 } // namespace OHOS::Ace::Framework
466