cutCtrl.js 1.4 KB

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