function gp() {
var _this=video;// video為當(dāng)前video元素
var percent=null;
// FF4+, Chrome
if (_this && _this.buffered && _this.buffered.length > 0 && _this.buffered.end && _this.duration) {
percent = _this.buffered.end(0) / _this.duration;
}
// Some browsers (e.g., FF3.6 and Safari 5) cannot calculate target.bufferered.end()
// to be anything other than 0. If the byte count is available we use this instead.
// Browsers that support the else if do not seem to have the bufferedBytes value and
// should skip to there. Tested in Safari 5, Webkit head, FF3.6, Chrome 6, IE 7/8.
else if (_this && _this.bytesTotal != undefined && _this.bytesTotal > 0 && _this.bufferedBytes != undefined) {
percent = _this.bufferedBytes / _this.bytesTotal;
}
if (percent !== null) {
percent = 100 * Math.min(1, Math.max(0, percent));
return percent;
}
return 0;
}