HarmonyOS 首页频道多个列表,列表已经使用了lazyforeach,但新闻查看过多后,视频Video黑屏无法播放

首页频道多个列表,列表已经使用了lazyforeach,但新闻查看过多后,视频Video黑屏无法播放

是不是内存占用太多的缘故?如果是,HarmonyOS有没有设置app最大使用内存的api?

HarmonyOS
2024-08-22 18:58:32
783浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

VideoPlayer.ets:

Index.ets:

import { VideoPlayer } from './VideoPlayer'; 
import { VideoItem, myVideoSourceDate } from './MyDataSource'; 
 
@Entry 
@Component 
struct Index { 
  @State sources: VideoItem[] = [ 
    { 
      videoUrl: 'https://xxx.xxx.com/mda-pmia5y0htmibjej2/576p/h264/xxxx/mda-pmia5y0htmibjej2.mp4?auth_key=1703155514-0-0-a92de0b6c32239b242d0e51b151ee2d6&bcevod_channel=searchbox_feed&cr=1&cd=0&pd=1&pt=4&logid=2714832517&vid=9811936085320099438&abtest=all', 
      title: '我们只是拿某站的数据进行一下测试' 
    } 
  ] 
  @State curIndex: number = 0; 
  @State firstFlag: boolean = true; 
  private swiperController: SwiperController = new SwiperController(); 
 
  build() { 
    Swiper(this.swiperController) { 
      LazyForEach(new myVideoSourceDate(this.sources), (item: VideoItem, index: number) => { 
        VideoPlayer({ curSource: item, curIndex: this.curIndex, index: index, firstFlag: this.firstFlag }) 
      }, (item: string, index: number) => JSON.stringify(item) + index) 
    } 
    .width('100%') 
    .height('100%') 
    .index($$this.curIndex) 
    .vertical(true) 
    .loop(false) 
    .indicator(false) 
    .backgroundColor(Color.Black) 
  } 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
分享
微博
QQ
微信
回复
2024-08-23 17:30:12
相关问题
HarmonyOS 视频列表播放问题
671浏览 • 1回复 待解决
HarmonyOS 列表视频滚动播放
1012浏览 • 1回复 待解决
HarmonyOS 列表视频全屏播放实现
1172浏览 • 1回复 待解决
创建多个视频组件无法播放
3041浏览 • 1回复 待解决
HarmonyOS Video播放器,autoplay false黑屏
752浏览 • 1回复 待解决
使用LazyForEach懒加载列表相关问题
1726浏览 • 1回复 待解决
HarmonyOS 播放10bit视频黑屏
409浏览 • 1回复 待解决
视频播放黑屏,下面是代码
10307浏览 • 1回复 待解决