You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.5 KiB

  1. /*
  2. * Video.js plugin for Pannellum
  3. * Copyright (c) 2015-2016 Matthew Petroff
  4. * MIT License
  5. */
  6. (function(document, videojs, pannellum) {
  7. 'use strict';
  8. videojs.plugin('pannellum', function() {
  9. // Create Pannellum instance
  10. var player = this;
  11. var container = player.el();
  12. var vid = container.getElementsByTagName('video')[0],
  13. pnlmContainer = document.createElement('div'),
  14. config = {
  15. 'type': 'equirectangular',
  16. 'dynamic': true,
  17. 'showZoomCtrl': false,
  18. 'showFullscreenCtrl': false,
  19. 'autoLoad': true,
  20. 'panorama': vid
  21. };
  22. pnlmContainer.style.visibility = 'hidden';
  23. var pnlm = pannellum.viewer(pnlmContainer, config);
  24. container.insertBefore(pnlmContainer, container.firstChild);
  25. vid.style.display = 'none';
  26. // Handle update settings
  27. player.on('play', function() {
  28. if (vid.readyState > 1)
  29. pnlm.setUpdate(true);
  30. });
  31. player.on('canplay', function() {
  32. if (!player.paused())
  33. pnlm.setUpdate(true);
  34. });
  35. player.on('pause', function() {
  36. pnlm.setUpdate(false);
  37. });
  38. player.on('loadeddata', function() {
  39. pnlmContainer.style.visibility = 'visible';
  40. });
  41. player.on('seeking', function() {
  42. if (player.paused())
  43. pnlm.setUpdate(true);
  44. });
  45. player.on('seeked', function() {
  46. if (player.paused())
  47. pnlm.setUpdate(false);
  48. });
  49. });
  50. })(document, videojs, pannellum);