Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhaojunkai
2024-04-03 15:44:57 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a54af08dc7236a3636520a7bd8489fe8b491a40c
a54af08d
1 parent
12e1f54b
音乐详情-播放/暂停音乐
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
22 deletions
sight_harmony/features/wdComponent/src/main/ets/components/AudioDetailComponent.ets
sight_harmony/products/phone/src/main/ets/pages/detail/AudioDetail.ets
sight_harmony/features/wdComponent/src/main/ets/components/AudioDetailComponent.ets
View file @
a54af08
...
...
@@ -3,7 +3,8 @@ import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailView
import { ContentDetailDTO } from 'wdBean';
import media from '@ohos.multimedia.media';
import { OperRowListView } from './view/OperRowListView';
import { WDPlayerController } from 'wdPlayer';
import { WDPlayerController } from 'wdPlayer/Index';
const TAG = 'AudioDetailComponent'
interface Arr{
image:string,
...
...
@@ -15,7 +16,8 @@ export struct AudioDetailComponent {
private relId: string = ''
private contentId: string = ''
private relType: string = ''
private playerController: WDPlayerController = new WDPlayerController();
private avPlayer?: media.AVPlayer;
@State playerController: WDPlayerController = new WDPlayerController();
private arr:Arr[]=[
{image:'clock',title:'定时'},
...
...
@@ -26,24 +28,24 @@ export struct AudioDetailComponent {
@State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[]//详情
@State coverImage:string = '' //封面图
@State newsTitle:string = '' //标题
@State duration:number = 0 //时长
@State audioUrl:string = '' //音频路径
@State duration:number = 0 //时长
@State outSetValueOne:number = 40 //播放进度
@State @Watch('onIsPlayChanged')isPlay: boolean = true
onIsPlayChanged(){
if(this.isPlay){
console.log('监听播放')
// this.avPlayer.play()
}else{
console.log('监听暂停')
// this.avPlayer.pause()
}
}
@State isPlay: boolean = false
async aboutToAppear() {
await this.getContentDetailData()
this.playerController.firstPlay(this.audioUrl);
this.playerController.onCanplay = () => {
this.playerController.play()
this.isPlay = true
}
this.playerController.onTimeUpdate = (nowSeconds, totalSeconds) =>{
console.log('现在时间',nowSeconds)
console.log('总时间',totalSeconds)
this.outSetValueOne = nowSeconds
this.duration = totalSeconds
}
}
build() {
Row() {
...
...
@@ -94,10 +96,17 @@ export struct AudioDetailComponent {
Column(){
// 进度条
Row(){
Progress({ value: this.outSetValueOne, type: ProgressType.Linear })
.width('100%')
.color('#ED2800')
.backgroundColor('rgba(0,0,0,0.5)')
Slider({
value: this.outSetValueOne,
step: 1
})
.showTips(true)
.trackColor('rgba(0,0,0,0.5)')
.selectedColor('#ED2800')
.onChange((value: number, mode: SliderChangeMode) => {
console.log('滑块长度',value)
this.playerController?.setSeekTime(value, mode);
})
}
.width('100%')
.padding({left:24,right:24})
...
...
@@ -126,6 +135,14 @@ export struct AudioDetailComponent {
.padding(28)
.backgroundColor('#4D5258')
.borderRadius(50)
.onClick(()=>{
if(this.isPlay){
this.playerController.pause()
}else{
this.playerController.play()
}
this.isPlay = !this.isPlay
})
Image($r('app.media.fastForward_close'))
.width(24)
.height(24)
...
...
@@ -151,7 +168,6 @@ export struct AudioDetailComponent {
}
}
private async getContentDetailData() {
try {
let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
...
...
sight_harmony/products/phone/src/main/ets/pages/detail/AudioDetail.ets
View file @
a54af08
...
...
@@ -29,8 +29,5 @@ struct AudioDetail {
this.relId = params?.extra?.relId || '';
this.relType = params?.extra?.relType || '';
this.contentId = params?.contentID || '';
Logger.info(TAG, 'aboutToAppear');
Logger.info(TAG, 'params', JSON.stringify(params));
console.log('参数',JSON.stringify(par))
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment