javascript - IE 不从 php 脚本播放 mp3

标签 javascript php html

我只在 IE 中播放音频时遇到问题。 控制台不显示错误。我从 php 脚本获取文件并设置此 header :

    $mime_type = "audio/mpeg";
    header("Content-Type: {$mime_type}");
    header('Content-Length: '.filesize($file));
    readfile($file);

在 js 中:

    audio.src = source;
    audio.load();
    audio.addEventListener('canplay', function(){
        audio.play();
    }, true); 

在 php 脚本的 source 路径中。

最佳答案

Add this meta tag to the head:

< meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

and also

Try

audio/vnd.wave

because some browser do attempt content fixing wrong MIME types.

关于javascript - IE 不从 php 脚本播放 mp3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38393702/

相关文章:

javascript 匹配替换文本

javascript - HTML 应用程序的网格

php - 重定向在 laravel 5 中不起作用

javascript - 使 body 为浏览器窗口的 100% 高度

javascript - IE中的CSS翻转动画: Turned side shows mirror content

javascript - 空 Div 不会在 IE6 中注册 CSS 事件

javascript - XMLHttpRequest 文件上传在 IE11 中不起作用

javascript - JavaScript 中的事件循环和 Node.js 中的异步非阻塞 I/O 有什么区别?

PHP:刷新我的代码

php - Laravel 配置强制 https