diff --git a/audioFeature/build-profile.json5 b/audioFeature/build-profile.json5 index 5f0c96d1e7175525fc023ac99a0429f264c8f739..2e52bcec39776cf0b7df3dc769c2f2e1db2ab27c 100644 --- a/audioFeature/build-profile.json5 +++ b/audioFeature/build-profile.json5 @@ -17,9 +17,6 @@ "apiType": 'stageMode', "buildOption": { }, - "entryModules": [ - "entry" - ], "targets": [ { "name": "default" diff --git a/audioFeature/src/main/ets/pages/Index.ets b/audioFeature/src/main/ets/pages/Index.ets index b080e207f38b9115b45ef4b9cff68a0715651cb8..6055764da6289c91b4d785272af1ed82c6710b98 100644 --- a/audioFeature/src/main/ets/pages/Index.ets +++ b/audioFeature/src/main/ets/pages/Index.ets @@ -13,24 +13,24 @@ * limitations under the License. */ -import { media } from '@kit.MediaKit' -import Logger from '../util/Logger' import { common } from '@kit.AbilityKit'; -import { BusinessError } from '@kit.BasicServicesKit' +import { BusinessError } from '@kit.BasicServicesKit'; +import { media } from '@kit.MediaKit'; +import Logger from '../util/Logger'; -const TAG: string = 'Index' -const FD_PREFIX: string = 'fd://' +const TAG: string = 'Index'; +const FD_PREFIX: string = 'fd://'; let player: media.AVPlayer; media.createAVPlayer().then((video: media.AVPlayer) => { if (video != null) { player = video; - console.info('createAVPlayer success'); + Logger.info(TAG, 'createAVPlayer success'); } else { - console.error('createAVPlayer fail'); + Logger.error(TAG, 'createAVPlayer fail'); } }).catch((error: BusinessError) => { - console.error(`AVPlayer catchCallback, error message:${error.message}`); + Logger.error(TAG, `AVPlayer catchCallback, error message:${error.message}`); }); @Entry @@ -42,27 +42,26 @@ struct Index { build() { Row() { - Button({type: ButtonType.Circle, stateEffect: true}) { - Image($r("app.media.play")).width(35).height(35) + Button({ type: ButtonType.Circle, stateEffect: true }) { + Image($r('app.media.play')).width(35).height(35) } - .onClick((event) => { - Logger.info(TAG, "play button clicked, hasInit: " + this.hasInit) - console.log("this.hasInit",this.hasInit) + .onClick(() => { + Logger.info(TAG, 'play button clicked, hasInit: ' + this.hasInit) if (this.hasInit) { - player.play() + player.play(); } else { - this.initAudioPlayer() + this.initAudioPlayer(); } }) .id('btnAudioPlay') .backgroundColor(0xFFFFFF) - .margin({right: 15}) + .margin({ right: 15 }) - Button({type: ButtonType.Circle, stateEffect: true}) { - Image($r("app.media.pause")).width(35).height(35) + Button({ type: ButtonType.Circle, stateEffect: true }) { + Image($r('app.media.pause')).width(35).height(35) } .onClick((event) => { - player.pause() + player.pause(); }) .id('btnAudioStop') .backgroundColor(0xFFFFFF) @@ -73,11 +72,15 @@ struct Index { } initAudioPlayer() { - if(this.context){ - this.setCallback(player) - this.context.resourceManager.getRawFd("1.mp3").then(value => { - player.fdSrc = value - }) + if (this.context) { + this.setCallback(player); + this.context.resourceManager.getRawFd('1.mp3') + .then(value => { + player.fdSrc = value + }) + .catch((error: BusinessError) => { + Logger.error(TAG, `getRawFd failed, error code=${error.code}, message=${error.message}`); + }) } } @@ -85,20 +88,22 @@ struct Index { player.on('stateChange', this.stateChangeCallback = async (state: string, reason: media.StateChangeReason) => { switch (state) { case 'idle': - console.info('state idle called'); + Logger.info(TAG, 'state idle called'); break; case 'initialized': - Logger.info(TAG, 'initialized prepared called') + Logger.info(TAG, 'initialized prepared called'); this.hasInit = true; player.prepare().then(() => { - player.play() + player.play(); + }).catch((error: BusinessError) => { + Logger.error(TAG, `prepare failed, error code=${error.code}, message=${error.message}`); }) break; case 'playing': - Logger.info(TAG, 'audio play success') + Logger.info(TAG, 'audio play success'); break; case 'paused': - Logger.info(TAG, 'audio paused success') + Logger.info(TAG, 'audio paused success'); break; case 'error': Logger.error('state error called'); @@ -107,10 +112,10 @@ struct Index { Logger.info('unkown state :' + state); break; } - }) + }); } aboutToAppear() { - this.context = this.getUIContext().getHostContext() as common.UIAbilityContext + this.context = this.getUIContext().getHostContext() as common.UIAbilityContext; } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index abb3479b8f26978286ff37e27f07dd6b54a5d22c..916fdf1d945ce96fc8eeb9c4d49184ab03f49013 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -72,7 +72,6 @@ struct Index { } aboutToAppear() { - this.context = this.getUIContext().getHostContext() as common.UIAbilityContext - + this.context = this.getUIContext().getHostContext() as common.UIAbilityContext; } } \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 index f70ecd4112d94f9aa555adf898d53f18bf58f3e9..a2a2e3781820ac1b548a01481b50e88b0f2e5cfa 100644 --- a/hvigor/hvigor-config.json5 +++ b/hvigor/hvigor-config.json5 @@ -1,5 +1,5 @@ { - "modelVersion": "5.0.0", + "modelVersion": "5.0.5", "dependencies": { } } \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 index 9f50643e26e62f22e732ed1f26f7e5e3b584f910..0a0df96a64c42450fd0122a060c6d0ba0119c223 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -1,5 +1,5 @@ { - "modelVersion": "5.0.0", + "modelVersion": "5.0.5", "license": "ISC", "devDependencies": { }, diff --git a/videoFeature/build-profile.json5 b/videoFeature/build-profile.json5 index 5f0c96d1e7175525fc023ac99a0429f264c8f739..2e52bcec39776cf0b7df3dc769c2f2e1db2ab27c 100644 --- a/videoFeature/build-profile.json5 +++ b/videoFeature/build-profile.json5 @@ -17,9 +17,6 @@ "apiType": 'stageMode', "buildOption": { }, - "entryModules": [ - "entry" - ], "targets": [ { "name": "default"