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.
 
 
 
 
 
 

54 regels
1.5 KiB

  1. /*
  2. * Video.js plugin for Pannellum
  3. * Copyright (c) 2015-2017 Matthew Petroff
  4. * MIT License
  5. */
  6. (function(document, videojs, pannellum) {
  7. 'use strict';
  8. videojs.plugin('pannellum', function(config) {
  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 = config || {};
  15. config.type = 'equirectangular';
  16. config.dynamic = true;
  17. config.showZoomCtrl = false;
  18. config.showFullscreenCtrl = false;
  19. config.autoLoad = true;
  20. config.panorama = vid;
  21. pnlmContainer.style.visibility = 'hidden';
  22. player.pnlmViewer = pannellum.viewer(pnlmContainer, config);
  23. container.insertBefore(pnlmContainer, container.firstChild);
  24. vid.style.display = 'none';
  25. // Handle update settings
  26. player.on('play', function() {
  27. if (vid.readyState > 1)
  28. player.pnlmViewer.setUpdate(true);
  29. });
  30. player.on('canplay', function() {
  31. if (!player.paused())
  32. player.pnlmViewer.setUpdate(true);
  33. });
  34. player.on('pause', function() {
  35. player.pnlmViewer.setUpdate(false);
  36. });
  37. player.on('loadeddata', function() {
  38. pnlmContainer.style.visibility = 'visible';
  39. });
  40. player.on('seeking', function() {
  41. if (player.paused())
  42. player.pnlmViewer.setUpdate(true);
  43. });
  44. player.on('seeked', function() {
  45. if (player.paused())
  46. player.pnlmViewer.setUpdate(false);
  47. });
  48. });
  49. })(document, videojs, pannellum);