Source: services/VideoStreamService.js

  1. /**
  2. * @ngdoc service
  3. * @name VideoStreamService
  4. * @module s4c.services.VideoStreamService
  5. *
  6. * @description Componente para acesso a api do backend e/ou comunicação entre controllers
  7. *
  8. *
  9. */
  10. (function () {
  11. 'use strict';
  12. angular.module('s4c.services').factory(
  13. 'VideoStreamService', VideoStreamService);
  14. VideoStreamService.$inject = [];
  15. /**
  16. * @method VideoStreamService
  17. */
  18. function VideoStreamService() {
  19. var service = {
  20. open: open,
  21. close: close,
  22. closeAll: closeAll,
  23. setPlayerOptions: setPlayerOptions
  24. };
  25. var players = [];
  26. var playerOptions = {
  27. };
  28. /**
  29. * @method setPlayerOptions
  30. * @param {*} opts
  31. */
  32. function setPlayerOptions(opts) {
  33. playerOptions = opts;
  34. }
  35. /**
  36. * @method open
  37. * @param {*} divId
  38. * @param {*} url
  39. */
  40. function open(divId, url) {
  41. document.getElementById(divId).src = url;
  42. players[divId] = window.Streamedian.player(divId, playerOptions);
  43. }
  44. /**
  45. * @method close
  46. * @param {*} divId
  47. */
  48. function close(divId) {
  49. if (players[divId]) {
  50. players[divId].destroy();
  51. players[divId] = null;
  52. }
  53. }
  54. /**
  55. * @method closeAll
  56. */
  57. function closeAll() {
  58. for(var index in players){
  59. if (!players[index]) {
  60. continue;
  61. }
  62. players[index].destroy();
  63. players[index] = null;
  64. }
  65. players = [];
  66. }
  67. return service;
  68. }
  69. }());