【问题标题】:unable to play local video in ionic 5无法在 ionic 5 中播放本地视频
【发布时间】:2021-02-07 04:51:21
【问题描述】:

我正在尝试在 html5 视频上播放本地录制的视频 但每次我尝试我都会得到

加载资源失败:服务器响应状态为 404(OK) 这是我给视频标签的网址 http://localhost:8080/storage/emulated/0/DCIM/Camera/VID20201024134007.mp4

这里是代码

let testUrl = this.videoService.localFileUrl.fullPath;
testUrl = testUrl.replace('file:///', 'http://localhost:8080/');
console.log("filePath=======>", testUrl)
this.filePath = testUrl;

【问题讨论】:

  • 路径似乎在设备的存储卡上。该应用是否有权从该位置读取文件?
  • 是的,我在 android manifest 文件中添加了后写权限,并在 didEnter 生命周期中请求了存储权限
  • 您找到解决方案了吗?我也有同样的问题...

标签: angular ionic-framework ionic3 ionic4


【解决方案1】:

问题是由这行代码引起的:

testUrl = testUrl.replace('file:///', 'http://localhost:8080/');
如果正在访问的文件存储在服务器上,则使用

localhost。由于此文件存储在设备上,因此需要文件路径。您可以使用问题所附图片中指定的fullpathlocalURL 下的路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-02
    • 2017-04-20
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    相关资源
    最近更新 更多