【问题标题】:Mp3 file uploaded to Ghpages won't play. I have tried using rawgit to host the file and githubusercontent and it still won't work?上传到 Ghpages 的 Mp3 文件无法播放。我曾尝试使用 rawgit 来托管文件和 githubusercontent,但它仍然无法正常工作?
【发布时间】:2019-01-04 01:25:49
【问题描述】:

这是我拥有的本地代码,它可以工作。

  <audio preload="auto" autoplay="autoplay">
    <source src="halloween_theme.mp3" type="audio/mp3" />
  </audio>

这是我从另一个 stackoverflow 中读到的内容

  <audio preload="auto" autoplay="autoplay">
    <source src="https://raw.githubusercontent.com/jerryhoglen/halloween_site/master/halloween_theme.mp3" type="audio/mp3" />
  </audio>

我已尝试将曲目托管在 google drive 上,但它也无法正常工作。

【问题讨论】:

  • src https://raw.githubusercontent.com/jerryhoglen/halloween_site/master/halloween_theme.mp3 将找不到页面。仔细检查网址
  • 你确定你的文件上传到 GitHub 成功了吗,因为你不能 git 超过 100mb 和上传超过 25mb(通过GitHub's website)到 GitHub。

标签: html github html5-audio github-pages


【解决方案1】:

我找到了答案。 Chrome 已更新并删除了自动播放功能,但有一个使用 iframe 播放 mp3 音频的解决方法。

  <iframe src="audio/halloween_theme.mp3" allow="autoplay" style="display:none" id="iframeAudio"></iframe>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-17
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-30
    相关资源
    最近更新 更多