HTML嵌入了autoplay =“false”,但仍然会自动播放

时间:2013-11-29 13:04:57

标签: html audio

this website的首页,有一个标题为“全国广播广告活动ForACURE”的粘性帖子,其中包含以下HTML:

<embed type="audio/x-wav" src="http://www.foracure.org.au/wp-content/uploads/FOR-A-CURE-RADIO-Daniel-45sec.mp3" autoplay="false" height="20" width="200" autostart="false">

但是,当我在Chrome v31.0.1650.57 m中加载此网站时,即使自动播放和自动启动都设置为false,音频也会自动播放。

是否有更好的跨浏览器方法来嵌入此音频?

9 个答案:

答案 0 :(得分:8)

Chrome似乎无法理解truefalse。 请改用autostart="1"autostart="0"


来源:( Google网上论坛:https://productforums.google.com/forum/#!topic/chrome/LkA8FoBoleU

答案 1 :(得分:3)

<video width="320" height="240" controls autoplay>
<source src="movie.mp4" type="video/mp4"> Your browser does not support the video tag.
</video>

删除autoplay 如果你想禁用自动播放视频。

答案 2 :(得分:1)

只需将mime类型更改为:type="audio/mpeg",这样chrome就会尊重autostart="false"参数。

答案 3 :(得分:1)

使用js设置如下:

<script>
    var vid = document.getElementById("myVideo");
    vid.autoplay = false;
    vid.load();
</script>

设置&#34; true&#34;打开outoplay 设置&#34;假&#34;关闭outoplay

http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_av_prop_autoplay

答案 4 :(得分:0)

这将阻止浏览器自动播放音频。

HTML

#include <stdio.h>
#include <string.h>

int main(void)
{
    float f = 10./7;
    char  bytes[4];

    // Check that float is the same size as the array we provide.
    _Static_assert(sizeof f == sizeof bytes, "float mus be four bytes.");

    // Copy bytes from the float to the array.
    memcpy(bytes, &f, sizeof bytes);

    // Show the bytes.
    for (size_t i = 0; i < sizeof bytes; ++i)
        printf("Byte %zu is 0x%02x.\n", i, (unsigned char) bytes[i]);

    // Copy the bytes from the array to another float.
    float g;
    memcpy(&g, bytes, sizeof g);

    // Show the resulting float.
    printf("g = %g.\n", g);
}

jQuery

<audio type="audio/wav" id="audio" autoplay="false" autostart="false"></audio>

答案 5 :(得分:0)

将false替换为0

答案 6 :(得分:0)

上面发布的所有视频设置都不适用于我使用 HTML5 中的 embedobject 元素测试的现代浏览器(如 Firefox)。对于 videoaudio 元素,他们确实停止了自动播放。对于 embedobject,他们没有。

我使用 embedobject 元素使用几种不同的媒体类型以及 HTML 属性(例如 autostartautoplay)对此进行了测试.无论多个浏览器中的设置如何组合,这些视频始终会播放。同样,使用较新的 HTML5 videoaudio 元素时,这不是问题,只是在使用 embedobject 时。

事实证明,视频“自动播放”的新浏览器设置已更改。 Firefox 现在将忽略这些标签上的 autoplay 属性并继续播放视频除非您在浏览器设置中明确设置为“阻止音频和视频”自动播放

要在 Firefox 中执行此操作,我已发布以下设置:

  1. 打开您的 Firefox 浏览器,点击菜单按钮,然后选择“选项”
  2. 选择“隐私和安全”面板并向下滚动到“权限”部分
  3. 找到“自动播放”并点击“设置”按钮。在下拉列表中将其更改为阻止音频和视频。默认值只是音频。

当在网页中使用 objectembed 元素显示视频时,您的视频现在不会自动播放。

答案 7 :(得分:-1)

以下代码帮助我解决了同样的问题。 如果有帮助,请告诉我。

<!DOCTYPE html>
<html>
<body>


<audio controls>

<source src="YOUR AUDIO FILE" type="audio/mpeg">
Your browser does not support the audio element.
</audio>



</body>
</html>

答案 8 :(得分:-2)

问题是你的插件。要解决这个问题,只需输入以下地址:

chrome://flags/#enable-NPAPI

单击激活NPAPI,最后在页面底部重新启动。

相关问题