Skip to content

Commit 83cdd30

Browse files
thoronwenThulinma
authored andcommitted
Embed: added mistPlay option to rotate the video (pass rotate:1 to rotate clockwise, rotate:-1 to rotate counterclockwise, and rotate:2 for 180degrees)
1 parent 0d170d4 commit 83cdd30

File tree

6 files changed

+89
-2
lines changed

6 files changed

+89
-2
lines changed

embed/min/player.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

embed/min/skins/default.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
.mistvideo-controls{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
33
.mistvideo.novideo{overflow:visible}
44
.mistvideo-video{overflow:hidden;outline:0}
5+
.mistvideo .mistvideo-maincontainer,.mistvideo .mistvideo-videocontainer{width:var(--width);height:var(--height)}
6+
.mistvideo[data-fullscreen] .mistvideo-maincontainer,.mistvideo[data-fullscreen] .mistvideo-videocontainer{width:100vw;height:100vh}
7+
[data-mist-rotate="-1"],[data-mist-rotate="1"]{width:var(--height)!important;height:var(--width)!important;transform-origin:bottom left;transform:translate(calc(var(--factor) * var(--width)),calc(var(--factor) * var(--height) - var(--width))) rotate(var(--rotate));object-fit:contain}
8+
.mistvideo[data-fullscreen] [data-mist-rotate="-1"],.mistvideo[data-fullscreen] [data-mist-rotate="1"]{width:100vh!important;height:100vw!important;transform-origin:bottom left;transform:translate(calc(var(--factor) * 100vw),calc(var(--factor) * 100vh - 100vw)) rotate(var(--rotate));object-fit:contain}
9+
[data-mist-rotate="1"]{--rotate:90deg;--factor:0}
10+
[data-mist-rotate="-1"]{--rotate:-90deg;--factor:1}
11+
[data-mist-rotate="2"]{transform:rotate(180deg);transform-origin:center center}
512
.mistvideo svg.icon.loading{z-index:-1;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;opacity:0}
613
.mistvideo [data-loading]{position:relative}
714
.mistvideo [data-loading=stalled] svg.icon.loading{transition:opacity 0s 3s}

embed/min/skins/dev.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
.mistvideo-controls{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
33
.mistvideo.novideo{overflow:visible}
44
.mistvideo-video{overflow:hidden;outline:0}
5+
.mistvideo .mistvideo-maincontainer,.mistvideo .mistvideo-videocontainer{width:var(--width);height:var(--height)}
6+
.mistvideo[data-fullscreen] .mistvideo-maincontainer,.mistvideo[data-fullscreen] .mistvideo-videocontainer{width:100vw;height:100vh}
7+
[data-mist-rotate="-1"],[data-mist-rotate="1"]{width:var(--height)!important;height:var(--width)!important;transform-origin:bottom left;transform:translate(calc(var(--factor) * var(--width)),calc(var(--factor) * var(--height) - var(--width))) rotate(var(--rotate));object-fit:contain}
8+
.mistvideo[data-fullscreen] [data-mist-rotate="-1"],.mistvideo[data-fullscreen] [data-mist-rotate="1"]{width:100vh!important;height:100vw!important;transform-origin:bottom left;transform:translate(calc(var(--factor) * 100vw),calc(var(--factor) * 100vh - 100vw)) rotate(var(--rotate));object-fit:contain}
9+
[data-mist-rotate="1"]{--rotate:90deg;--factor:0}
10+
[data-mist-rotate="-1"]{--rotate:-90deg;--factor:1}
11+
[data-mist-rotate="2"]{transform:rotate(180deg);transform-origin:center center}
512
.mistvideo svg.icon.loading{z-index:-1;position:absolute;top:0;left:0;right:0;bottom:0;margin:auto;opacity:0}
613
.mistvideo [data-loading]{position:relative}
714
.mistvideo [data-loading=stalled] svg.icon.loading{transition:opacity 0s 3s}

embed/player.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ function MistVideo(streamName,options) {
3030
setTracks: false, //don't set tracks
3131
fillSpace: false, //don't fill parent container
3232
width: false, //no set width
33-
height: false, //no set height
33+
height: false, //no set height,
34+
rotate: false, //do not rotate; 1: rotate clockwise, -1: counter clockwise, 2: 180 degrees
3435
maxwidth: false, //no max width (apart from targets dimensions)
3536
maxheight: false, //no max height (apart from targets dimensions)
3637
ABR_resize: true, //for supporting wrappers: when the player resizes, request a video track that matches the resolution best
@@ -377,6 +378,13 @@ function MistVideo(streamName,options) {
377378
MistVideo.showError(e,{reload:true,hideTitle:true});
378379
return;
379380
}
381+
382+
if (Math.abs(MistVideo.options.rotate) == 1) {
383+
//switch width and height
384+
var w = d.width;
385+
MistVideo.info.width = d.height;
386+
MistVideo.info.height = w;
387+
}
380388

381389
//pre-show poster or other loading image
382390
MistVideo.calcSize = function(size) {
@@ -1064,6 +1072,8 @@ function MistVideo(streamName,options) {
10641072
this.setSize(size);
10651073
container.style.width = size.width+"px";
10661074
container.style.height = size.height+"px";
1075+
container.style.setProperty("--width",size.width+"px");
1076+
container.style.setProperty("--height",size.height+"px");
10671077

10681078
if ((MistVideo.options.fillSpace) && (!options || !options.reiterating)) {
10691079
//if this container is set to fill the available space

embed/skins.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,17 @@ MistSkins["default"] = {
332332
},
333333
video: function(){
334334
var MistVideo = this;
335+
336+
if (MistVideo.options.rotate) {
337+
switch (MistVideo.options.rotate) {
338+
case -1:
339+
case 1:
340+
case 2: {
341+
MistVideo.video.setAttribute("data-mist-rotate",MistVideo.options.rotate);
342+
break;
343+
}
344+
}
345+
}
335346

336347
//disable right click
337348
MistUtil.event.addListener(MistVideo.video,"contextmenu",function(e){
@@ -2453,6 +2464,17 @@ MistSkins["default"] = {
24532464

24542465
var ele = document.createElement("div");
24552466
var MistVideo = this;
2467+
2468+
if (MistVideo.options.rotate) {
2469+
switch (MistVideo.options.rotate) {
2470+
case -1:
2471+
case 1:
2472+
case 2: {
2473+
ele.setAttribute("data-mist-rotate",MistVideo.options.rotate);
2474+
break;
2475+
}
2476+
}
2477+
}
24562478

24572479
var canvasses = [];
24582480
for (var n = 0; n < 2; n++) {

embed/skins/general.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,47 @@
2020
overflow: hidden;
2121
outline: none;
2222
}
23+
.mistvideo .mistvideo-maincontainer,
24+
.mistvideo .mistvideo-videocontainer {
25+
width: var(--width);
26+
height: var(--height);
27+
}
28+
.mistvideo[data-fullscreen] .mistvideo-maincontainer,
29+
.mistvideo[data-fullscreen] .mistvideo-videocontainer {
30+
width: 100vw;
31+
height: 100vh;
32+
}
33+
[data-mist-rotate="1"],
34+
[data-mist-rotate="-1"] {
35+
width: var(--height) !important;
36+
height: var(--width) !important;
37+
transform-origin: bottom left;
38+
transform: translate(calc(var(--factor) * var(--width)), calc(var(--factor) * var(--height) - var(--width))) rotate(var(--rotate));
39+
object-fit: contain;
40+
}
41+
.mistvideo[data-fullscreen] [data-mist-rotate="1"],
42+
.mistvideo[data-fullscreen] [data-mist-rotate="-1"] {
43+
width: 100vh !important;
44+
height: 100vw !important;
45+
transform-origin: bottom left;
46+
transform: translate(calc(var(--factor) * 100vw), calc(var(--factor) * 100vh - 100vw)) rotate(var(--rotate));
47+
object-fit: contain;
48+
}
49+
50+
[data-mist-rotate="1"] {
51+
--rotate: 90deg;
52+
--factor: 0;
53+
}
54+
[data-mist-rotate="-1"] {
55+
--rotate: -90deg;
56+
--factor: 1;
57+
58+
}
59+
[data-mist-rotate="2"] {
60+
transform: rotate(180deg);
61+
transform-origin: center center;
62+
}
63+
2364
.mistvideo svg.icon.loading {
2465
z-index: -1; /* don't use display: none because of transition for [data-loading=stalled] */
2566
position: absolute;

0 commit comments

Comments
 (0)