diff --git a/packages/video_player/video_player_ohos/ohos/src/main/ets/components/videoplayer/VideoPlayer.ets b/packages/video_player/video_player_ohos/ohos/src/main/ets/components/videoplayer/VideoPlayer.ets index 9ffe26bbe6f448ff857800a4b9c6b575bc0f1d42..3e6527f837e7320b45d325a885f4d56e25800c1c 100644 --- a/packages/video_player/video_player_ohos/ohos/src/main/ets/components/videoplayer/VideoPlayer.ets +++ b/packages/video_player/video_player_ohos/ohos/src/main/ets/components/videoplayer/VideoPlayer.ets @@ -182,8 +182,13 @@ export class VideoPlayer { this.sendBufferingUpdate(infoType, value); }); - this.avPlayer.on(Events.ERROR, (err: Object) => { + this.avPlayer.on(Events.ERROR, (err: BusinessError) => { Log.e(TAG, "avPlayer Events.ERROR: " + JSON.stringify(err)); + // 播放直播视频时,设置 loop 会报错,而 loop 一定会设置(video_player.dart 中初始化之后会 _applyLooping),所以屏蔽掉该报错 + // message: Unsupport Capability: The stream is live stream, not support loop + if(err.code == 801) { + return; + } this.avPlayer?.reset(); this.sendError(err); }) diff --git a/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets b/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets index 81ce600676bbda8ceb921c799e5e0dfa8937009c..27f7bfbf2bb8989bd642bfcdb55d1038403c900f 100644 --- a/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets +++ b/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets @@ -24,8 +24,13 @@ export struct OhosWebView { webView: WebViewPlatformView = this.params.platformView as WebViewPlatformView; controller: web_webview.WebviewController = this.webView.getController(); + @State textZoomRatio: number = this.webView.getWebSettings().getTextZoom(); + aboutToAppear() { this.webView.getWebSettings().setSupportZoom(true); + this.webView.getWebSettings().onTextZoomChanged((ratio: number) => { + this.textZoomRatio = ratio; + }); } build() { @@ -57,7 +62,7 @@ export struct OhosWebView { .overviewModeAccess(this.webView.getWebSettings().getLoadWithOverviewMode()) .wideViewModeAccess(this.webView.getWebSettings().getUseWideViewPort()) .fileAccess(this.webView.getWebSettings().getAllowFileAccess()) - .textZoomRatio(this.webView.getWebSettings().getTextZoom()) + .textZoomRatio(this.textZoomRatio) .onScroll(this.webView.onScroll) .onControllerAttached(this.webView.onControllerAttached) .overScrollMode(OverScrollMode.ALWAYS) diff --git a/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebSettingsHostApiImpl.ets b/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebSettingsHostApiImpl.ets index e7ee2d5d552e56ea11e5c5c6e75aab86940a633a..388420aeb00df29e62c1aaddf07c88a5710aed2e 100644 --- a/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebSettingsHostApiImpl.ets +++ b/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebSettingsHostApiImpl.ets @@ -69,6 +69,8 @@ export interface WebSettings { getTextZoom(): number; getUserAgentString(): Promise + + onTextZoomChanged(callback: (ratio: number) => void): void; } export class WebSettingsCreator { diff --git a/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebViewHostApiImpl.ets b/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebViewHostApiImpl.ets index f95b13179e6d3a04ce51bea64c8451392575ee3c..62f6209be37ed6ca99e07d3227de00ab61b1e5c9 100644 --- a/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebViewHostApiImpl.ets +++ b/packages/webview_flutter-v4.4.4/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebViewHostApiImpl.ets @@ -503,6 +503,8 @@ class WebSettingsImpl implements WebSettings { wideViewModeAccess: boolean = false; fileAccess : boolean = false; textZoomRatio : number = 0; + textZoomRatioCallback?: (ratio: number) => void; + constructor(webView: WebViewPlatformView) { this.webView = webView; @@ -605,6 +607,7 @@ class WebSettingsImpl implements WebSettings { setTextZoom(textZoom: number) { this.textZoomRatio = textZoom; + this.textZoomRatioCallback && this.textZoomRatioCallback(textZoom); } async getUserAgentString(): Promise { @@ -615,4 +618,9 @@ class WebSettingsImpl implements WebSettings { getTextZoom() : number{ return this.textZoomRatio; } + + onTextZoomChanged(callback: (ratio: number) => void): void { + this.textZoomRatioCallback = callback; + } + } \ No newline at end of file diff --git a/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets b/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets index 98cd5db97225c14ffc198a068f10ec28cf25c4f3..ec022032672ddb1d3d2492d80ef961c3f4a72f7a 100644 --- a/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets +++ b/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets @@ -24,8 +24,13 @@ export struct OhosWebView { webView: WebViewPlatformView = this.params.platformView as WebViewPlatformView; controller: web_webview.WebviewController = this.webView.getController(); + @State textZoomRatio: number = this.webView.getWebSettings().getTextZoom(); + aboutToAppear() { this.webView.getWebSettings().setSupportZoom(true); + this.webView.getWebSettings().onTextZoomChanged((ratio: number) => { + this.textZoomRatio = ratio; + }); } build() { @@ -57,7 +62,7 @@ export struct OhosWebView { .overviewModeAccess(this.webView.getWebSettings().getLoadWithOverviewMode()) .wideViewModeAccess(this.webView.getWebSettings().getUseWideViewPort()) .fileAccess(this.webView.getWebSettings().getAllowFileAccess()) - .textZoomRatio(this.webView.getWebSettings().getTextZoom()) + .textZoomRatio(this.textZoomRatio) .onScroll(this.webView.onScroll) .onControllerAttached(this.webView.onControllerAttached) .overScrollMode(OverScrollMode.ALWAYS) diff --git a/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebSettingsHostApiImpl.ets b/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebSettingsHostApiImpl.ets index 4ca37028cd176e2805caaad1d19dac34969545cf..1f7d17832e01d870e2bf2cd40a657e8556dffa2f 100644 --- a/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebSettingsHostApiImpl.ets +++ b/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebSettingsHostApiImpl.ets @@ -70,6 +70,8 @@ export interface WebSettings { getUserAgentString(): string; + + onTextZoomChanged(callback: (ratio: number) => void): void; } export class WebSettingsCreator { diff --git a/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebViewHostApiImpl.ets b/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebViewHostApiImpl.ets index cd83597ebfe12769f7cf5d77f14b0bf14c67940e..a46733dfe0669343f57b83d659b177a4376ea450 100644 --- a/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebViewHostApiImpl.ets +++ b/packages/webview_flutter/webview_flutter_ohos/ohos/src/main/ets/io.flutter.plugins/webview_flutter/WebViewHostApiImpl.ets @@ -535,6 +535,7 @@ class WebSettingsImpl implements WebSettings { wideViewModeAccess: boolean = false; fileAccess : boolean = false; textZoomRatio : number = 0; + textZoomRatioCallback?: (ratio: number) => void; constructor(webView: WebViewPlatformView) { this.webView = webView; @@ -638,6 +639,7 @@ class WebSettingsImpl implements WebSettings { setTextZoom(textZoom: number) { this.textZoomRatio = textZoom; + this.textZoomRatioCallback && this.textZoomRatioCallback(textZoom); } getUserAgentString(): string { @@ -649,4 +651,8 @@ class WebSettingsImpl implements WebSettings { return this.textZoomRatio; } + onTextZoomChanged(callback: (ratio: number) => void): void { + this.textZoomRatioCallback = callback; + } + } \ No newline at end of file