diff --git a/AppScope/app.json5 b/AppScope/app.json5 index 2b5d480736b59224a2e891f182f5c73add037649..ac33cf588186c1cb113b2124aaf0a3e290e8e0f2 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -3,7 +3,7 @@ "bundleName": "com.openharmony.videotrimmer", "vendor": "example", "versionCode": 1000000, - "versionName": "1.0.1", + "versionName": "1.1.0", "icon": "$media:app_icon", "label": "$string:app_name" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f78d4a8439bd287fc50a8c336dfc1a4a23c218..e8551d7e05465f86147d21b034b261b2de4a043b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.1.0 +- 适配V2装饰器 + ## 1.0.1 - ArkTs语法适配 - 适配DevEco Studio: 4.1 Canary2 (4.1.3.322), SDK: API11 (4.1.3.1) diff --git a/README.md b/README.md index b96c17466eefca13d9d08f7675e09847b91fbd38..a7dca092d1ccf93c4ee3358a95571a9467ce6a97 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ OpenHarmony ohpm环境配置等更多内容,请参考 [如何安装OpenHarmony build() { Row() { Column() { - VideoTrimmerView( {videoTrimmerOption:$videoTrimmerOption}) + VideoTrimmerView( {videoTrimmerOption:this.videoTrimmerOption!!}) } .width('100%') } @@ -126,7 +126,7 @@ build() { ## 约束与限制 在下述版本验证通过: -DevEco Studio: 4.1 Canary2 (4.1.3.322), SDK: API11 (4.1.3.1) +DevEco Studio: NEXT Developer Beta3-5.0.3.530, SDK: API12 (5.0.0.35) HSP场景适配: diff --git a/build-profile.json5 b/build-profile.json5 index c94ae0173aff0f874087156626f92dbd8d7ab82c..09c7b856b80d8be7ff02bd498a3e7df212144ec0 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -4,8 +4,8 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": 11, - "compatibleSdkVersion": 11, + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, } ] }, diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index 4071f5eee0ebd088c1c5b64f59851d0314b76b9b..bb35ad0879300472f19c6c0f883ef0e3cea9325d 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -5,7 +5,7 @@ "name": "entry", "description": "Please describe the basic information.", "main": "", - "version": "1.0.1", + "version": "1.1.0", "dependencies": { '@ohos/videotrimmer': 'file:../videotrimmer', '@ohos/ijkplayer': '2.0.3-rc.1' diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 8936a866f4d95225aa53cc1be597263a821f08e1..b9a02ca842529e122085fa8b6c53c450521d0e1f 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -16,17 +16,17 @@ import {FileUtils} from './FileUtils' import router from '@ohos.router' import { IjkMediaPlayer, OnCompletionListener, OnErrorListener } from "@ohos/ijkplayer" @Entry -@Component +@ComponentV2 struct Index { - @State hint1 : string ='是否存入成功' - @State inFilePath:string = '' - @State outFilePath:string = '' - @State outFilePath2:string = '' + @Local hint1 : string ='是否存入成功' + @Local inFilePath:string = '' + @Local outFilePath:string = '' + @Local outFilePath2:string = '' myVideoController:VideoController = new VideoController(); - @State xComponentId: string = "xid" + Math.random(); - @State needInit: boolean = true; - @State hasContext: boolean = false; - @State isPlaying: boolean = false; + @Local xComponentId: string = "xid" + Math.random(); + @Local needInit: boolean = true; + @Local hasContext: boolean = false; + @Local isPlaying: boolean = false; private xComponentContext: object | null = null; private player: IjkMediaPlayer | null = null; diff --git a/entry/src/main/ets/pages/Video.ets b/entry/src/main/ets/pages/Video.ets index 14df79231e58c36efcd5fc5854d69bd2cb57ac20..9c32562703301868a9d1d6f36ddb43245a18043f 100644 --- a/entry/src/main/ets/pages/Video.ets +++ b/entry/src/main/ets/pages/Video.ets @@ -21,30 +21,30 @@ import router from '@ohos.router' import image from '@ohos.multimedia.image' @Entry -@Component +@ComponentV2 struct Video1 { - @State cropHint: string = '视频裁剪中...' + @Local cropHint: string = '视频裁剪中...' /* 同步和config设置项目 */ - @StorageLink('maxtime') maxtime: string = '10' - @StorageLink('mintime') mintime: string = '3' - @StorageLink('max_countrange') max_countrange: string = '10' - @StorageLink('thumb_width') thumb_width: string = '30' - @StorageLink('pad_width') pad_width: string = '10' - @StorageLink('is_setholder') is_setholder: string = '0' - @StorageLink('is_setbg') is_setbg: string = '0' + @Provider('maxtime') maxtime: string = '10' + @Provider('mintime') mintime: string = '3' + @Provider('max_countrange') max_countrange: string = '10' + @Provider('thumb_width') thumb_width: string = '30' + @Provider('pad_width') pad_width: string = '10' + @Provider('is_setholder') is_setholder: string = '0' + @Provider('is_setbg') is_setbg: string = '0' /* config end */ pixelMapHolder?: PixelMap = undefined dialogController: CustomDialogController = new CustomDialogController({ builder: CustomDialogExample({ - textValue: $cropHint + // textValue: $cropHint }), autoCancel: false, alignment: DialogAlignment.Center, offset: { dx: 0, dy: 0 }, customStyle: false }) - @State visibleTrim: boolean = false; + @Local visibleTrim: boolean = false; initListener: VideoTrimListener = { onStartTrim: () => { }, @@ -59,15 +59,15 @@ struct Video1 { onFinishLoad: () => { } } - @State videoTrimmerOption: VideoTrimmerOption = new VideoTrimmerOption() - @State isVideoPageHidden: boolean = false + @Local videoTrimmerOption: VideoTrimmerOption = new VideoTrimmerOption() + @Local isVideoPageHidden: boolean = false filePath: string = '' outPath: string = '' build() { Row() { Column() { - VideoTrimmerView({ videoTrimmerOption: $videoTrimmerOption }) + VideoTrimmerView({ videoTrimmerOption: this.videoTrimmerOption!! }) } .width('100%') @@ -173,7 +173,7 @@ struct Video1 { @CustomDialog struct CustomDialogExample { controller: CustomDialogController - @Link textValue: string + // @Link textValue: string build() { Stack() { diff --git a/entry/src/main/ets/pages/configPage.ets b/entry/src/main/ets/pages/configPage.ets index 797984b8cd8c5cc5ca60e7dae42cb3ce4523c8a9..d4ebbd6773d3039b53f109a077d1301206755d06 100644 --- a/entry/src/main/ets/pages/configPage.ets +++ b/entry/src/main/ets/pages/configPage.ets @@ -15,16 +15,16 @@ import router from '@ohos.router'; @Entry -@Component +@ComponentV2 struct ConfigPage{ - @State message: string = '配置Option' - @State maxtime: string = '10' - @State mintime: string = '3' - @State max_countrange: string = '10' - @State thumb_width:string = '30' - @State pad_width: string = '30' - @State is_setholder:string = '0' - @State is_setbg:string = '0' + @Local message: string = '配置Option' + @Consumer() maxtime: string = '10' + @Consumer() mintime: string = '3' + @Consumer() max_countrange: string = '10' + @Consumer() thumb_width:string = '30' + @Consumer() pad_width: string = '30' + @Consumer() is_setholder:string = '0' + @Consumer() is_setbg:string = '0' build(){ Row(){ diff --git a/oh-package.json5 b/oh-package.json5 index d952109660c31dd5029763f5fd2b2da2847e8f64..d48d82350c13c048e87b928c989684c0ce4ccc69 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -7,6 +7,6 @@ "name": "myapplication", "description": "Please describe the basic information.", "main": "", - "version": "1.0.1", + "version": "1.1.0", "dependencies": {} } diff --git a/sharedlibrary/oh-package.json5 b/sharedlibrary/oh-package.json5 index 79679fe4a21e2892a4119886f7dc51b968863886..e5cc6ba08d6bd6aaa734e6747eced40b349c4380 100644 --- a/sharedlibrary/oh-package.json5 +++ b/sharedlibrary/oh-package.json5 @@ -1,6 +1,6 @@ { "name": "sharedlibrary", - "version": "1.0.1", + "version": "1.1.0", "description": "Please describe the basic information.", "main": "./src/main/ets/Index.ets", "author": "", diff --git a/sharedlibrary/src/main/ets/pages/Index.ets b/sharedlibrary/src/main/ets/pages/Index.ets index 20918e4e239889c10f1500923b410c4140410939..f18022b24b2c372cc3484558ca2e24fa2249d39f 100644 --- a/sharedlibrary/src/main/ets/pages/Index.ets +++ b/sharedlibrary/src/main/ets/pages/Index.ets @@ -18,17 +18,17 @@ import common from '@ohos.app.ability.common' import { IjkMediaPlayer, OnCompletionListener, OnErrorListener } from "@ohos/ijkplayer" @Entry -@Component +@ComponentV2 struct Index { - @State hint1: string = '是否存入成功' - @State inFilePath: string = '' - @State outFilePath: string = '' - @State outFilePath2: string = '' - myVideoController: VideoController = new VideoController(); - @State xComponentId: string = "xid" + Math.random(); - @State needInit: boolean = true; - @State hasContext: boolean = false; - @State isPlaying: boolean = false; + @Local hint1: string ='是否存入成功' + @Local inFilePath:string = '' + @Local outFilePath:string = '' + @Local outFilePath2:string = '' + myVideoController:VideoController = new VideoController(); + @Local xComponentId: string = "xid" + Math.random(); + @Local needInit: boolean = true; + @Local hasContext: boolean = false; + @Local isPlaying: boolean = false; private xComponentContext: object | null = null; private player: IjkMediaPlayer | null = null; diff --git a/sharedlibrary/src/main/ets/pages/Video.ets b/sharedlibrary/src/main/ets/pages/Video.ets index 16fcf72aa5dfa9aa9cc2c0b925b49c6eba590800..2bf80b2eb3a1aa0ec73b64af5724ca11f61262e7 100644 --- a/sharedlibrary/src/main/ets/pages/Video.ets +++ b/sharedlibrary/src/main/ets/pages/Video.ets @@ -22,30 +22,30 @@ import image from '@ohos.multimedia.image' import common from '@ohos.app.ability.common' @Entry -@Component +@ComponentV2 struct Video1 { - @State cropHint: string = '视频裁剪中...' + @Local cropHint: string = '视频裁剪中...' /* 同步和config设置项目 */ - @StorageLink('maxtime') maxtime: string = '10' - @StorageLink('mintime') mintime: string = '3' - @StorageLink('max_countrange') max_countrange: string = '10' - @StorageLink('thumb_width') thumb_width: string = '30' - @StorageLink('pad_width') pad_width: string = '10' - @StorageLink('is_setholder') is_setholder: string = '0' - @StorageLink('is_setbg') is_setbg: string = '0' + @Provider('maxtime') maxtime: string = '10' + @Provider('mintime') mintime: string = '3' + @Provider('max_countrange') max_countrange: string = '10' + @Provider('thumb_width') thumb_width: string = '30' + @Provider('pad_width') pad_width: string = '10' + @Provider('is_setholder') is_setholder: string = '0' + @Provider('is_setbg') is_setbg: string = '0' /* config end */ pixelMapHolder?: PixelMap = undefined dialogController: CustomDialogController = new CustomDialogController({ builder: CustomDialogExample({ - textValue: $cropHint + // textValue: $cropHint }), autoCancel: false, alignment: DialogAlignment.Center, offset: { dx: 0, dy: 0 }, customStyle: false }) - @State visibleTrim: boolean = false; + @Local visibleTrim: boolean = false; initListener: VideoTrimListener = { onStartTrim: () => { }, @@ -60,15 +60,15 @@ struct Video1 { onFinishLoad: () => { } } - @State videoTrimmerOption: VideoTrimmerOption = new VideoTrimmerOption() - @State isVideoPageHidden: boolean = false + @Local videoTrimmerOption: VideoTrimmerOption = new VideoTrimmerOption() + @Local isVideoPageHidden: boolean = false filePath: string = '' outPath: string = '' build() { Row() { Column() { - VideoTrimmerView({ videoTrimmerOption: $videoTrimmerOption }) + VideoTrimmerView({ videoTrimmerOption: this.videoTrimmerOption }) } .width('100%') @@ -173,7 +173,7 @@ struct Video1 { @CustomDialog struct CustomDialogExample { controller: CustomDialogController - @Link textValue: string + // @Link textValue: string build() { Stack() { diff --git a/sharedlibrary/src/main/ets/pages/configPage.ets b/sharedlibrary/src/main/ets/pages/configPage.ets index 797984b8cd8c5cc5ca60e7dae42cb3ce4523c8a9..d4ebbd6773d3039b53f109a077d1301206755d06 100644 --- a/sharedlibrary/src/main/ets/pages/configPage.ets +++ b/sharedlibrary/src/main/ets/pages/configPage.ets @@ -15,16 +15,16 @@ import router from '@ohos.router'; @Entry -@Component +@ComponentV2 struct ConfigPage{ - @State message: string = '配置Option' - @State maxtime: string = '10' - @State mintime: string = '3' - @State max_countrange: string = '10' - @State thumb_width:string = '30' - @State pad_width: string = '30' - @State is_setholder:string = '0' - @State is_setbg:string = '0' + @Local message: string = '配置Option' + @Consumer() maxtime: string = '10' + @Consumer() mintime: string = '3' + @Consumer() max_countrange: string = '10' + @Consumer() thumb_width:string = '30' + @Consumer() pad_width: string = '30' + @Consumer() is_setholder:string = '0' + @Consumer() is_setbg:string = '0' build(){ Row(){ diff --git a/videotrimmer/oh-package.json5 b/videotrimmer/oh-package.json5 index 39bb49526fd6c5754188eb164618d2b8008b03d1..90894184cc91ebb1eeea04622fd6da3703aa0d62 100644 --- a/videotrimmer/oh-package.json5 +++ b/videotrimmer/oh-package.json5 @@ -14,7 +14,7 @@ "main": "index.ets", "repository": "https://gitee.com/openharmony-sig/ohos_video_trimmer", "type": "module", - "version": "1.0.1", + "version": "1.1.0", "dependencies": { '@ohos/mp4parser': '^2.0.3-rc.0' }, diff --git a/videotrimmer/src/main/ets/components/RangeSeekBarView.ets b/videotrimmer/src/main/ets/components/RangeSeekBarView.ets index ae86156284951dca2a4e4c764fb921f900f64edc..5af1586a05ea1a26766365a33953acaa01bb6696 100644 --- a/videotrimmer/src/main/ets/components/RangeSeekBarView.ets +++ b/videotrimmer/src/main/ets/components/RangeSeekBarView.ets @@ -40,38 +40,66 @@ export class RangSeekBarOption { mPaddingTopBottom: number = 10 } -@Component +@ComponentV2 export struct RangeSeekBarView { - @Watch('watchRangSeekBarOption') @Link mRangSeekBarOption: RangSeekBarOption - @Watch('watchMediaPlayerStatus') @Link mMediaPlayerStatus: MediaPlayerStatus - @Link mRangSeekBarListener: RangSeekBarListener - @State leftThumbWidth: number = 30 - @State rightThumbWidth: number = 30 - @State topPaddingWidth: number = 10; - @State bottomPaddingWidth: number = 10; - @State transparentWidth: number = 0 + @Param @Require mRangSeekBarOption: RangSeekBarOption + @Monitor('mRangSeekBarOption') + watchRangSeekBarOption() { + this.configUI() + this.initUIRange() + } + @Param @Require mMediaPlayerStatus: MediaPlayerStatus + @Monitor('mMediaPlayerStatus') + watchMediaPlayerStatus() { + if (this.mMediaPlayerStatus) { + this.showRedProgress = this.mMediaPlayerStatus.isPlaying; + this.touchEnable = !this.mMediaPlayerStatus.isPlaying + this.redLinePosition = { + x: this.leftThumbRect[2] + this.transparentWidth * this.mMediaPlayerStatus.redLineProgress, + y: this.topPaddingWidth + } + } + } + @Param @Require mRangSeekBarListener: RangSeekBarListener + @Local leftThumbWidth: number = 30 + @Local rightThumbWidth: number = 30 + @Local topPaddingWidth: number = 10; + @Local bottomPaddingWidth: number = 10; + @Local transparentWidth: number = 0 // 可滑动组件的整体宽度 - @State seekCompWidth: number = 0 + @Local seekCompWidth: number = 0 // 可滑动组件的整体高度 - @State seekCompHeight: number = 0 + @Local seekCompHeight: number = 0 // 整个组件的宽度 componentMaxWidth: number = 0 // 整个组件的高度 componentMaxHeight: number = 0; // 当前组件的rect left top right bottom - @Watch('watchComponentRect') @State componentRect: Array = [] - @Watch('watchLeftThumbRect') @State leftThumbRect: Array = [] - @Watch('watchRightThumbRect') @State rightThumbRect: Array = [] + @Local componentRect: Array = [] + @Monitor('componentRect') + watchComponentRect() { + console.log('watchComponentRect = ' + JSON.stringify(this.componentRect)) + } + @Local leftThumbRect: Array = [] + @Monitor('leftThumbRect') + watchLeftThumbRect() { + console.log('dodo watchLeftThumb =' + JSON.stringify(this.leftThumbRect)) + } + @Local rightThumbRect: Array = [] + @Monitor('rightThumbRect') + watchRightThumbRect() { + console.log('watchRightThumbRect =' + JSON.stringify(this.rightThumbRect)) + } TOUCH_LEFT_THUMB = 1; TOUCH_RIGHT_THUMB = 2; TOUCH_HOR_SCROLL = 3; touchStatus: number = this.TOUCH_HOR_SCROLL touchXOld = 0; touchDeltaX = 0; - @State leftThumbPosition: Position = { x: 0, y: 0 } - @State rightThumbPosition: Position = { x: 0, y: 0 } - @State middenPosition: Position = { x: 0, y: 0 } - @State redLinePosition: Position = { x: 0, y: 0 } + @Local leftThumbPosition: Position = { x: 0, y: 0 } + @Local rightThumbPosition: Position = { x: 0, y: 0 } + @Local middenPosition: Position = { x: 0, y: 0 } + @Local redLinePosition: Position = { x: 0, y: 0 } // 左边可滑动条状物 左边间距 LEFT_PADDING = 0; @@ -84,15 +112,10 @@ export struct RangeSeekBarView { // 一秒钟所占的PX宽度 msPxAvg: number = 0; - scroller: Scroller = new Scroller(); + @Param @Once scroller: Scroller = new Scroller(); speed: number = 0; touchEnable: boolean = true - watchRangSeekBarOption() { - this.configUI() - this.initUIRange() - } - configUI() { if (this.mRangSeekBarOption.mThumbWidth) { this.leftThumbWidth = this.mRangSeekBarOption.mThumbWidth @@ -104,35 +127,12 @@ export struct RangeSeekBarView { } } - watchMediaPlayerStatus() { - if (this.mMediaPlayerStatus) { - this.showRedProgress = this.mMediaPlayerStatus.isPlaying; - this.touchEnable = !this.mMediaPlayerStatus.isPlaying - this.redLinePosition = { - x: this.leftThumbRect[2] + this.transparentWidth * this.mMediaPlayerStatus.redLineProgress, - y: this.topPaddingWidth - } - } - } - - watchComponentRect() { - console.log('watchComponentRect = ' + JSON.stringify(this.componentRect)) - } - - watchLeftThumbRect() { - console.log('dodo watchLeftThumb =' + JSON.stringify(this.leftThumbRect)) - } - - watchRightThumbRect() { - console.log('watchRightThumbRect =' + JSON.stringify(this.rightThumbRect)) - } - private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Left | PanDirection.Right }) - @State leftText: string = '00:00:00' - @State rightText: string = '00:00:10' - @State leftTextPosition: Position = { x: 0, y: 0 } - @State rightTextPosition: Position = { x: 0, y: 0 } - @State showRedProgress: boolean = false; + @Local leftText: string = '00:00:00' + @Local rightText: string = '00:00:10' + @Local leftTextPosition: Position = { x: 0, y: 0 } + @Local rightTextPosition: Position = { x: 0, y: 0 } + @Local showRedProgress: boolean = false; leftTextWidth: number = 60 rightTextWidth: number = 60 diff --git a/videotrimmer/src/main/ets/components/VideoThumbListView.ets b/videotrimmer/src/main/ets/components/VideoThumbListView.ets index af55d0a52f8d3d7904553125d4b1b1e41b9d624e..6026122465de85e52e6759bff1be3cf9b74820d1 100644 --- a/videotrimmer/src/main/ets/components/VideoThumbListView.ets +++ b/videotrimmer/src/main/ets/components/VideoThumbListView.ets @@ -23,10 +23,10 @@ export class VideoThumbOption { videoThumbWidth: number = 30; } -@Component +@ComponentV2 export struct VideoThumbListView { - @Link mVideoThumbOption: VideoThumbOption - scroller: Scroller = new Scroller() + @Param @Require mVideoThumbOption: VideoThumbOption + @Param @Once scroller: Scroller = new Scroller() build() { Column() { diff --git a/videotrimmer/src/main/ets/components/VideoTrimmerOption.ets b/videotrimmer/src/main/ets/components/VideoTrimmerOption.ets index c5b4b6b10d5fc974e33c081d0d5a37e6ba36e931..ac03203608476abb5c5b135e853add109be7ceac 100644 --- a/videotrimmer/src/main/ets/components/VideoTrimmerOption.ets +++ b/videotrimmer/src/main/ets/components/VideoTrimmerOption.ets @@ -15,29 +15,31 @@ import common from '@ohos.app.ability.common'; import { VideoLoadFramesListener } from './VideoLoadFramesListener'; import { VideoTrimListener } from './VideoTrimListener' + +@ObservedV2 export class VideoTrimmerOption { - srcFilePath:string = ''; - listener:VideoTrimListener = { + @Trace srcFilePath:string = ''; + @Trace listener:VideoTrimListener = { onStartTrim(){}, onFinishTrim(outputFile:string){}, onCancel(){} }; - loadFrameListener:VideoLoadFramesListener={ + @Trace loadFrameListener:VideoLoadFramesListener={ onStartLoad(){}, onFinishLoad(){} } // 10秒 - VIDEO_MAX_TIME?: number = 10; + @Trace VIDEO_MAX_TIME?: number = 10; // 最小剪辑时间3s - VIDEO_MIN_TIME?: number = 3; + @Trace VIDEO_MIN_TIME?: number = 3; // seekBar的区域内一共有多少张图片 - MAX_COUNT_RANGE?: number = 10; - THUMB_WIDTH?: number = 30; - PAD_LINE_WIDTH?: number = 10; - framePlaceholder?:PixelMap - frameBackground?:string - context?:common.UIAbilityContext + @Trace MAX_COUNT_RANGE?: number = 10; + @Trace THUMB_WIDTH?: number = 30; + @Trace PAD_LINE_WIDTH?: number = 10; + @Trace framePlaceholder?:PixelMap + @Trace frameBackground?:string + @Trace context?:common.UIAbilityContext } \ No newline at end of file diff --git a/videotrimmer/src/main/ets/components/VideoTrimmerView.ets b/videotrimmer/src/main/ets/components/VideoTrimmerView.ets index cc39f1f5589c462ec4eb44ad7f85eb675b9e2af4..3592e8bf3820e21ff6e0a5521088780acdf22c00 100644 --- a/videotrimmer/src/main/ets/components/VideoTrimmerView.ets +++ b/videotrimmer/src/main/ets/components/VideoTrimmerView.ets @@ -29,10 +29,18 @@ import common from '@ohos.app.ability.common' const TAG: string = 'MediaDemo VideoPlayer:'; -@Component +@ComponentV2 export struct VideoTrimmerView { - @Watch('watchVideoTrimmerOption') @Link videoTrimmerOption: VideoTrimmerOption; - @State hintText?: string = '拖动选择你要发表的10秒以内片段' + @Param @Require videoTrimmerOption: VideoTrimmerOption; + @Monitor('videoTrimmerOption') + watchVideoTrimmerOption() { + console.log('watchVideoTrimmerOption') + this.configUIInfo() + this.isPausePreview = true + this.waitLoadedInitAVPlayer(); + } + @Event $videoTrimmerOption: (value: VideoTrimmerOption) => void = (value: VideoTrimmerOption) => {} + @Local hintText?: string = '拖动选择你要发表的10秒以内片段' mLeftProgressPos: number = 0; mRightProgressPos: number = 10; mRedProgressBarPos: number = 0; @@ -47,18 +55,18 @@ export struct VideoTrimmerView { // 是否是restore isFromRestore: boolean = false; - scroller: Scroller = new Scroller(); - @State ratio: number = 1.0; - @State currentTime: string = '0'; - @State durationTimeText: string = '100'; - @State setValue: number = 0; - @State isLoop: boolean = false; - @State videoName: string = ''; - @State isSpeed: boolean = false; - @State descriptionValue: string = ''; - @State isBuffering: boolean = false; - @State speedTag: number = 1; - @State scaleTag: number = 0; + @Param @Once scroller: Scroller = new Scroller(); + @Local ratio: number = 1.0; + @Local currentTime: string = '0'; + @Local durationTimeText: string = '100'; + @Local setValue: number = 0; + @Local isLoop: boolean = false; + @Local videoName: string = ''; + @Local isSpeed: boolean = false; + @Local descriptionValue: string = ''; + @Local isBuffering: boolean = false; + @Local speedTag: number = 1; + @Local scaleTag: number = 0; private avPlayer?: media.AVPlayer = undefined; private surfaceID: string = ''; private mXcomponentController: XComponentController = new XComponentController(); @@ -66,16 +74,16 @@ export struct VideoTrimmerView { // XComponent 加载状态 private isLoaded: boolean = false; private isTrimming: boolean = false; - @State VIDEO_MAX_TIME: number = 10; // 10秒 - @State VIDEO_MIN_TIME: number = 3; // 最小剪辑时间3s - @State MAX_COUNT_RANGE: number = 10; //seekBar的区域内一共有多少张图片 - @State THUMB_WIDTH: number = 30; - @State PAD_LINE_WIDTH: number = 10; - @State mVideoThumbOption: VideoThumbOption = { + @Local VIDEO_MAX_TIME: number = 10; // 10秒 + @Local VIDEO_MIN_TIME: number = 3; // 最小剪辑时间3s + @Local MAX_COUNT_RANGE: number = 10; //seekBar的区域内一共有多少张图片 + @Local THUMB_WIDTH: number = 30; + @Local PAD_LINE_WIDTH: number = 10; + @Local mVideoThumbOption: VideoThumbOption = { videoThumbWidth: 0, videoThumbs: [] } - @State mRangSeekBarOption: RangSeekBarOption = { + @Local mRangSeekBarOption: RangSeekBarOption = { mLeftProgressPos: 0, mRightProgressPos: 10 * 1000, // 最小时间 比如一屏幕10张图 间隔10s, 现在最小时间是3s,那么leftThumb和rightThumb的最小间隔是3张图宽度 @@ -90,13 +98,13 @@ export struct VideoTrimmerView { mThumbWidth: 30, mPaddingTopBottom: 10 } - @State mMediaPlayerStatus: MediaPlayerStatus = { + @Local mMediaPlayerStatus: MediaPlayerStatus = { isPlaying: false, redLineProgress: 0 } startTruncationTime: number = 0; endTruncationTime: number = 0; - @State mRangSeekBarListener: RangSeekBarListener = { + @Local mRangSeekBarListener: RangSeekBarListener = { onRangeSeekBarValuesChanged: (minValue, maxValue) => { // TODO 视频裁剪 和 预览的时间范围 console.log("dodo RangSeekBarListener minValue=" + minValue + " maxValue=" + maxValue) @@ -637,13 +645,6 @@ export struct VideoTrimmerView { this.setSourceInfo(); } - watchVideoTrimmerOption() { - console.log('watchVideoTrimmerOption') - this.configUIInfo() - this.isPausePreview = true - this.waitLoadedInitAVPlayer(); - } - watchHiddenPage() { } @@ -702,7 +703,7 @@ export struct VideoTrimmerView { .height('30%') } - @State isPausePreview: boolean = true; + @Local isPausePreview: boolean = true; @Builder private bottomClickContent() {