HarmonyOS 鸿蒙Next VideoPlayer的url设置不上,请问该如何解决?

HarmonyOS 鸿蒙Next VideoPlayer的url设置不上,请问该如何解决?

// 调用createVideoPlayer接口返回videoPlayer实例对象media.createVideoPlayer().then((video) => { if (typeof (video) != ‘undefined’) { console.info(‘createVideoPlayer success!’); this.videoPlayer = video; // 设置surfaceID用于显示视频画面 this.videoPlayer.setDisplaySurface(surfaceId).then(() => { console.info(‘setDisplaySurface success’); }, this.failureCallback).catch(this.catchCallback); video.url=“https://video-qn.51miz.com/preview/video/00/00/15/34/V-153443-20A3FA57.mp4” // 上面这句话不管放到哪儿,设置完后,video.url的值总是"",那位大佬可以帮帮小弟? } else { console.info(‘createVideoPlayer fail!’); } }, this.failureCallback).catch(this.catchCallback);


更多关于HarmonyOS 鸿蒙Next VideoPlayer的url设置不上,请问该如何解决?的实战教程也可以访问 https://www.itying.com/category-93-b0.html

5 回复

更多关于HarmonyOS 鸿蒙Next VideoPlayer的url设置不上,请问该如何解决?的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


开发者您好,视频播放可以参考以下链接:https://developer.huawei.com/consumer/cn/codelabsPortal/carddetails/HarmonyOS-SimpleVideoETS

这个是旧Video,我用的是API 8的 ,初始化时区别较大

this.videoPlayer.setDisplaySurface(surfaceId).then(() => {
  console.info('setDisplaySurface success');
});

调试运行时:

07-14 16:33:28.605 15583-15804/com.example.onlinelearning I 03B00/JSApp: app Log: createVideoPlayer success!
07-14 16:34:28.120 15583-15804/com.example.onlinelearning I 03B00/JSApp: app Log: GroupMessenger parse json result
07-14 16:34:31.833 15583-15804/com.example.onlinelearning I 03B00/JSApp: app Log: setDisplaySurface success

直接运行时:

07-14 16:39:24.781 11981-12247/com.example.onlinelearning I 03B00/JSApp: app Log: createVideoPlayer success!
07-14 16:39:24.783 11981-12247/com.example.onlinelearning I 03B00/JSApp: app Log: GroupMessenger parse json result
07-14 16:39:24.783 11981-12247/com.example.onlinelearning I 03B00/JSApp: app Log: failure error happened,error Name is undefined
07-14 16:39:24.783 11981-12247/com.example.onlinelearning I 03B00/JSApp: app Log: failure error happened,error Code is 8
07-14 16:39:24.783 11981-12247/com.example.onlinelearning I 03B00/JSApp: app Log: failure error happened,error Message is undefined

this.videoPlayer.setDisplaySurface(surfaceId)
调试运行时设置成功,直接运行时设置出差,我也是晕了

欢迎开发小伙伴们进来帮帮楼主

针对HarmonyOS鸿蒙Next VideoPlayer的url设置不上的问题,可以尝试以下步骤进行排查和解决:

  1. 检查URL格式: 确保所设置的URL格式正确无误,支持的视频格式应被鸿蒙系统所兼容。检查URL中是否包含非法字符或空格,必要时进行URL编码。

  2. 检查权限设置: 确保应用已获取到访问网络资源的权限。在鸿蒙系统的应用权限管理中,检查并授予相应的网络访问权限。

  3. 检查VideoPlayer组件: 确保VideoPlayer组件已正确初始化,并检查其属性设置是否正确。在代码中查找VideoPlayer的初始化部分,确认url属性是否被正确赋值。

  4. 更新鸿蒙系统SDK: 如果使用的是较旧的鸿蒙系统SDK,尝试更新到最新版本。新版本可能修复了旧版本中的一些问题。

  5. 查阅官方文档: 详细查阅鸿蒙系统的官方文档,了解VideoPlayer组件的使用方法和注意事项,确保按照官方推荐的方式进行设置。

如果上述步骤均无法解决问题,可能是鸿蒙系统或VideoPlayer组件本身存在的bug。此时,建议联系鸿蒙系统的官方客服进行进一步排查和解决。官网客服地址是:https://www.itying.com/category-93-b0.html

回到顶部