HTML5 视频持续时间无限,而 readyState = 4
Posted
技术标签:
【中文标题】HTML5 视频持续时间无限,而 readyState = 4【英文标题】:HTML5 video duration infinity while readyState = 4 【发布时间】:2019-02-09 13:51:04 【问题描述】:我正在创建一个自定义的 html5 视频播放器,可以播放直播、录制直播和播放常规视频文件。录制我正在使用 RecordRTC。一切运行良好,但我需要创建一个自定义搜索栏。为此,我只是简单地使用
var seekerPosition = (video.currentTime * 1000) / (video.duration * 1000);
var seekerValue = seekerPosition * 100 + "%";
并将此值添加到栏的 css 宽度。但是我的搜索栏会在视频开始播放一段时间后开始。从这个question 我发现视频持续时间只有在视频的 readyState 改变时才可用。所以我检查了它,即使 readyState 是 4,持续时间显示 Infinity。这是我的代码:
<video id="video" class="video" muted></video>
function startTracking()
reqId = requestAnimationFrame(function play()
console.log("currentTime = " + video.currentTime + " , duration = " + video.duration + " , readyState is " + video.readyState);
var seekerPosition = (video.currentTime * 1000) / (video.duration * 1000);
var seekerValue = seekerPosition * 100 + "%";
//console.log("( " + (video.currentTime * 1000) + " / " + (video.duration * 1000) + " ) * 100 = " + seekerValue);
$(seeker).css("width", seekerValue);
reqId = requestAnimationFrame(play);
);
;
function stopTracking()
if (reqId)
cancelAnimationFrame(reqId);
;
function togglePlayPause()
if ($(playPause).hasClass("play"))
$(playPause).addClass("pause").removeClass("play");
video.pause();
if (recorder === null && liveStream === null)
stopTracking();
else if ($(playPause).hasClass("pause"))
$(playPause).addClass("play").removeClass("pause");
video.play();
if (recorder === null && liveStream === null)
startTracking();
我刚刚录制了一个 7 秒的视频,然后播放了它,我还向您展示了 console.log
结果。此结果由startTracking
函数生成。
currentTime = 0.221292 , duration = Infinity , readyState is 4
currentTime = 0.238313 , duration = Infinity , readyState is 4
currentTime = 0.25625 , duration = Infinity , readyState is 4
currentTime = 0.271875 , duration = Infinity , readyState is 4
currentTime = 0.288854 , duration = Infinity , readyState is 4
currentTime = 0.304854 , duration = Infinity , readyState is 4
currentTime = 0.322396 , duration = Infinity , readyState is 4
currentTime = 0.338375 , duration = Infinity , readyState is 4
currentTime = 0.355396 , duration = Infinity , readyState is 4
currentTime = 0.371375 , duration = Infinity , readyState is 4
currentTime = 0.388375 , duration = Infinity , readyState is 4
currentTime = 0.405313 , duration = Infinity , readyState is 4
currentTime = 0.421396 , duration = Infinity , readyState is 4
currentTime = 0.438438 , duration = Infinity , readyState is 4
currentTime = 0.456375 , duration = Infinity , readyState is 4
currentTime = 0.472396 , duration = Infinity , readyState is 4
currentTime = 0.488396 , duration = Infinity , readyState is 4
currentTime = 0.505396 , duration = Infinity , readyState is 4
currentTime = 0.521417 , duration = Infinity , readyState is 4
currentTime = 0.539375 , duration = Infinity , readyState is 4
currentTime = 0.555417 , duration = Infinity , readyState is 4
currentTime = 0.571292 , duration = Infinity , readyState is 4
currentTime = 0.588292 , duration = Infinity , readyState is 4
currentTime = 0.605313 , duration = Infinity , readyState is 4
currentTime = 0.622396 , duration = Infinity , readyState is 4
currentTime = 0.639438 , duration = Infinity , readyState is 4
currentTime = 0.655417 , duration = Infinity , readyState is 4
currentTime = 0.671396 , duration = Infinity , readyState is 4
currentTime = 0.688354 , duration = Infinity , readyState is 4
currentTime = 0.705354 , duration = Infinity , readyState is 4
currentTime = 0.721479 , duration = Infinity , readyState is 4
currentTime = 0.738375 , duration = Infinity , readyState is 4
currentTime = 0.755396 , duration = Infinity , readyState is 4
currentTime = 0.772375 , duration = Infinity , readyState is 4
currentTime = 0.789333 , duration = Infinity , readyState is 4
currentTime = 0.805333 , duration = Infinity , readyState is 4
currentTime = 0.821417 , duration = Infinity , readyState is 4
currentTime = 0.839417 , duration = Infinity , readyState is 4
currentTime = 0.856375 , duration = Infinity , readyState is 4
currentTime = 0.872354 , duration = Infinity , readyState is 4
currentTime = 0.888417 , duration = Infinity , readyState is 4
currentTime = 0.905417 , duration = Infinity , readyState is 4
currentTime = 0.921417 , duration = Infinity , readyState is 4
currentTime = 0.939333 , duration = Infinity , readyState is 4
currentTime = 0.955417 , duration = Infinity , readyState is 4
currentTime = 0.972354 , duration = Infinity , readyState is 4
currentTime = 0.988313 , duration = Infinity , readyState is 4
currentTime = 1.005313 , duration = Infinity , readyState is 4
currentTime = 1.021396 , duration = Infinity , readyState is 4
currentTime = 1.038313 , duration = Infinity , readyState is 4
currentTime = 1.05625 , duration = Infinity , readyState is 4
currentTime = 1.071271 , duration = Infinity , readyState is 4
currentTime = 1.088271 , duration = Infinity , readyState is 4
currentTime = 1.105229 , duration = Infinity , readyState is 4
currentTime = 1.121958 , duration = Infinity , readyState is 4
currentTime = 1.138938 , duration = Infinity , readyState is 4
currentTime = 1.155417 , duration = Infinity , readyState is 4
currentTime = 1.171333 , duration = Infinity , readyState is 4
currentTime = 1.188333 , duration = Infinity , readyState is 4
currentTime = 1.206333 , duration = Infinity , readyState is 4
currentTime = 1.221938 , duration = Infinity , readyState is 4
currentTime = 1.238396 , duration = Infinity , readyState is 4
currentTime = 1.257396 , duration = Infinity , readyState is 4
currentTime = 1.271354 , duration = Infinity , readyState is 4
currentTime = 1.288354 , duration = Infinity , readyState is 4
currentTime = 1.306354 , duration = Infinity , readyState is 4
currentTime = 1.321333 , duration = Infinity , readyState is 4
currentTime = 1.338271 , duration = Infinity , readyState is 4
currentTime = 1.35525 , duration = Infinity , readyState is 4
currentTime = 1.372229 , duration = Infinity , readyState is 4
currentTime = 1.389167 , duration = Infinity , readyState is 4
currentTime = 1.406167 , duration = Infinity , readyState is 4
currentTime = 1.421208 , duration = Infinity , readyState is 4
currentTime = 1.43925 , duration = Infinity , readyState is 4
currentTime = 1.455229 , duration = Infinity , readyState is 4
currentTime = 1.471188 , duration = Infinity , readyState is 4
currentTime = 1.488229 , duration = Infinity , readyState is 4
currentTime = 1.506229 , duration = Infinity , readyState is 4
currentTime = 1.521271 , duration = Infinity , readyState is 4
currentTime = 1.539208 , duration = Infinity , readyState is 4
currentTime = 1.55525 , duration = Infinity , readyState is 4
currentTime = 1.572167 , duration = Infinity , readyState is 4
currentTime = 1.589167 , duration = Infinity , readyState is 4
currentTime = 1.605167 , duration = Infinity , readyState is 4
currentTime = 1.622271 , duration = Infinity , readyState is 4
currentTime = 1.639208 , duration = Infinity , readyState is 4
currentTime = 1.655167 , duration = Infinity , readyState is 4
currentTime = 1.67125 , duration = Infinity , readyState is 4
currentTime = 1.689188 , duration = Infinity , readyState is 4
currentTime = 1.705188 , duration = Infinity , readyState is 4
currentTime = 1.721229 , duration = Infinity , readyState is 4
currentTime = 1.73825 , duration = Infinity , readyState is 4
currentTime = 1.755188 , duration = Infinity , readyState is 4
currentTime = 1.772667 , duration = Infinity , readyState is 4
currentTime = 1.788667 , duration = Infinity , readyState is 4
currentTime = 1.805667 , duration = Infinity , readyState is 4
currentTime = 1.821292 , duration = Infinity , readyState is 4
currentTime = 1.838292 , duration = Infinity , readyState is 4
currentTime = 1.855313 , duration = Infinity , readyState is 4
currentTime = 1.871292 , duration = Infinity , readyState is 4
currentTime = 1.888292 , duration = Infinity , readyState is 4
currentTime = 1.90525 , duration = Infinity , readyState is 4
currentTime = 1.92125 , duration = Infinity , readyState is 4
currentTime = 1.938271 , duration = Infinity , readyState is 4
currentTime = 1.955313 , duration = Infinity , readyState is 4
currentTime = 1.97125 , duration = Infinity , readyState is 4
currentTime = 1.98825 , duration = Infinity , readyState is 4
currentTime = 2.006229 , duration = Infinity , readyState is 4
currentTime = 2.021313 , duration = Infinity , readyState is 4
currentTime = 2.038292 , duration = Infinity , readyState is 4
currentTime = 2.055604 , duration = Infinity , readyState is 4
currentTime = 2.07125 , duration = Infinity , readyState is 4
currentTime = 2.08825 , duration = Infinity , readyState is 4
currentTime = 2.106313 , duration = Infinity , readyState is 4
currentTime = 2.122313 , duration = Infinity , readyState is 4
currentTime = 2.138292 , duration = Infinity , readyState is 4
currentTime = 2.155333 , duration = Infinity , readyState is 4
currentTime = 2.172271 , duration = Infinity , readyState is 4
currentTime = 2.188271 , duration = Infinity , readyState is 4
currentTime = 2.205271 , duration = Infinity , readyState is 4
currentTime = 2.221208 , duration = Infinity , readyState is 4
currentTime = 2.238208 , duration = Infinity , readyState is 4
currentTime = 2.255667 , duration = Infinity , readyState is 4
currentTime = 2.270729 , duration = Infinity , readyState is 4
currentTime = 2.289292 , duration = Infinity , readyState is 4
currentTime = 2.306292 , duration = Infinity , readyState is 4
currentTime = 2.321292 , duration = Infinity , readyState is 4
currentTime = 2.338313 , duration = Infinity , readyState is 4
currentTime = 2.356292 , duration = Infinity , readyState is 4
currentTime = 2.372229 , duration = Infinity , readyState is 4
currentTime = 2.389229 , duration = Infinity , readyState is 4
currentTime = 2.406229 , duration = Infinity , readyState is 4
currentTime = 2.421313 , duration = Infinity , readyState is 4
currentTime = 2.439229 , duration = Infinity , readyState is 4
currentTime = 2.455229 , duration = Infinity , readyState is 4
currentTime = 2.471188 , duration = Infinity , readyState is 4
currentTime = 2.489188 , duration = Infinity , readyState is 4
currentTime = 2.505188 , duration = Infinity , readyState is 4
currentTime = 2.521229 , duration = Infinity , readyState is 4
currentTime = 2.538208 , duration = Infinity , readyState is 4
currentTime = 2.556208 , duration = Infinity , readyState is 4
currentTime = 2.571188 , duration = Infinity , readyState is 4
currentTime = 2.588188 , duration = Infinity , readyState is 4
currentTime = 2.605167 , duration = Infinity , readyState is 4
currentTime = 2.622208 , duration = Infinity , readyState is 4
currentTime = 2.639188 , duration = Infinity , readyState is 4
currentTime = 2.655188 , duration = Infinity , readyState is 4
currentTime = 2.672229 , duration = Infinity , readyState is 4
currentTime = 2.688188 , duration = Infinity , readyState is 4
currentTime = 2.706188 , duration = Infinity , readyState is 4
currentTime = 2.722646 , duration = Infinity , readyState is 4
currentTime = 2.740667 , duration = Infinity , readyState is 4
currentTime = 2.756979 , duration = Infinity , readyState is 4
currentTime = 2.772292 , duration = Infinity , readyState is 4
currentTime = 2.789229 , duration = Infinity , readyState is 4
currentTime = 2.805229 , duration = Infinity , readyState is 4
currentTime = 2.821313 , duration = Infinity , readyState is 4
currentTime = 2.838333 , duration = Infinity , readyState is 4
currentTime = 2.85625 , duration = Infinity , readyState is 4
currentTime = 2.872229 , duration = Infinity , readyState is 4
currentTime = 2.889271 , duration = Infinity , readyState is 4
currentTime = 2.905271 , duration = Infinity , readyState is 4
currentTime = 2.921292 , duration = Infinity , readyState is 4
currentTime = 2.938271 , duration = Infinity , readyState is 4
currentTime = 2.957271 , duration = Infinity , readyState is 4
currentTime = 2.971313 , duration = Infinity , readyState is 4
currentTime = 2.988292 , duration = Infinity , readyState is 4
currentTime = 3.005292 , duration = Infinity , readyState is 4
currentTime = 3.022229 , duration = Infinity , readyState is 4
currentTime = 3.038313 , duration = Infinity , readyState is 4
currentTime = 3.055271 , duration = Infinity , readyState is 4
currentTime = 3.07125 , duration = Infinity , readyState is 4
currentTime = 3.090604 , duration = Infinity , readyState is 4
currentTime = 3.107604 , duration = Infinity , readyState is 4
currentTime = 3.120708 , duration = Infinity , readyState is 4
currentTime = 3.138292 , duration = Infinity , readyState is 4
currentTime = 3.155271 , duration = Infinity , readyState is 4
currentTime = 3.17125 , duration = Infinity , readyState is 4
currentTime = 3.18825 , duration = Infinity , readyState is 4
currentTime = 3.205313 , duration = Infinity , readyState is 4
currentTime = 3.221292 , duration = Infinity , readyState is 4
currentTime = 3.239313 , duration = Infinity , readyState is 4
currentTime = 3.255292 , duration = Infinity , readyState is 4
currentTime = 3.27125 , duration = Infinity , readyState is 4
currentTime = 3.289229 , duration = Infinity , readyState is 4
currentTime = 3.306229 , duration = Infinity , readyState is 4
currentTime = 3.321625 , duration = Infinity , readyState is 4
currentTime = 3.338208 , duration = Infinity , readyState is 4
currentTime = 3.356292 , duration = Infinity , readyState is 4
currentTime = 3.37225 , duration = Infinity , readyState is 4
currentTime = 3.38825 , duration = Infinity , readyState is 4
currentTime = 3.405292 , duration = Infinity , readyState is 4
currentTime = 3.42125 , duration = Infinity , readyState is 4
currentTime = 3.438271 , duration = Infinity , readyState is 4
currentTime = 3.456271 , duration = Infinity , readyState is 4
currentTime = 3.471313 , duration = Infinity , readyState is 4
currentTime = 3.489208 , duration = Infinity , readyState is 4
currentTime = 3.506208 , duration = Infinity , readyState is 4
currentTime = 3.52125 , duration = Infinity , readyState is 4
currentTime = 3.538313 , duration = Infinity , readyState is 4
currentTime = 3.55525 , duration = Infinity , readyState is 4
currentTime = 3.571188 , duration = Infinity , readyState is 4
currentTime = 3.588188 , duration = Infinity , readyState is 4
currentTime = 3.605313 , duration = Infinity , readyState is 4
currentTime = 3.621292 , duration = Infinity , readyState is 4
currentTime = 3.640688 , duration = Infinity , readyState is 4
currentTime = 3.657604 , duration = Infinity , readyState is 4
currentTime = 3.672333 , duration = Infinity , readyState is 4
currentTime = 3.688333 , duration = Infinity , readyState is 4
currentTime = 3.705188 , duration = Infinity , readyState is 4
currentTime = 3.722208 , duration = Infinity , readyState is 4
currentTime = 3.738271 , duration = Infinity , readyState is 4
currentTime = 3.755271 , duration = Infinity , readyState is 4
currentTime = 3.771292 , duration = Infinity , readyState is 4
currentTime = 3.788292 , duration = Infinity , readyState is 4
currentTime = 3.805292 , duration = Infinity , readyState is 4
currentTime = 3.821271 , duration = Infinity , readyState is 4
currentTime = 3.838313 , duration = Infinity , readyState is 4
currentTime = 3.856646 , duration = Infinity , readyState is 4
currentTime = 3.872229 , duration = Infinity , readyState is 4
currentTime = 3.888229 , duration = Infinity , readyState is 4
currentTime = 3.905229 , duration = Infinity , readyState is 4
currentTime = 3.921229 , duration = Infinity , readyState is 4
currentTime = 3.938229 , duration = Infinity , readyState is 4
currentTime = 3.955188 , duration = Infinity , readyState is 4
currentTime = 3.971542 , duration = Infinity , readyState is 4
currentTime = 3.989625 , duration = Infinity , readyState is 4
currentTime = 4.007625 , duration = Infinity , readyState is 4
currentTime = 4.020688 , duration = Infinity , readyState is 4
currentTime = 4.038313 , duration = Infinity , readyState is 4
currentTime = 4.05525 , duration = Infinity , readyState is 4
currentTime = 4.071313 , duration = Infinity , readyState is 4
currentTime = 4.088313 , duration = Infinity , readyState is 4
currentTime = 4.106229 , duration = Infinity , readyState is 4
currentTime = 4.121646 , duration = Infinity , readyState is 4
currentTime = 4.139625 , duration = Infinity , readyState is 4
currentTime = 4.155313 , duration = Infinity , readyState is 4
currentTime = 4.171229 , duration = Infinity , readyState is 4
currentTime = 4.18925 , duration = Infinity , readyState is 4
currentTime = 4.20525 , duration = Infinity , readyState is 4
currentTime = 4.222271 , duration = Infinity , readyState is 4
currentTime = 4.238292 , duration = Infinity , readyState is 4
currentTime = 4.256313 , duration = Infinity , readyState is 4
currentTime = 4.271292 , duration = Infinity , readyState is 4
currentTime = 4.289229 , duration = Infinity , readyState is 4
currentTime = 4.304229 , duration = Infinity , readyState is 4
currentTime = 4.322313 , duration = Infinity , readyState is 4
currentTime = 4.338292 , duration = Infinity , readyState is 4
currentTime = 4.354292 , duration = Infinity , readyState is 4
currentTime = 4.372229 , duration = Infinity , readyState is 4
currentTime = 4.389229 , duration = Infinity , readyState is 4
currentTime = 4.404229 , duration = Infinity , readyState is 4
currentTime = 4.422333 , duration = 6.96 , readyState is 4
currentTime = 4.439313 , duration = 6.96 , readyState is 4
currentTime = 4.454271 , duration = 6.96 , readyState is 4
currentTime = 4.472292 , duration = 6.96 , readyState is 4
currentTime = 4.489292 , duration = 6.96 , readyState is 4
currentTime = 4.504292 , duration = 6.96 , readyState is 4
currentTime = 4.521313 , duration = 6.96 , readyState is 4
currentTime = 4.539271 , duration = 6.96 , readyState is 4
currentTime = 4.555313 , duration = 6.96 , readyState is 4
currentTime = 4.571271 , duration = 6.96 , readyState is 4
currentTime = 4.589646 , duration = 6.96 , readyState is 4
currentTime = 4.604646 , duration = 6.96 , readyState is 4
currentTime = 4.621625 , duration = 6.96 , readyState is 4
currentTime = 4.639333 , duration = 6.96 , readyState is 4
currentTime = 4.655292 , duration = 6.96 , readyState is 4
currentTime = 4.671292 , duration = 6.96 , readyState is 4
currentTime = 4.688292 , duration = 6.96 , readyState is 4
currentTime = 4.704313 , duration = 6.96 , readyState is 4
currentTime = 4.721313 , duration = 6.96 , readyState is 4
currentTime = 4.739313 , duration = 6.96 , readyState is 4
currentTime = 4.754313 , duration = 6.96 , readyState is 4
currentTime = 4.771271 , duration = 6.96 , readyState is 4
currentTime = 4.788271 , duration = 6.96 , readyState is 4
currentTime = 4.804229 , duration = 6.96 , readyState is 4
currentTime = 4.822333 , duration = 6.96 , readyState is 4
currentTime = 4.839313 , duration = 6.96 , readyState is 4
currentTime = 4.855271 , duration = 6.96 , readyState is 4
currentTime = 4.871313 , duration = 6.96 , readyState is 4
currentTime = 4.889188 , duration = 6.96 , readyState is 4
currentTime = 4.904188 , duration = 6.96 , readyState is 4
currentTime = 4.92125 , duration = 6.96 , readyState is 4
currentTime = 4.938208 , duration = 6.96 , readyState is 4
currentTime = 4.954229 , duration = 6.96 , readyState is 4
currentTime = 4.972188 , duration = 6.96 , readyState is 4
currentTime = 4.989646 , duration = 6.96 , readyState is 4
currentTime = 5.006646 , duration = 6.96 , readyState is 4
currentTime = 5.024625 , duration = 6.96 , readyState is 4
currentTime = 5.05425 , duration = 6.96 , readyState is 4
currentTime = 5.071292 , duration = 6.96 , readyState is 4
currentTime = 5.089271 , duration = 6.96 , readyState is 4
currentTime = 5.104271 , duration = 6.96 , readyState is 4
currentTime = 5.122208 , duration = 6.96 , readyState is 4
currentTime = 5.138229 , duration = 6.96 , readyState is 4
currentTime = 5.15525 , duration = 6.96 , readyState is 4
currentTime = 5.171167 , duration = 6.96 , readyState is 4
currentTime = 5.188146 , duration = 6.96 , readyState is 4
currentTime = 5.204146 , duration = 6.96 , readyState is 4
currentTime = 5.221313 , duration = 6.96 , readyState is 4
currentTime = 5.239229 , duration = 6.96 , readyState is 4
currentTime = 5.254208 , duration = 6.96 , readyState is 4
currentTime = 5.27125 , duration = 6.96 , readyState is 4
currentTime = 5.289271 , duration = 6.96 , readyState is 4
currentTime = 5.304271 , duration = 6.96 , readyState is 4
currentTime = 5.32125 , duration = 6.96 , readyState is 4
currentTime = 5.338229 , duration = 6.96 , readyState is 4
currentTime = 5.355229 , duration = 6.96 , readyState is 4
currentTime = 5.371167 , duration = 6.96 , readyState is 4
currentTime = 5.388167 , duration = 6.96 , readyState is 4
currentTime = 5.405167 , duration = 6.96 , readyState is 4
currentTime = 5.42125 , duration = 6.96 , readyState is 4
currentTime = 5.438229 , duration = 6.96 , readyState is 4
currentTime = 5.454229 , duration = 6.96 , readyState is 4
currentTime = 5.47125 , duration = 6.96 , readyState is 4
currentTime = 5.489146 , duration = 6.96 , readyState is 4
currentTime = 5.504146 , duration = 6.96 , readyState is 4
currentTime = 5.52125 , duration = 6.96 , readyState is 4
currentTime = 5.539229 , duration = 6.96 , readyState is 4
currentTime = 5.555229 , duration = 6.96 , readyState is 4
currentTime = 5.571167 , duration = 6.96 , readyState is 4
currentTime = 5.588167 , duration = 6.96 , readyState is 4
currentTime = 5.605146 , duration = 6.96 , readyState is 4
currentTime = 5.622313 , duration = 6.96 , readyState is 4
currentTime = 5.639229 , duration = 6.96 , readyState is 4
currentTime = 5.655208 , duration = 6.96 , readyState is 4
currentTime = 5.67125 , duration = 6.96 , readyState is 4
currentTime = 5.689167 , duration = 6.96 , readyState is 4
currentTime = 5.704167 , duration = 6.96 , readyState is 4
currentTime = 5.721229 , duration = 6.96 , readyState is 4
currentTime = 5.738229 , duration = 6.96 , readyState is 4
currentTime = 5.755229 , duration = 6.96 , readyState is 4
currentTime = 5.771188 , duration = 6.96 , readyState is 4
currentTime = 5.788167 , duration = 6.96 , readyState is 4
currentTime = 5.805167 , duration = 6.96 , readyState is 4
currentTime = 5.839229 , duration = 6.96 , readyState is 4
currentTime = 5.855229 , duration = 6.96 , readyState is 4
currentTime = 5.871292 , duration = 6.96 , readyState is 4
currentTime = 5.888292 , duration = 6.96 , readyState is 4
currentTime = 5.904188 , duration = 6.96 , readyState is 4
currentTime = 5.921229 , duration = 6.96 , readyState is 4
currentTime = 5.93925 , duration = 6.96 , readyState is 4
currentTime = 5.954229 , duration = 6.96 , readyState is 4
currentTime = 5.971167 , duration = 6.96 , readyState is 4
currentTime = 5.988167 , duration = 6.96 , readyState is 4
currentTime = 6.004167 , duration = 6.96 , readyState is 4
currentTime = 6.02225 , duration = 6.96 , readyState is 4
currentTime = 6.039229 , duration = 6.96 , readyState is 4
currentTime = 6.054208 , duration = 6.96 , readyState is 4
currentTime = 6.07125 , duration = 6.96 , readyState is 4
currentTime = 6.089646 , duration = 6.96 , readyState is 4
currentTime = 6.104646 , duration = 6.96 , readyState is 4
currentTime = 6.122688 , duration = 6.96 , readyState is 4
currentTime = 6.138292 , duration = 6.96 , readyState is 4
currentTime = 6.15525 , duration = 6.96 , readyState is 4
currentTime = 6.171208 , duration = 6.96 , readyState is 4
currentTime = 6.189188 , duration = 6.96 , readyState is 4
currentTime = 6.204188 , duration = 6.96 , readyState is 4
currentTime = 6.221208 , duration = 6.96 , readyState is 4
currentTime = 6.23825 , duration = 6.96 , readyState is 4
currentTime = 6.255229 , duration = 6.96 , readyState is 4
currentTime = 6.271229 , duration = 6.96 , readyState is 4
currentTime = 6.289167 , duration = 6.96 , readyState is 4
currentTime = 6.304167 , duration = 6.96 , readyState is 4
currentTime = 6.322229 , duration = 6.96 , readyState is 4
currentTime = 6.339271 , duration = 6.96 , readyState is 4
currentTime = 6.354188 , duration = 6.96 , readyState is 4
currentTime = 6.372146 , duration = 6.96 , readyState is 4
currentTime = 6.388146 , duration = 6.96 , readyState is 4
currentTime = 6.40525 , duration = 6.96 , readyState is 4
currentTime = 6.42125 , duration = 6.96 , readyState is 4
currentTime = 6.438208 , duration = 6.96 , readyState is 4
currentTime = 6.454208 , duration = 6.96 , readyState is 4
currentTime = 6.472208 , duration = 6.96 , readyState is 4
currentTime = 6.488208 , duration = 6.96 , readyState is 4
currentTime = 6.504167 , duration = 6.96 , readyState is 4
currentTime = 6.521229 , duration = 6.96 , readyState is 4
currentTime = 6.539208 , duration = 6.96 , readyState is 4
currentTime = 6.555229 , duration = 6.96 , readyState is 4
currentTime = 6.572188 , duration = 6.96 , readyState is 4
currentTime = 6.588188 , duration = 6.96 , readyState is 4
currentTime = 6.60525 , duration = 6.96 , readyState is 4
currentTime = 6.621208 , duration = 6.96 , readyState is 4
currentTime = 6.638208 , duration = 6.96 , readyState is 4
currentTime = 6.654229 , duration = 6.96 , readyState is 4
currentTime = 6.672188 , duration = 6.96 , readyState is 4
currentTime = 6.689167 , duration = 6.96 , readyState is 4
currentTime = 6.705167 , duration = 6.96 , readyState is 4
currentTime = 6.72225 , duration = 6.96 , readyState is 4
currentTime = 6.738229 , duration = 6.96 , readyState is 4
currentTime = 6.754208 , duration = 6.96 , readyState is 4
currentTime = 6.771229 , duration = 6.96 , readyState is 4
currentTime = 6.788229 , duration = 6.96 , readyState is 4
currentTime = 6.804208 , duration = 6.96 , readyState is 4
currentTime = 6.82125 , duration = 6.96 , readyState is 4
currentTime = 6.838229 , duration = 6.96 , readyState is 4
currentTime = 6.855208 , duration = 6.96 , readyState is 4
【问题讨论】:
流默认是不可搜索的。如果文件作为流提供,则响应标头中未设置内容长度,浏览器只会播放传入的内容。您没有声明服务器或源 URL,但您需要通过服务器提供视频作为通过设置内容长度来固定长度的文件。 (理想情况下,服务器还应该允许字节范围以更有效地进行搜索,如果不是的话)。 所以它本质上意味着无论如何我都无法在浏览器中寻找直接的 blob。上传到服务器是最终状态。如果用户想在上传之前播放录制的视频,那么他需要看到搜索栏。也许另一种方法是,在录制后立即将流保存在本地硬盘驱动器中,然后当用户想在上传之前播放它时,我将提供本地保存的视频作为源。 【参考方案1】:您也可以将媒体元素的currentTime
设置为Number.MAX_SAFE_INTEGER
,然后再次设置为0,这将强制浏览器将整个视频解析到最后并为您返回最后一帧。
这将允许您拥有一个可搜索的视频栏。
【讨论】:
在 chrome 中将currentTime
值设置为 0 让我无法播放视频,但将其设置为 0.1 效果很好。
@Infineight 听起来差不多,这个功能太坏了,这么多年过去了,他们不想修复任何这个。以上是关于HTML5 视频持续时间无限,而 readyState = 4的主要内容,如果未能解决你的问题,请参考以下文章
Internet Explorer 11 HTML5 音频持续时间 = 无限问题