Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. //HTML
  2. <video-resource></video-resource>
  3. //JS
  4. app.directive('videoResource', ['apiUrl',
  5. function() {
  6. var host = apiUrl.url;
  7. return {
  8. restrict : 'C',
  9. link: function (scope, element, attrs) {
  10. function render () {
  11. var path = attrs.path;
  12. var source1, source2, source3;
  13. var type1 = 'type="application/octet-stream"';
  14. var type2 = 'type="video/webm"';
  15. var type3 = 'type="video/ogg"';
  16. path = host + path;
  17. var dot = path.lastIndexOf('.');
  18. var ext = path.substr(dot + 1);
  19. switch (ext) {
  20. case 'mov':
  21. source1 = path;
  22. source2 = path.substr(0, dot) + '.webm';
  23. source3 = path.substr(0, dot) + '.ogv';
  24. break;
  25. case 'webm':
  26. source1 = path.substr(0, dot) + '.mov';
  27. source2 = path;
  28. source3 = path.substr(0, dot) + '.ogv';
  29. break;
  30. case 'ogv':
  31. source2 = path.substr(0, dot) + '.webm';
  32. source1 = path.substr(0, dot) + '.mov';
  33. source3 = path;
  34. break;
  35. default:
  36. }
  37.  
  38. var html = '<video id="myvideo" autoplay="" class="video-player" controls="controls" preload="auto" width="100%">'+
  39. '<source src="'+source1+'" '+type1+'>'+
  40. '<source src="'+source2+'" '+type2+'>'+
  41. '<source src="'+source3+'" '+type3+'>'+
  42. '</video>';
  43. }
  44.  
  45. render();
  46. }
  47. };
  48. }
  49. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement