diff --git a/README.md b/README.md index a105d314b8209b7abaa22d1d4a5d7e9b6a60e0d0..db48df47d44a4080e277dcef098f76520802f1c7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 基于AVPlayer实现视频基本播控功能 +# 基于AVPlayer实现视频基础播控功能 ## 项目简介 diff --git a/entry/src/main/ets/controller/AvPlayerController.ets b/entry/src/main/ets/controller/AvPlayerController.ets index 9456c4c47dce6dfa7418851c0e22f5ed30da47f2..585bfbd8099556ab64451471baa8219951eb7f5d 100644 --- a/entry/src/main/ets/controller/AvPlayerController.ets +++ b/entry/src/main/ets/controller/AvPlayerController.ets @@ -184,6 +184,7 @@ export class AvPlayerController { return; } switch (state) { + // DocsDot // [StartExclude state] case 'idle': // This state machine is triggered after the reset interface is successfully invoked. hilog.info(CommonConstants.LOG_DOMAIN, TAG, 'setAVPlayerCallback AVPlayer state idle called.'); @@ -197,10 +198,12 @@ export class AvPlayerController { this.avPlayer.prepare(); break; // [EndExclude state] + // DocsDot case 'prepared': // This state machine is reported after the prepare interface is successfully invoked. hilog.info(CommonConstants.LOG_DOMAIN, TAG, 'setAVPlayerCallback AVPlayer state prepared called.'); this.isReady = true; this.avPlayer.loop = true + // DocsDot // [StartExclude prepared] this.durationTime = this.avPlayer.duration; this.currentTime = this.avPlayer.currentTime; @@ -226,7 +229,9 @@ export class AvPlayerController { this.setVideoSpeed(); // [EndExclude prepared] + // DocsDot break; + // DocsDot // [StartExclude other_state] case 'playing': // After the play interface is successfully invoked, the state machine is reported. hilog.info(CommonConstants.LOG_DOMAIN, TAG, 'setAVPlayerCallback AVPlayer state playing called.'); @@ -260,6 +265,7 @@ export class AvPlayerController { hilog.info(CommonConstants.LOG_DOMAIN, TAG, 'setAVPlayerCallback AVPlayer state unknown called.'); break; // [EndExclude other_state] + // DocsDot } }); // [End loop_playback] diff --git a/entry/src/main/ets/views/LanguageDialog.ets b/entry/src/main/ets/views/LanguageDialog.ets index aa88125a948a74229799fbead0fd09660baff316..9fe6e4a1a385389e381724296401bf2b662e057e 100644 --- a/entry/src/main/ets/views/LanguageDialog.ets +++ b/entry/src/main/ets/views/LanguageDialog.ets @@ -18,7 +18,6 @@ import { AvPlayerController } from '../controller/AvPlayerController'; // Index of the playback rate list. const ONE = 1; -// [Start video_language_dialog] /** * Set language dialog */ @@ -26,40 +25,51 @@ const ONE = 1; export struct LanguageDialog { @State languageList: Resource[] = [$r('app.string.Chinese'), $r('app.string.English')]; - @Link languageSelect: number; // Index of the current selection + @Link @Watch('onLanguageSelectUpdate') languageSelect: number; // Index of the current selection @StorageLink('avPlayerController') avPlayerController: AvPlayerController = new AvPlayerController(); private controller: CustomDialogController; + onLanguageSelectUpdate() { + AppStorage.setOrCreate('currentLanguageType', this.languageSelect); + } + build() { Column() { - Text($r('app.string.language_switch'))// [StartExclude text_style1] + Text($r('app.string.language_switch')) .fontSize($r('app.float.size_20')) .fontWeight(FontWeight.Bold) .width('90%') .fontColor(Color.Black) .textAlign(TextAlign.Center) .margin({ top: $r('app.float.size_20'), bottom: $r('app.float.size_12') }) - // [EndExclude text_style1] + // [Start video_language_dialog] List() { ForEach(this.languageList, (item: Resource, index) => { ListItem() { Column() { Row() { - Text(item)// [StartExclude text_style2] + Text(item) + // DocsDot + // [StartExclude text_style2] .fontSize($r('app.float.size_16')) .fontColor(Color.Black) .fontWeight(FontWeight.Medium) .textAlign(TextAlign.Center) // [EndExclude text_style2] + // DocsDot Blank() Image(this.languageSelect === index ? $r('app.media.ic_radio_selected') : - $r('app.media.ic_radio'))// [StartExclude text_style3] + $r('app.media.ic_radio')) + // DocsDot + // [StartExclude text_style3] .width($r('app.float.size_24')) .height($r('app.float.size_24')) .objectFit(ImageFit.Contain) // [EndExclude text_style3] + // DocsDot } + // DocsDot // [StartExclude text_style4] .width('100%') @@ -72,6 +82,7 @@ export struct LanguageDialog { .width('100%') } // [EndExclude text_style4] + // DocsDot } .width('90%') } @@ -79,13 +90,13 @@ export struct LanguageDialog { .height($r('app.float.size_48')) .onClick(() => { this.languageSelect = index; - AppStorage.setOrCreate('currentLanguageType', this.languageSelect); this.avPlayerController.languageChange(this.languageSelect); this.controller.close(); }) }, (item: Resource, index) => index + '_' + JSON.stringify(item)) } - // [StartExclude cancel] + + // [End video_language_dialog] .width('100%') .height('192vp') .margin({ @@ -108,17 +119,12 @@ export struct LanguageDialog { .padding({ bottom: $r('app.float.size_5') }) .width('100%') - // [EndExclude cancel] } - // [StartExclude box_style] .alignItems(HorizontalAlign.Center) .width('100%') .margin({ left: $r('app.float.size_16'), right: $r('app.float.size_16') }) .borderRadius($r('app.float.size_24')) .backgroundColor(Color.White) - // [EndExclude box_style] } -} - -// [End video_language_dialog] \ No newline at end of file +} \ No newline at end of file diff --git a/entry/src/main/ets/views/ScaleDialog.ets b/entry/src/main/ets/views/ScaleDialog.ets index 082f4aa427beda9c184b5c3345b80cef5f6f5bb0..91ff6a7230e9f7f24ac5fc63aab875a7d1ffced4 100644 --- a/entry/src/main/ets/views/ScaleDialog.ets +++ b/entry/src/main/ets/views/ScaleDialog.ets @@ -49,23 +49,29 @@ export struct ScaleDialog { ListItem() { Column() { Row() { - Text(item)// [StartExclude text_style2] + Text(item) + // DocsDot + // [StartExclude text_style2] .fontSize($r('app.float.size_16')) .fontColor(Color.Black) .fontWeight(FontWeight.Medium) .textAlign(TextAlign.Center) // [EndExclude text_style2] + // DocsDot Blank() Image(this.windowScaleSelect === index ? $r('app.media.ic_radio_selected') : - $r('app.media.ic_radio'))// [StartExclude text_style3] + $r('app.media.ic_radio')) + // DocsDot + // [StartExclude text_style3] .width($r('app.float.size_24')) .height($r('app.float.size_24')) .objectFit(ImageFit.Contain) // [EndExclude text_style3] + // DocsDot } + // DocsDot // [StartExclude text_style4] .width('100%') - if (index != this.scaleList.length - ONE) { Divider() .vertical(false) @@ -75,6 +81,7 @@ export struct ScaleDialog { .width('100%') } // [EndExclude text_style4] + // DocsDot } .width('90%') } diff --git a/entry/src/main/ets/views/SpeedDialog.ets b/entry/src/main/ets/views/SpeedDialog.ets index a7ba007ce31c68c9b5194ae52edc0b24edd62806..a97c3d59793efb76238b06aa9c2b8ce0ae141861 100644 --- a/entry/src/main/ets/views/SpeedDialog.ets +++ b/entry/src/main/ets/views/SpeedDialog.ets @@ -54,20 +54,27 @@ export struct SpeedDialog { ListItem() { Column() { Row() { - Text(item)// [StartExclude text_style2] + Text(item) + // DocsDot + // [StartExclude text_style2] .fontSize($r('app.float.size_16')) .fontColor(Color.Black) .fontWeight(FontWeight.Medium) .textAlign(TextAlign.Center) // [EndExclude text_style2] + // DocsDot Blank() Image(this.speedSelect === index ? $r('app.media.ic_radio_selected') : - $r('app.media.ic_radio'))// [StartExclude text_style3] + $r('app.media.ic_radio')) + // DocsDot + // [StartExclude text_style3] .width($r('app.float.size_24')) .height($r('app.float.size_24')) .objectFit(ImageFit.Contain) // [EndExclude text_style3] + // DocsDot } + // DocsDot // [StartExclude text_style4] .width('100%') @@ -80,6 +87,7 @@ export struct SpeedDialog { .width('100%') } // [EndExclude text_style4] + // DocsDot } .width('90%') }