cutCtrl.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. app.controller('cutCtrl', function ($scope, $http,video,notify) {
  2. $scope.inicio=0;
  3. $scope.fin=0;
  4. $scope.curso="";
  5. $scope.desc="";
  6. $scope.video = video;
  7. $scope.censuras = [];
  8. $scope.timings = [];
  9. document.getElementById("video").setAttribute("src", $scope.video.file);
  10. $scope.post = function() {
  11. var data = {
  12. curso: $scope.curso,
  13. desc: $scope.desc,
  14. inicio: $scope.inicio,
  15. fin: $scope.fin,
  16. id: $scope.video._id,
  17. censuras: $scope.censuras
  18. };
  19. $http.post('/back/crop/', data)
  20. .success(function(data,state) {
  21. notify({message:data.status,classes:"alert"});
  22. })
  23. .error(function(data) {
  24. notify({message:data.status,classes:"alert alert-danger"});
  25. });
  26. };
  27. $scope.obtenerTiempos = function() {
  28. $http.get('/back/timings/' + $scope.video._id)
  29. .success(function(data, state) {
  30. $scope.timings = data["timings"];
  31. });
  32. };
  33. $scope.formatearTiempo = function(t) {
  34. var h = parseInt(t/3600);
  35. var m = parseInt((t % 3600) / 60);
  36. var s = parseInt(t % 60);
  37. if (m < 10)
  38. m = "0" + m;
  39. if (s < 10)
  40. s = "0" + s;
  41. return `${h}:${m}:${s}`;
  42. }
  43. $scope.borrarCensura = function(c) {
  44. var i = 0;
  45. for ( i = 0; i < $scope.censuras.length; i++) {
  46. if ( $scope.censuras[i] == c ) {
  47. $scope.censuras.splice(i,1);
  48. return;
  49. }
  50. }
  51. };
  52. $scope.agregarCensura = function(){
  53. for ( var i = 0; i < $scope.censuras.length; i++)
  54. if ($scope.censuras[i].inicio == 0)
  55. return;
  56. $scope.censuras.push({inicio:0,fin:0});
  57. }
  58. function getVideoTime(){
  59. var video = document.getElementById("video");
  60. return video.currentTime;
  61. }
  62. $scope.changeTimeAbs = function(t) {
  63. if (t === undefined) return;
  64. var video = document.getElementById("video");
  65. video.currentTime=t;
  66. }
  67. $scope.changeTime = function(t) {
  68. if (t === undefined) return;
  69. var video = document.getElementById("video");
  70. video.currentTime=video.currentTime+t;
  71. }
  72. $scope.setEnd = function() {
  73. $scope.fin=getVideoTime();
  74. };
  75. $scope.setStart = function() {
  76. $scope.inicio=getVideoTime();
  77. };
  78. });