是否可以使用HTML5播放shoutcast/icecast流?
如果是这样,我该如何实施呢?
我收到DOMException:无法加载,因为在video.play()中找不到支持的源 ; 线.我只是在添加了video.setAttribute('crossorigin','anonymous')之后才遇到这个问题; 我正在开发移动应用程序,所以对于交叉起源我需要添加这一行.更新chrome 50版本后,我在此之前遇到此问题,它可以正常工作.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head>
<body>
<script>
var video = document.createElement( 'video' );
video.id = 'video';
video.type = ' video/mp4; codecs="theora, vorbis" ';
video.src = "http://abcde.com/img/videos/what_is_design_thinking.mp4";
video.volume = .1;
video.setAttribute('crossorigin', 'anonymous');
video.load(); // must call after setting/changing source
$('body').html(video);
video.play();
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
$('body').append(canvas);
video.addEventListener('play', function() {
var $this = this; //cache
(function loop() {
if (!$this.paused && !$this.ended) {
ctx.drawImage($this, 0, 0);
setTimeout(loop, 1000 …Run Code Online (Sandbox Code Playgroud) 自从更新到v45后,Chrome似乎不再播放选择的MP3文件.这不是全面的,其他一些MP3文件仍在播放.Chrome v44没有显示任何问题并播放了所有文件.
这个问题在运行各种版本的Windows(32位和64位)的许多计算机上很常见,回滚将允许文件播放.然而,这对于客户端PC来说不是可行的解决方案,也不适合前进.
在检查文件本身时,我无法记录可播放和不可播放文件之间的任何明显差异(除了持续时间,大小和名称;持续时间和大小在两者中相当分散,因此它不像超过设定大小的文件不工作;有些人做,有些人不做.)
保存文件并使用MediaInfo进行检查会显示以下信息
General
Complete name : D:\Desktop\L03-02n.mp3
Format : MPEG Audio
File size : 3.41 MiB
Duration : 1mn 29s
Overall bit rate mode : Constant
Overall bit rate : 320 Kbps
Genre : Abstract
Writing library : LAME3.82
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Duration : 1mn 29s
Bit rate mode : Constant
Bit rate : 320 Kbps
Channel(s) : 1 channel
Sampling rate : 44.1 KHz …Run Code Online (Sandbox Code Playgroud) 我正在尝试遵循 Wes Bos 的 Javascript30 教程,但是当我尝试制作“Javascript Drum Kit”网站时,我无法播放任何声音。那里有适当的声音文件,但是当我按下按键尝试播放声音时,在检查控制台时会出现以下错误消息:
jsdrumkit.html:66 - Uncaught (in promise) DOMException: The element has no supported sources.
这是该网站的 JavaScript:
function playSound(e){
//querySelector() is just when you need a single return value
//audio[input] is an attribute selector, and it works just like its CSS counterpart.
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
if(!audio) return;
audio.currentTime = 0; //rewind the file to the start
audio.play(); //**line 66 in the site's code**
console.log(key);
key.classList.toggle('playing');
}
function removeTransition(e) {
if(e.propertyName …Run Code Online (Sandbox Code Playgroud)