更新视频跳转逻辑和精选
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
import { runCatching, seconds } from '@polyvharmony/media-player-sdk';
|
||||
|
||||
import { VideoMore } from '../model/VideoMoreModel'
|
||||
import { BasicConstant } from '@itcast/basic'
|
||||
import { promptAction, router } from '@kit.ArkUI';
|
||||
import { PLVMockMediaResourceData } from '../polyv/PLVMockMediaResourceData'
|
||||
import {
|
||||
PLVMediaPlayerSingleVideoPageParam
|
||||
} from 'media-player-common';
|
||||
import HashMap from '@ohos.util.HashMap';
|
||||
import { hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { VideoDetailModel } from '../model/VideoDetailModel'
|
||||
import { videoTools } from '../polyv/VideoUtil'
|
||||
@Preview
|
||||
@Component
|
||||
export struct ItemCompVideo {
|
||||
@@ -47,7 +40,7 @@ export struct ItemCompVideo {
|
||||
}.backgroundColor(Color.White)
|
||||
.borderRadius(5)
|
||||
.onClick(()=>{
|
||||
this.getVideoDetail(this.item.uuid)
|
||||
videoTools.getVideoDetail(this.item.uuid)
|
||||
|
||||
})
|
||||
.width('100%').clip(true)
|
||||
@@ -56,39 +49,7 @@ export struct ItemCompVideo {
|
||||
|
||||
}
|
||||
|
||||
getVideoDetail(video_uuid:string)
|
||||
{
|
||||
this.hashMap.clear();
|
||||
this.hashMap.set('video_uuid', video_uuid)
|
||||
hdHttp.httpReq<string>(BasicConstant.videoDetail,this.hashMap).then(async (res: HdResponse<string>) => {
|
||||
logger.info('Response videoDetail'+res);
|
||||
let json:VideoDetailModel = JSON.parse(res+'') as VideoDetailModel;
|
||||
this.goPLVMediaPlayerSingleVideoPage(json.video.polyv_uuid,video_uuid)
|
||||
|
||||
}).catch((err: BusinessError) => {
|
||||
this.goPLVMediaPlayerSingleVideoPage('','')
|
||||
})
|
||||
}
|
||||
|
||||
async goPLVMediaPlayerSingleVideoPage(vid:string,video_uuid:string)
|
||||
{
|
||||
const mediaResourcesResult = await runCatching(PLVMockMediaResourceData.getInstance().setupMediaResourcesFromLocal(vid))
|
||||
if (mediaResourcesResult.success === false) {
|
||||
promptAction.showToast({
|
||||
message: `'视频数据初始化失败': ${mediaResourcesResult.error}`,
|
||||
duration: seconds(3).toMillis()
|
||||
})
|
||||
return
|
||||
}
|
||||
const mediaResource = mediaResourcesResult.data[0]
|
||||
router.pushUrl({
|
||||
url:'pages/VideoPage/PLVMediaPlayerSingleVideoPage',
|
||||
params: {
|
||||
video_uuid:video_uuid,
|
||||
param:new PLVMediaPlayerSingleVideoPageParam(mediaResource)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import { VideoMoreModel,VideoMore } from '../model/VideoMoreModel'
|
||||
import { HdList, HdListController,BasicConstant,hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
|
||||
import { promptAction, router } from '@kit.ArkUI'
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { HdLoadingDialog,EmptyViewComp } from '@itcast/basic'
|
||||
import HashMap from '@ohos.util.HashMap';
|
||||
import { videoTools } from '../polyv/VideoUtil'
|
||||
|
||||
|
||||
@Component
|
||||
export struct ListCompVideoSelect {
|
||||
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
|
||||
|
||||
@Prop
|
||||
type_uuid:string=''
|
||||
@State
|
||||
list: VideoMore[] = []
|
||||
controller = new HdListController()
|
||||
@State
|
||||
page: number = 1
|
||||
@State
|
||||
keyword: string = ''
|
||||
hashMap: HashMap<string, string> = new HashMap();
|
||||
|
||||
dialog: CustomDialogController = new CustomDialogController({
|
||||
builder: HdLoadingDialog({ message: '加载中...' }),
|
||||
customStyle: true,
|
||||
alignment: DialogAlignment.Center
|
||||
})
|
||||
|
||||
|
||||
|
||||
onRefresh() {
|
||||
this.page = 1
|
||||
this.initData(0)
|
||||
}
|
||||
|
||||
initData(type:number)
|
||||
{
|
||||
this.dialog.open()
|
||||
this.hashMap.clear();
|
||||
this.hashMap.set('page', this.page+"")
|
||||
this.hashMap.set('typeUuid', this.type_uuid)
|
||||
hdHttp.httpReq<string>(BasicConstant.videoByTypeNew,this.hashMap).then(async (res: HdResponse<string>) => {
|
||||
logger.info('Response videoByTypeNew'+res);
|
||||
let json:VideoMoreModel = JSON.parse(res+'') as VideoMoreModel;
|
||||
this.dialog.close()
|
||||
if(type==0)
|
||||
{
|
||||
this.controller.refreshed()
|
||||
}
|
||||
else
|
||||
{
|
||||
this.controller.loaded()
|
||||
}
|
||||
if(this.page==1)
|
||||
{
|
||||
this.list=[]
|
||||
if(json.data!=null&&json.data.list!)
|
||||
{
|
||||
this.list = json.data.list
|
||||
}
|
||||
|
||||
}
|
||||
else if(this.page>1)
|
||||
{
|
||||
this.list.push(...json.data.list)
|
||||
}
|
||||
|
||||
if (this.page >= json.data.totalPage) {
|
||||
this.controller.finished()
|
||||
} else {
|
||||
this.page++
|
||||
}
|
||||
if (this.list.length>0) {
|
||||
this.isEmptyViewVisible = false;
|
||||
} else {
|
||||
this.isEmptyViewVisible = true;
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close()
|
||||
if (this.list.length>0) {
|
||||
this.isEmptyViewVisible = false;
|
||||
} else {
|
||||
this.isEmptyViewVisible = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
if (this.isEmptyViewVisible){
|
||||
EmptyViewComp({promptText:'暂无数据',isVisibility:this.isEmptyViewVisible})
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
} else {
|
||||
HdList({
|
||||
lw: 1,
|
||||
controller: this.controller,
|
||||
onRefresh: () => {
|
||||
this.onRefresh()
|
||||
},
|
||||
onLoad: () => {
|
||||
this.initData(1)
|
||||
}
|
||||
}) {
|
||||
ForEach(this.list, (items: VideoMore) => {
|
||||
ListItem() {
|
||||
Column()
|
||||
{
|
||||
Row()
|
||||
{
|
||||
Text(items.name) .textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.maxLines(1)
|
||||
.textAlign(TextAlign.Start)
|
||||
.layoutWeight(1)
|
||||
.fontSize(16)
|
||||
.padding(10)
|
||||
Image($r('sys.media.ohos_ic_public_arrow_right'))
|
||||
.width(15)
|
||||
.height(15)
|
||||
.margin({ right: 10})
|
||||
}
|
||||
.width('100%')
|
||||
Text('').height(1).width('100%')
|
||||
.backgroundColor($r('app.color.1a000000'))
|
||||
}
|
||||
.onClick(()=>{
|
||||
videoTools.getVideoDetail(items.uuid)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from 'media-player-common';
|
||||
import { runCatching, seconds } from '@polyvharmony/media-player-sdk';
|
||||
import { it } from '@ohos/hypium';
|
||||
|
||||
import { videoTools } from '../polyv/VideoUtil'
|
||||
@Component
|
||||
export struct SwiperComp {
|
||||
@State
|
||||
@@ -61,7 +61,7 @@ export struct SwiperComp {
|
||||
.padding({right:100,left:5})
|
||||
.margin({ bottom: 0 })
|
||||
}.onClick(()=>{
|
||||
this.getVideoDetail(item.uuid);
|
||||
videoTools.getVideoDetail(item.uuid)
|
||||
})
|
||||
}, (item: VideoRoll) => JSON.stringify(item))
|
||||
}
|
||||
@@ -85,35 +85,5 @@ export struct SwiperComp {
|
||||
.width('100%')
|
||||
}
|
||||
|
||||
getVideoDetail(video_uuid:string) {
|
||||
const hashMap: HashMap<string, string> = new HashMap();
|
||||
hashMap.clear();
|
||||
hashMap.set('video_uuid', video_uuid)
|
||||
hdHttp.httpReq<string>(BasicConstant.videoDetail,hashMap).then(async (res: HdResponse<string>) => {
|
||||
logger.info('Response videoDetail'+res);
|
||||
let json:VideoDetailModel = JSON.parse(res+'') as VideoDetailModel;
|
||||
this.goPLVMediaPlayerSingleVideoPage(json.video.polyv_uuid,video_uuid)
|
||||
}).catch((err: BusinessError) => {
|
||||
this.goPLVMediaPlayerSingleVideoPage('','')
|
||||
})
|
||||
}
|
||||
|
||||
async goPLVMediaPlayerSingleVideoPage(vid:string,video_uuid:string) {
|
||||
const mediaResourcesResult = await runCatching(PLVMockMediaResourceData.getInstance().setupMediaResourcesFromLocal(vid))
|
||||
if (mediaResourcesResult.success === false) {
|
||||
promptAction.showToast({
|
||||
message: `'视频数据初始化失败': ${mediaResourcesResult.error}`,
|
||||
duration: seconds(3).toMillis()
|
||||
})
|
||||
return
|
||||
}
|
||||
const mediaResource = mediaResourcesResult.data[0]
|
||||
router.pushUrl({
|
||||
url:'pages/VideoPage/PLVMediaPlayerSingleVideoPage',
|
||||
params: {
|
||||
video_uuid:video_uuid,
|
||||
param:new PLVMediaPlayerSingleVideoPageParam(mediaResource)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ export struct PlayBack {
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.padding({bottom:50})
|
||||
|
||||
}
|
||||
|
||||
getSelect()
|
||||
|
||||
@@ -8,7 +8,10 @@ export struct VideoMore {
|
||||
build() {
|
||||
|
||||
Column() {
|
||||
HdNav({ title: this.params.title, showRightIcon: false, showLeftIcon: true,showRightText:true,rightText:'精选' })
|
||||
HdNav({ title: this.params.title, showRightIcon: false, showLeftIcon: true,showRightText:true,rightText:'精选',rightItemAction:()=>{
|
||||
router.pushUrl({url:'pages/VideoPage/VideoSelectedPage',
|
||||
params: this.params})
|
||||
} })
|
||||
Text('').height(1).width('100%')
|
||||
.backgroundColor($r('app.color.1a000000'))
|
||||
.margin({bottom:10})
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import router from '@ohos.router';
|
||||
import { HdNav } from '@itcast/basic'
|
||||
import { ListCompVideoSelect } from '../components/ListCompVideoSelect'
|
||||
@Component
|
||||
export struct VideoSelected{
|
||||
|
||||
@State params:Record<string, string> = router.getParams() as Record<string, string>;
|
||||
build() {
|
||||
|
||||
Column() {
|
||||
HdNav({ title: this.params.title, showRightIcon: false, showLeftIcon: true })
|
||||
ListCompVideoSelect({type_uuid:this.params.uuid}).backgroundColor(Color.White).height('100%')
|
||||
}.width('100%')
|
||||
.height('100%').backgroundColor($r('app.color.top_bg'))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { runCatching, seconds } from '@polyvharmony/media-player-sdk';
|
||||
import { BasicConstant } from '@itcast/basic'
|
||||
import { promptAction, router } from '@kit.ArkUI';
|
||||
import { PLVMockMediaResourceData } from '../polyv/PLVMockMediaResourceData'
|
||||
import {
|
||||
PLVMediaPlayerSingleVideoPageParam
|
||||
} from 'media-player-common';
|
||||
import HashMap from '@ohos.util.HashMap';
|
||||
import { hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { VideoDetailModel } from '../model/VideoDetailModel'
|
||||
class VideoTools {
|
||||
hashMap: HashMap<string, string> = new HashMap();
|
||||
getVideoDetail(video_uuid:string)
|
||||
{
|
||||
this.hashMap.clear();
|
||||
this.hashMap.set('video_uuid', video_uuid)
|
||||
hdHttp.httpReq<string>(BasicConstant.videoDetail,this.hashMap).then(async (res: HdResponse<string>) => {
|
||||
logger.info('Response videoDetail'+res);
|
||||
let json:VideoDetailModel = JSON.parse(res+'') as VideoDetailModel;
|
||||
this.goPLVMediaPlayerSingleVideoPage(json.video.polyv_uuid,video_uuid)
|
||||
|
||||
}).catch((err: BusinessError) => {
|
||||
this.goPLVMediaPlayerSingleVideoPage('','')
|
||||
})
|
||||
}
|
||||
|
||||
async goPLVMediaPlayerSingleVideoPage(vid:string,video_uuid:string)
|
||||
{
|
||||
const mediaResourcesResult = await runCatching(PLVMockMediaResourceData.getInstance().setupMediaResourcesFromLocal(vid))
|
||||
if (mediaResourcesResult.success === false) {
|
||||
promptAction.showToast({
|
||||
message: `'视频数据初始化失败': ${mediaResourcesResult.error}`,
|
||||
duration: seconds(3).toMillis()
|
||||
})
|
||||
return
|
||||
}
|
||||
const mediaResource = mediaResourcesResult.data[0]
|
||||
router.pushUrl({
|
||||
url:'pages/VideoPage/PLVMediaPlayerSingleVideoPage',
|
||||
params: {
|
||||
video_uuid:video_uuid,
|
||||
param:new PLVMediaPlayerSingleVideoPageParam(mediaResource)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const videoTools = new VideoTools()
|
||||
Reference in New Issue
Block a user