cutCtrl.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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.post = function() {
  9. var data = {
  10. curso: $scope.curso,
  11. desc: $scope.desc,
  12. inicio: $scope.inicio,
  13. fin: $scope.fin,
  14. id: $scope.video._id,
  15. censuras: $scope.censuras
  16. };
  17. $http.post('/back/crop/', data)
  18. .success(function(data,state) {
  19. notify({message:data.status,classes:"alert"});
  20. })
  21. .error(function(data) {
  22. notify({message:data.status,classes:"alert alert-danger"});
  23. });
  24. };
  25. $scope.borrarCensura = function(c) {
  26. var i = 0;
  27. for ( i = 0; i < $scope.censuras.length; i++) {
  28. if ( $scope.censuras[i] == c ) {
  29. $scope.censuras.splice(i,1);
  30. return;
  31. }
  32. }
  33. };
  34. $scope.agregarCensura = function(){
  35. for ( var i = 0; i < $scope.censuras.length; i++)
  36. if ($scope.censuras[i].inicio == 0)
  37. return;
  38. $scope.censuras.push({inicio:0,fin:0});
  39. }
  40. function getVideoTime(){
  41. var video = document.getElementById("video");
  42. return video.currentTime;
  43. }
  44. $scope.changeTime = function(t) {
  45. if (t === undefined) return;
  46. var video = document.getElementById("video");
  47. video.currentTime=video.currentTime+t;
  48. }
  49. $scope.setEnd = function() {
  50. $scope.fin=getVideoTime();
  51. };
  52. $scope.setStart = function() {
  53. $scope.inicio=getVideoTime();
  54. };
  55. });