zhenghy

视频播放修改

... ... @@ -4,6 +4,7 @@ import { ResponseDTO } from 'wdNetwork/Index';
import { DetailPlayShortVideoPage } from './DetailPlayShortVideoPage'
import { Test } from './Test'
import router from '@ohos.router';
import window from '@ohos.window';
@Entry
@Component
... ... @@ -17,6 +18,7 @@ export struct DetailVideoListPage {
@State currentIndex: number = 0
async aboutToAppear(): Promise<void> {
console.error('=================',)
let data: ContentDetailDTO[] = []
let action: Action = router.getParams() as Action
if (action) {
... ... @@ -80,9 +82,10 @@ export struct DetailVideoListPage {
// }, (item: string) => item)
}
.cachedCount(2)
.cachedCount(0)
.indicator(false)
.vertical(true)
.loop(false)
.width('100%')
.height('100%')
... ...
... ... @@ -77,9 +77,10 @@ export struct PlayerDetailContainer {
.zIndex(1)
}
.width('100%')
.height('100%')
// .aspectRatio(this.isFullScreen ? 0.1 : 16 / 9.0) // 若width值确定,当aspectRatio值越小,则height值越大
.height(this.isFullScreen ? '100%' : this.buildVideoHeight())
.margin({ top: this.isFullScreen ? 0 : this.buildVideoTo() })
// .height(this.isFullScreen ? '100%' : this.buildVideoHeight())
// .margin({ top: this.isFullScreen ? 0 : this.buildVideoTo() })
// .margin({ bottom: this.isFullScreen ? 0 : this.buildVideoBottom() })
.alignRules({
top: { anchor: '__container__', align: VerticalAlign.Top },
... ...
... ... @@ -29,33 +29,33 @@ export struct PlayerTitleComment {
build() {
Column() {
Column() {
Row() {
Image($r('app.media.ic_switch_orientation'))
.width(34)
.aspectRatio(1)
.objectFit(ImageFit.Contain)
.padding({ left: 10, right: 5 })
Text("全屏观看")
.fontColor(Color.White)
.fontSize('14fp')
.maxLines(2)
.layoutWeight(1)
}
.width(100)
.backgroundColor(Color.Gray)
.borderRadius(10)
.alignItems(VerticalAlign.Center)
.visibility(this.videoLandScape == 2 ? Visibility.Hidden : Visibility.Visible)
.onClick(() => {
this.isFullScreen = !this.isFullScreen;
WindowModel.shared.setPreferredOrientation(window.Orientation.LANDSCAPE);
devicePLSensorManager.devicePLSensorOn(window.Orientation.LANDSCAPE);
})
}
.width('100%')
// .margin({ bottom: 120 })
.alignItems(HorizontalAlign.Center)
// Column() {
// Row() {
// Image($r('app.media.ic_switch_orientation'))
// .width(34)
// .aspectRatio(1)
// .objectFit(ImageFit.Contain)
// .padding({ left: 10, right: 5 })
// Text("全屏观看")
// .fontColor(Color.White)
// .fontSize('14fp')
// .maxLines(2)
// .layoutWeight(1)
// }
// .width(100)
// .backgroundColor(Color.Gray)
// .borderRadius(10)
// .alignItems(VerticalAlign.Center)
// .visibility(this.videoLandScape == 2 ? Visibility.Hidden : Visibility.Visible)
// .onClick(() => {
// this.isFullScreen = !this.isFullScreen;
// WindowModel.shared.setPreferredOrientation(window.Orientation.LANDSCAPE);
// devicePLSensorManager.devicePLSensorOn(window.Orientation.LANDSCAPE);
// })
// }
// .width('100%')
// // .margin({ bottom: 120 })
// .alignItems(HorizontalAlign.Center)
Row() {
Column() {
... ...
... ... @@ -80,6 +80,9 @@ export struct WDPlayerRenderView {
})
.onLoad(async (event) => {
Logger.info(TAG, 'onLoad')
let surfaceId = this.xComponentController.getXComponentSurfaceId()
console.log('surfaceId===', surfaceId)
console.log('insId===', this.insId)
this.xComponentController.setXComponentSurfaceSize({
surfaceWidth: 1920,
surfaceHeight: 1080
... ... @@ -94,7 +97,7 @@ export struct WDPlayerRenderView {
}
.id(this.insId)
.onAreaChange(() => {
this.updateLayout()
// this.updateLayout()
})
.backgroundColor("#000000")
.justifyContent(FlexAlign.Center)
... ...