setting aspect ratio only to videos that are playing works
This commit is contained in:
parent
c6ad32f712
commit
4d21187596
@ -66,26 +66,26 @@ class CommsClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.cmd === "set-ar") {
|
if (message.cmd === "set-ar") {
|
||||||
this.pageInfo.setAr(message.arg);
|
this.pageInfo.setAr(message.arg, message.playing);
|
||||||
} else if (message.cmd === 'set-alignment') {
|
} else if (message.cmd === 'set-alignment') {
|
||||||
this.pageInfo.setVideoFloat(message.arg);
|
this.pageInfo.setVideoFloat(message.arg, message.playing);
|
||||||
this.pageInfo.restoreAr();
|
this.pageInfo.restoreAr();
|
||||||
} else if (message.cmd === "set-stretch") {
|
} else if (message.cmd === "set-stretch") {
|
||||||
this.pageInfo.setStretchMode(StretchMode[message.arg]);
|
this.pageInfo.setStretchMode(StretchMode[message.arg], message.playing);
|
||||||
} else if (message.cmd === "autoar-start") {
|
} else if (message.cmd === "autoar-start") {
|
||||||
if (message.enabled !== false) {
|
if (message.enabled !== false) {
|
||||||
this.pageInfo.initArDetection();
|
this.pageInfo.initArDetection(message.playing);
|
||||||
this.pageInfo.startArDetection();
|
this.pageInfo.startArDetection(message.playing);
|
||||||
} else {
|
} else {
|
||||||
this.pageInfo.stopArDetection();
|
this.pageInfo.stopArDetection(message.playing);
|
||||||
}
|
}
|
||||||
} else if (message.cmd === "pause-processing") {
|
} else if (message.cmd === "pause-processing") {
|
||||||
this.pageInfo.pauseProcessing();
|
this.pageInfo.pauseProcessing(message.playing);
|
||||||
} else if (message.cmd === "resume-processing") {
|
} else if (message.cmd === "resume-processing") {
|
||||||
// todo: autoArStatus
|
// todo: autoArStatus
|
||||||
this.pageInfo.resumeProcessing(message.autoArStatus);
|
this.pageInfo.resumeProcessing(message.autoArStatus, message.playing);
|
||||||
} else if (message.cmd === 'set-zoom') {
|
} else if (message.cmd === 'set-zoom') {
|
||||||
this.pageInfo.setZoom(message.zoom, true);
|
this.pageInfo.setZoom(message.zoom, true, message.playing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,4 +186,13 @@ class VideoData {
|
|||||||
announceZoom(scale){
|
announceZoom(scale){
|
||||||
this.pageInfo.announceZoom(scale);
|
this.pageInfo.announceZoom(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isPlaying() {
|
||||||
|
|
||||||
|
console.log("is playing? video:", this.video, "ctime:", this.video.currentTime,
|
||||||
|
"paused/ended:", this.video.paused, this.video.ended,
|
||||||
|
"is playing?", this.video && this.video.currentTime > 0 && !this.video.paused && !this.video.ended);
|
||||||
|
|
||||||
|
return this.video && this.video.currentTime > 0 && !this.video.paused && !this.video.ended;
|
||||||
|
}
|
||||||
}
|
}
|
@ -196,22 +196,49 @@ class PageInfo {
|
|||||||
this.scheduleUrlCheck();
|
this.scheduleUrlCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
initArDetection(){
|
initArDetection(playingOnly){
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos){
|
||||||
|
if(vd.isPlaying()) {
|
||||||
|
vd.initArDetection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
for(var vd of this.videos){
|
for(var vd of this.videos){
|
||||||
vd.initArDetection();
|
vd.initArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// to je treba klicat ob menjavi zavihkov
|
// to je treba klicat ob menjavi zavihkov
|
||||||
// these need to be called on tab switch
|
// these need to be called on tab switch
|
||||||
pauseProcessing(){
|
pauseProcessing(playingOnly){
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos){
|
||||||
|
if (vd.isPlaying()) {
|
||||||
|
vd.pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for(var vd of this.videos){
|
for(var vd of this.videos){
|
||||||
vd.pause();
|
vd.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resumeProcessing(resumeAutoar = false){
|
resumeProcessing(resumeAutoar = false, playingOnly = false){
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos){
|
||||||
|
if (vd.isPlaying()) {
|
||||||
|
vd.resume();
|
||||||
|
if(resumeAutoar){
|
||||||
|
vd.resumeAutoAr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for(var vd of this.videos){
|
for(var vd of this.videos){
|
||||||
vd.resume();
|
vd.resume();
|
||||||
if(resumeAutoar){
|
if(resumeAutoar){
|
||||||
@ -219,32 +246,48 @@ class PageInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
startArDetection(){
|
startArDetection(playingOnly){
|
||||||
if (Debug.debug) {
|
if (Debug.debug) {
|
||||||
console.log('[PageInfo::startArDetection()] starting automatic ar detection!')
|
console.log('[PageInfo::startArDetection()] starting automatic ar detection!')
|
||||||
}
|
}
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos){
|
||||||
|
if (video.isPlaying()) {
|
||||||
|
vd.startArDetection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for(var vd of this.videos){
|
for(var vd of this.videos){
|
||||||
vd.startArDetection();
|
vd.startArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stopArDetection(){
|
stopArDetection(playingOnly){
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos){
|
||||||
|
if (vd.isPlaying()) {
|
||||||
|
vd.stopArDetection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for(var vd of this.videos){
|
for(var vd of this.videos){
|
||||||
vd.stopArDetection();
|
vd.stopArDetection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setAr(ar){
|
|
||||||
if (Debug.debug) {
|
|
||||||
console.log('[PageInfo::setAr] aspect ratio:', ar)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setAr(ar, playingOnly){
|
||||||
|
if (Debug.debug) {
|
||||||
|
console.log('[PageInfo::setAr] aspect ratio:', ar, "playing only?", playingOnly)
|
||||||
|
}
|
||||||
|
|
||||||
if (ar !== 'auto') {
|
if (ar !== 'auto') {
|
||||||
this.stopArDetection();
|
this.stopArDetection(playingOnly);
|
||||||
} else {
|
} else {
|
||||||
if (Debug.debug) {
|
if (Debug.debug) {
|
||||||
console.log('[PageInfo::setAr] aspect ratio is auto');
|
console.log('[PageInfo::setAr] aspect ratio is auto');
|
||||||
@ -252,65 +295,113 @@ class PageInfo {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for (var vd of this.videos) {
|
for (var vd of this.videos) {
|
||||||
|
if (!playingOnly || vd.isPlaying()) {
|
||||||
vd.resetLastAr();
|
vd.resetLastAr();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("???", e);
|
console.log("???", e);
|
||||||
}
|
}
|
||||||
this.initArDetection();
|
this.initArDetection(playingOnly);
|
||||||
this.startArDetection();
|
this.startArDetection(playingOnly);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: find a way to only change aspect ratio for one video
|
// TODO: find a way to only change aspect ratio for one video
|
||||||
if (ar === 'reset') {
|
if (ar === 'reset') {
|
||||||
for (var vd of this.videos) {
|
for (var vd of this.videos) {
|
||||||
|
if (!playingOnly || vd.isPlaying()) {
|
||||||
vd.resetAr();
|
vd.resetAr();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (var vd of this.videos) {
|
for (var vd of this.videos) {
|
||||||
|
if (!playingOnly || vd.isPlaying()) {
|
||||||
vd.setAr(ar)
|
vd.setAr(ar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setVideoFloat(videoFloat) {
|
setVideoFloat(videoFloat, playingOnly) {
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos) {
|
||||||
|
if (vd.isPlaying()) {
|
||||||
|
vd.setVideoFloat(videoFloat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for(var vd of this.videos) {
|
for(var vd of this.videos) {
|
||||||
vd.setVideoFloat(videoFloat)
|
vd.setVideoFloat(videoFloat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setPanMode(mode) {
|
setPanMode(mode, playingOnly) {
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos) {
|
||||||
|
if (vd.isPlaying()) {
|
||||||
|
vd.setPanMode(mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for(var vd of this.videos) {
|
for(var vd of this.videos) {
|
||||||
vd.setPanMode(mode);
|
vd.setPanMode(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
restoreAr() {
|
restoreAr(playingOnly) {
|
||||||
|
if (playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(var vd of this.videos){
|
||||||
vd.restoreAr()
|
if (vd.isPlaying()) {
|
||||||
|
vd.restoreAr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(var vd of this.videos){
|
||||||
|
vd.restoreAr();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setStretchMode(sm){
|
setStretchMode(sm, playingOnly){
|
||||||
// TODO: find a way to only change aspect ratio for one video
|
// TODO: find a way to only change aspect ratio for one video
|
||||||
|
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos){
|
||||||
|
if (vd.isPlaying()) {
|
||||||
|
vd.setStretchMode(sm)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for(var vd of this.videos){
|
for(var vd of this.videos){
|
||||||
vd.setStretchMode(sm)
|
vd.setStretchMode(sm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setZoom(zoomLevel, no_announce) {
|
setZoom(zoomLevel, no_announce, playingOnly) {
|
||||||
|
if (playingOnly) {
|
||||||
|
for(var vd of this.videos) {
|
||||||
|
if (vd.isPlaying()) {
|
||||||
|
vd.setZoom(zoomLevel, no_announce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for(var vd of this.videos) {
|
for(var vd of this.videos) {
|
||||||
vd.setZoom(zoomLevel, no_announce);
|
vd.setZoom(zoomLevel, no_announce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
zoomStep(step){
|
zoomStep(step, playingOnly) {
|
||||||
for(var vd of this.videos){
|
for(var vd of this.videos){
|
||||||
|
if (!playingOnly || vd.isPlaying()) {
|
||||||
vd.zoomStep(step);
|
vd.zoomStep(step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
announceZoom(scale) {
|
announceZoom(scale) {
|
||||||
if (this.announceZoomTimeout) {
|
if (this.announceZoomTimeout) {
|
||||||
|
Loading…
Reference in New Issue
Block a user