jplayer.builder.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/2815083
  5. * @preserve
  6. **/
  7. (function ($, Drupal) {
  8. 'use strict';
  9. Drupal.AudiofieldJplayer = {};
  10. Drupal.AudiofieldJplayer.generate = function (context, settings) {
  11. $('#jquery_jplayer_' + settings.unique_id, context).once('generate-jplayer').jPlayer({
  12. cssSelectorAncestor: '#jp_container_' + settings.unique_id
  13. }, {
  14. ready: function ready() {
  15. var mediaArray = {
  16. title: settings.description
  17. };
  18. mediaArray[settings.filetype] = settings.file;
  19. $('#jquery_jplayer_' + settings.unique_id, context).jPlayer('setMedia', mediaArray);
  20. },
  21. canplay: function canplay() {
  22. if (!!settings.autoplay) {
  23. $('#jquery_jplayer_' + settings.unique_id, context).jPlayer('play');
  24. }
  25. },
  26. swfPath: '/libraries/jplayer/dist/jplayer',
  27. supplied: settings.filetype,
  28. wmode: 'window',
  29. useStateClassSkin: true,
  30. autoBlur: false,
  31. preload: settings.lazyload,
  32. smoothPlayBar: true,
  33. keyEnabled: true,
  34. remainingDuration: false,
  35. toggleDuration: false,
  36. volume: settings.volume
  37. });
  38. };
  39. Drupal.AudiofieldJplayer.generatePlaylist = function (context, settings) {
  40. $.each($(context).find('#jquery_jplayer_' + settings.unique_id).once('generate-jplayer'), function (index, item) {
  41. var thisPlaylist = new jPlayerPlaylist({
  42. jPlayer: $(item),
  43. cssSelectorAncestor: '#jp_container_' + settings.unique_id
  44. }, [], {
  45. canplay: function canplay() {
  46. if (!!settings.autoplay) {
  47. $(item).jPlayer('play');
  48. }
  49. },
  50. playlistOptions: {
  51. enableRemoveControls: false
  52. },
  53. swfPath: '/libraries/jplayer/dist/jplayer',
  54. wmode: 'window',
  55. useStateClassSkin: true,
  56. autoBlur: false,
  57. preload: settings.lazyload,
  58. smoothPlayBar: true,
  59. keyEnabled: true,
  60. volume: settings.volume
  61. });
  62. $.each(settings.files, function (key, fileEntry) {
  63. var mediaArray = {
  64. title: fileEntry.description
  65. };
  66. mediaArray[fileEntry.filetype] = fileEntry.file;
  67. thisPlaylist.add(mediaArray);
  68. });
  69. });
  70. };
  71. Drupal.AudiofieldJplayer.generateCircle = function (context, file) {
  72. $.each($(context).find('#jquery_jplayer_' + file.fid).once('generate-jplayer'), function (index, item) {
  73. var mediaArray = {};
  74. mediaArray[file.filetype] = file.file;
  75. new CirclePlayer($(item), mediaArray, {
  76. cssSelectorAncestor: '#cp_container_' + file.fid,
  77. canplay: function canplay() {
  78. if (!!file.autoplay) {
  79. $(item).jPlayer('play');
  80. }
  81. },
  82. swfPath: '/libraries/jplayer/dist/jplayer',
  83. wmode: 'window',
  84. keyEnabled: true,
  85. preload: settings.lazyload,
  86. supplied: file.filetype
  87. });
  88. });
  89. };
  90. Drupal.behaviors.audiofieldjplayer = {
  91. attach: function attach(context, settings) {
  92. $.each(settings.audiofieldjplayer, function (key, settingEntry) {
  93. if (settingEntry.playertype === 'default') {
  94. Drupal.AudiofieldJplayer.generate(context, settingEntry);
  95. } else if (settingEntry.playertype === 'playlist') {
  96. Drupal.AudiofieldJplayer.generatePlaylist(context, settingEntry);
  97. } else if (settingEntry.playertype === 'circle') {
  98. $.each(settingEntry.files, function (key2, fileEntry) {
  99. Drupal.AudiofieldJplayer.generateCircle(context, fileEntry);
  100. });
  101. }
  102. });
  103. }
  104. };
  105. })(jQuery, Drupal);