Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Commit

Permalink
[html5] minor fix on speed adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
myfreeer authored Dec 15, 2016
1 parent 3fe6e73 commit a42c140
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,13 @@ let getVideosByCid = function (cid) {
"filesize": sizes[i],
"url": urls[i]
});
//if (mediaDataSource.segments.length ===1 && mediaDataSource.segments.url.match('\.mp4')) mediaDataSource.type = 'mp4';
/*
if (mediaDataSource.segments.length === 1 && mediaDataSource.segments[0].url.match('\.mp4') && !mediaDataSource.segments[0].url.match('\.flv')) {
mediaDataSource.type = 'mp4';
mediaDataSource.type = mediaDataSource.segments[0].url;
delete mediaDataSource.segments
}
*/
return mediaDataSource
})
};
Expand Down
2 changes: 1 addition & 1 deletion bilibili_ASS_Danmaku_Downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ var initFont = (function () {

var generateASS = function (danmaku, info) {
if (Number(info.opacity)) config.opacity = info.opacity;
var assHeader = fillStr('[Script Info]\nTitle: {{title}}\nOriginal Script: 根据 {{ori}} 的弹幕信息,由 https://github.com/tiansh/us-danmaku 生成\nScriptType: v4.00+\nCollisions: Normal\nPlayResX: {{playResX}}\nPlayResY: {{playResY}}\nTimer: 10.0000\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\nStyle: Fix,{{font}},25,&H{{alpha}}FFFFFF,&H{{alpha}}FFFFFF,&H{{alpha}}000000,&H{{alpha}}000000,1,0,0,0,100,100,0,0,1,2,0,2,20,20,2,0\nStyle: R2L,{{font}},25,&H{{alpha}}FFFFFF,&H{{alpha}}FFFFFF,&H{{alpha}}000000,&H{{alpha}}000000,1,0,0,0,100,100,0,0,1,2,0,2,20,20,2,0\n\n[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n', config, info, {'alpha': hexAlpha(config.opacity) });
var assHeader = fillStr('[Script Info]\nTitle: {{title}}\nOriginal Script: 根据 {{ori}} 的弹幕信息,由 https://github.com/tiansh/us-danmaku 生成\nScriptType: v4.00+\nCollisions: Normal\nPlayResX: {{playResX}}\nPlayResY: {{playResY}}\nTimer: 10.0000\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\nStyle: Fix,{{font}},25,&H{{alpha}}FFFFFF,&H{{alpha}}FFFFFF,&H{{alpha}}000000,&H{{alpha}}000000,0,0,0,0,100,100,0,0,1,2,0,2,20,20,2,0\nStyle: R2L,{{font}},25,&H{{alpha}}FFFFFF,&H{{alpha}}FFFFFF,&H{{alpha}}000000,&H{{alpha}}000000,0,0,0,0,100,100,0,0,1,2,0,2,20,20,2,0\n\n[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n', config, info, {'alpha': hexAlpha(config.opacity) });
// 补齐数字开头的0
var paddingNum = function (num, len) {
num = '' + num;
Expand Down
12 changes: 10 additions & 2 deletions bilibili_injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
biliHelper.mainBlock.switcherSection.find('a.b-btn[type="' + this.current + '"]').addClass('w');
biliHelper.mainBlock.switcherSection.find('a.b-btn[type="' + newMode + '"]').removeClass('w');
localStorage.removeItem('defaulth5');
if (this.current == 'html5' && this.flvPlayer) this.flvPlayer.unload();
if (this.current == 'html5' && this.flvPlayer) this.flvPlayer.destroy();
try{clearInterval(checkFinished);} catch(e){}
try{clearInterval(interval);} catch(e){}
if (newMode.match('html5')) {
Expand Down Expand Up @@ -638,16 +638,23 @@
config: e.detail
});
});
var restart=video=>!video.paused&&!video.pause()&&!video.play();
biliHelper.mainBlock.speedSection.input.addEventListener("change", function(e) {
if (Number(biliHelper.mainBlock.speedSection.input.value)) {
abp.video.playbackRate = Number(biliHelper.mainBlock.speedSection.input.value);
restart(abp.video);
} else {
biliHelper.mainBlock.speedSection.input.value = 1.0;
restart(abp.video);
};
});
abp.video.addEventListener("loadedmetadata", function(e) {
biliHelper.mainBlock.speedSection.res.innerText = abp.video.videoWidth + "x" + abp.video.videoHeight;
biliHelper.mainBlock.speedSection.res.innerText = '分辨率: ' + abp.video.videoWidth + "x" + abp.video.videoHeight;
});
/*abp.video.addEventListener("timeupdate", function(e) {
if (abp.video.readyState > 2)
biliHelper.mainBlock.speedSection.res.innerText = '分辨率: ' + abp.video.videoWidth + "x" + abp.video.videoHeight + '; FPS: ' + (abp.video.webkitDecodedFrameCount/abp.video.currentTime).toString().substr(0,5) + '; Bitrate: ' + ((abp.video.webkitVideoDecodedByteCount+abp.video.webkitAudioDecodedByteCount)/(abp.video.currentTime*1000)).toString().substr(0,7);
});*/
biliHelper.mainBlock.speedSection.rotate.addEventListener("change", function(e) {
if (Number(biliHelper.mainBlock.speedSection.rotate.value) % 360 ===0) biliHelper.mainBlock.speedSection.rotate.value = 0;
if (biliHelper.mainBlock.speedSection.mirror.className==="b-btn") {
Expand Down Expand Up @@ -696,6 +703,7 @@
biliHelper.switcher.flvPlayer.load();
biliHelper.switcher.flvPlayer.on(flvjs.Events.ERROR, e => console.warn(e, 'Switch back to HTML5 HD.', biliHelper.switcher.html5hd()));
//biliHelper.switcher.flvPlayer.play();
biliHelper.switcher.flvPlayer.on(flvjs.Events.MEDIA_INFO, e=>console.log('分辨率: ' + e.width + "x" + e.height+', FPS: '+e.fps,'视频码率: '+Math.round(e.videoDataRate*100)/100,'音频码率: '+Math.round(e.audioDataRate*100)/100));
}
}, 600);
var lastTime;
Expand Down

0 comments on commit a42c140

Please sign in to comment.