除 IE 之外的现代浏览器处理 MJPEG
( Motion JPEG )。 Here是一个例子 fiddle 。
我可以检测到对 MJPEG
的支持吗?我已经看过 Modernizr徒劳无功。
最佳答案
Modernizr only supports the following formats for detection right now: ogg, webm and h264.
video 元素有一个名为 canPlayType(format)
的调用,这实际上是您唯一的选择(如果它适用于 mjpg)。您的检测逻辑看起来像这样(不是格式会有所不同)。
var videoElement = document.createElement('video');
if(!!videoElement.canPlayType)
{
var browserConfidence = videoElement.canPlayType('video/mjpeg; codecs="insert, them"');
if(browserConfidence == "probably")
{
// high confidence
}
else if(browserConfidence == "maybe")
{
// low confidence
}
else
{
// no confidence... it definately will not play
}
}
确保你visit the W3C's information on canPlayType .看起来 mime 类型应该是“video/mjpeg”而不是您之前指定的“video/mjpg”。
关于javascript - 如何检测浏览器是否支持 MJPEG?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8521651/