Просмотр исходного кода

add front end support for audio timings

David 9 лет назад
Родитель
Сommit
6afa274160
2 измененных файлов с 33 добавлено и 0 удалено
  1. 25 0
      front/controllers/cutCtrl.js
  2. 8 0
      front/views/cut.html

+ 25 - 0
front/controllers/cutCtrl.js

@@ -5,6 +5,7 @@ app.controller('cutCtrl', function ($scope, $http,video,notify) {
 	$scope.desc="";
 	$scope.video = video; 
 	$scope.censuras = [];
+    $scope.timings = [];
 
 	document.getElementById("video").setAttribute("src", $scope.video.file);
 
@@ -26,6 +27,24 @@ app.controller('cutCtrl', function ($scope, $http,video,notify) {
 		});
 	};
 
+    $scope.obtenerTiempos = function() {
+        $http.get('/back/timings/' + $scope.video._id)
+        .success(function(data, state) {
+            $scope.timings = data["timings"];
+        });
+    };
+
+    $scope.formatearTiempo = function(t) {
+        var h = parseInt(t/3600);
+        var m = parseInt((t % 3600) / 60);
+        var s = parseInt(t % 60);
+        if (m < 10)
+            m = "0" + m;
+        if (s < 10)
+            s = "0" + s;
+        return `${h}:${m}:${s}`;
+    }
+
 	$scope.borrarCensura = function(c) {
 		var i = 0;
 		for ( i = 0; i < $scope.censuras.length; i++) {
@@ -46,6 +65,12 @@ app.controller('cutCtrl', function ($scope, $http,video,notify) {
 		var video = document.getElementById("video");
 		return video.currentTime;
 	}
+	$scope.changeTimeAbs = function(t) {
+		if (t === undefined) return;
+		var video = document.getElementById("video");
+		video.currentTime=t;
+	}
+
 	$scope.changeTime = function(t) {
 		if (t === undefined) return;
 		var video = document.getElementById("video");

+ 8 - 0
front/views/cut.html

@@ -66,6 +66,14 @@
 
 			<button ng-click="setStart()" class="btn btn-default">Inicio</button>
 			<button ng-click="setEnd()" class="btn btn-default">Fin</button>
+			<button ng-click="obtenerTiempos()" class="btn btn-default"><i class="">Tiempo</i></button>
 			<button ng-click="post()" class="btn btn-default btn-send">Enviar</button>
+			<div class="row">
+				<div class="col-md-6">
+				    <div class="row" ng-repeat="c in timings">
+			            <button ng-click="changeTimeAbs(c)" class="btn btn-default">{{formatearTiempo(c)}}</button>
+                    </div>
+				</div>
+            </div>
 		</div>
 </div>