简体   繁体   English

Meteor Safari 视频无法显示

[英]Meteor Safari Video Wont Display

I am not sure if this has always been an issue, but simple html5 videos simply will not display for me in Safari.我不确定这是否一直是一个问题,但简单的 html5 视频根本不会在 Safari 中显示。 Both mobile and desktop.移动端和桌面端。

I have gone so far as to install Meteor fresh, and add both a local mp4 file and webm file and even tried a know working video file from here: https://www.w3schools.com/html/html5_video.asp我什至重新安装了 Meteor,并添加了本地 mp4 文件和 webm 文件,甚至从这里尝试了一个已知的工作视频文件: https : //www.w3schools.com/html/html5_video.asp

I have used the identical html5 video code from other frameworks and static html (all that work on those platforms) but alas they do not work either.我使用了来自其他框架的相同 html5 视频代码和静态 html(所有这些都在这些平台上工作),但可惜它们也不起作用。

There are no errors to speak of (console or terminal) and everything else works/loads fine.没有错误可言(控制台或终端),其他一切正常/加载正常。

Give it a shot.试一试。 Add a new meteor install and add the following html5 video:添加新的流星安装并添加以下 html5 视频:

<video playsinline autoplay muted loop> <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4" /> </video>

Any assistance would be greatly appreciated!任何帮助将不胜感激!

Safari seems to choke on rendering the video without controls. Safari 似乎无法在没有控件的情况下渲染视频。 I was able to make it work by manually creating the video element (sub-optimal)我能够通过手动创建视频元素来使其工作(次优)

Template.video.onRendered(function () {
  const instance = this
  const parent = instance.find('#video-parent')
  instance.video = document.createElement('video')
  instance.video.classList.add('rounded-lg')
  instance.video.classList.add('img-fluid')
  instance.video.src = instance.data.src ? instance.data.src : ''
  instance.video.addEventListener('canplaythrough', () => {
    console.log(instance.video)
    instance.video.controls = true
    //Meteor.setTimeout(()=>{
    //  instance.video.play()
    //}, 500)
  })
  parent.append(instance.video)
})
Template.video.onDestroyed(function () {
  const instance = this
  instance.video.pause()
  instance.video.remove()
})

with

<template name="video">
 <div id="video-parent"></div>
</template>

<template name+"something">
 {{>video src="https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_2mb.mp4"}}
</template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM