首页 > 解决方案 > [src]="sermon?.sermonVideo" 不工作。虽然它适用于图片

问题描述

所以……我正在尝试从 data.json 获取我的页面上的视频

奇怪的是,如果我直接获取视频,它可以正常工作。

这是我的代码,然后我会解释更多。

html

<div class="sermon-background">
<div class="topRoom" >
  <video controls="controls" preload="metadata" autoplay="autoplay" webkit-playsinline="webkit-playsinline" class="videoPlayer">
   <source [src]="sermon?.sermonVideo" type="video/mp4" />
  </video>
</div>
<div class="topRoom2">
  <svg width="100%" height="calc(1vw + 1vh + 6vmin)">
    <rect width="100%" height="calc(1vw + 1vh + 6vmin)" style="fill:rgba(44, 44, 44, 0.548);stroke-width:0;stroke:rgb(60,200,160)" />
    <text dominant-baseline="middle" text-anchor="middle" x="50%" y="55%" fill="white" style="font-size: calc(1vw + 1vh + 2vmin); font-family: 'Quicksand', sans-serif; font-weight: calc(.1vw + .1vh + .1vmin); text-shadow: 1px 1px 0px rgba(44, 44, 44, 0.445), 2px 2px 0px rgba(44, 44, 44,0.445), 3px 3px 0px rgba(44, 44, 44, 0.445) ">{{sermon?.name}}</text>
  </svg>
</div >
<img [src]="sermon?.profilePic" [alt]="sermon?.name">

因此,使用相同方法来自同一位置的 profilePic 可以正常加载。

另外,如果我使用“src=assets/videos/Sermon1.mp4”,效果很好。

这是我的 data.json

      "name": "Finding Grace",
  "profilePic": "/assets/img/stuffs/PastorEvaFace.jpg",
  "sermonVideo": "/assets/videos/Sermon1.mp4",
  "about": "Learn to fnid Grace in every circumstance and realize just how much God has given you.",
  "sum": "God has given us grace, we just need to open our eyes.",
  "location": "Everywhere",
  "id": "1"

有人知道为什么它不能运行视频吗?profilePic 运行良好...

我在尝试视频时收到错误“没有支持格式和 mime 类型的视频”

提前感谢您的高峰

标签: htmljsonangularionic-frameworkionic5

解决方案



推荐阅读