From 028382a751ae6d07da6e3b832cc86f39b170b70b Mon Sep 17 00:00:00 2001 From: Timer91 Date: Thu, 14 Jan 2016 01:26:25 +0100 Subject: [PATCH 1/2] tempo --- api/video.js | 8 ++++++++ dom.js | 2 ++ index.html | 2 ++ player/events/rotation.js | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 player/events/rotation.js diff --git a/api/video.js b/api/video.js index 95cb65f..72ce434 100644 --- a/api/video.js +++ b/api/video.js @@ -149,6 +149,14 @@ api.video = that = { jqVideo.trigger( "opacitychange" ); } return that; + }, + + // Getter: width/height + width: function() { + return video.videoWidth; + }, + height: function() { + return video.videoHeight; } }; diff --git a/dom.js b/dom.js index 1a3baf4..302e97d 100644 --- a/dom.js +++ b/dom.js @@ -34,6 +34,8 @@ window.dom = { // Opacity jqPlayerOpacityIcon: $( "#ctrl .opacity .fa" ), jqPlayerOpacitySlider: $( "#ctrl .opacity .cuteslider" ), + // Rotation + jqPlayerRotationIcon: $( "#ctrl .rotation" ), // CurrentTime jqPlayerSliderCurrentTime: $( "#ctrl .cuteslider.position" ), // Thumbnail diff --git a/index.html b/index.html index 5676441..ecfb8d5 100644 --- a/index.html +++ b/index.html @@ -103,6 +103,7 @@

+ diff --git a/player/events/rotation.js b/player/events/rotation.js new file mode 100644 index 0000000..bd05faa --- /dev/null +++ b/player/events/rotation.js @@ -0,0 +1,38 @@ +(function(){ + +var + jqVideo = dom.jqPlayerVideo, + jqRotation = dom.jqPlayerRotationIcon +; + +function getRotationDegrees( obj ) { + var matrix = obj.css( "transform" ); + + if( matrix !== 'none' ) { + var + values = + matrix + .split( '(' )[ 1 ] + .split( ')' )[ 0 ] + .split( ',' ) + , + a = values[ 0 ], + b = values[ 1 ], + angle = Math.round( Math.atan2( b, a ) * ( 180 / Math.PI ) ) + ; + } else { var angle = 0; } + //return (angle < 0) ? angle + 360 : angle; + return angle; +} + +function rotate( degree ) { + var rotation = getRotationDegrees( jqVideo ); + + jqVideo.css( { transform: "rotate(" + ( rotation + degree ) + "deg)" } ); +} + + + +jqRotation.click( function() { rotate( 45 ); } ); + +})(); From d464ee755722647bf33fa44aeadd4dac8dc36cb7 Mon Sep 17 00:00:00 2001 From: Timer91 Date: Thu, 14 Jan 2016 04:48:13 +0100 Subject: [PATCH 2/2] Controls+Rotation: New menu for rotation with a cuteslider --- api/video.js | 12 ++++++++++++ dom.js | 4 +++- index.html | 21 ++++++++++++++++++++- init.js | 1 + player/css/controls.css | 8 +++++++- player/data-binding.js | 4 ++++ player/events/rotation.js | 37 +++---------------------------------- player/player-ui.js | 9 +++++++++ tools/utils.js | 1 + 9 files changed, 60 insertions(+), 37 deletions(-) diff --git a/api/video.js b/api/video.js index adb776f..a342690 100644 --- a/api/video.js +++ b/api/video.js @@ -4,6 +4,7 @@ var that, oldSource, opacity, + rotation, isStopped = true, isLoaded = false, video = dom.jqPlayerVideo[ 0 ], @@ -155,12 +156,23 @@ api.video = that = { return that; }, + // Rotation (degrees) + rotation: function( deg ) { + if ( arguments.length === 0 ) { + return rotation; + } + rotation = utils.range( 0, deg, 360, rotation ); + jqVideo.trigger( "rotationchange" ); + return that; + }, + // Getter: width/height width: function() { return video.videoWidth; }, height: function() { return video.videoHeight; + }, opacityToggle: function( b ) { if ( typeof b !== "boolean" ) { diff --git a/dom.js b/dom.js index d7fd196..b683892 100644 --- a/dom.js +++ b/dom.js @@ -45,7 +45,9 @@ window.dom = { jqPlayerOpacitySlider: $( "#ctrl .opacity .cuteslider" ), jqPlayerOpacityValue: $( "#ctrl .opacity .val" ), // Rotation - jqPlayerRotationIcon: $( "#ctrl .rotation" ), + jqPlayerRotationIcon: $( "#ctrl .rotation .fa" ), + jqPlayerRotationSlider: $( "#ctrl .rotation .cuteslider" ), + jqPlayerRotationValue: $( "#ctrl .rotation .val" ), // CurrentTime jqPlayerSliderCurrentTime: $( "#ctrl .cuteslider.position" ), // Thumbnail diff --git a/index.html b/index.html index 992f08a..d3bee25 100644 --- a/index.html +++ b/index.html @@ -102,7 +102,26 @@