saut Drupal 10.6.22 -> 11.4.13 (PHP 8.4 local)
- composer update -W: core-recommended ^11.4 (11.4.13), drush ^13.8, gin ^5.0, symfony 7 - scan p2 packages.drupal.org: 98/101 modules ont une release compatible D11; contraintes racine+profil relevées - takeover custom: audiofield + bulkdelete (plus de branche D11 upstream), q2d_mod blocs convertis en attributs PHP 8 - patch core 2671162 supprimé (fix mergé dans D11), 2645922 gardé, patches image_field_caption réappliqués - seven retiré (plus dans le core D11), claro déjà présent pour gin - updb OK, change list entity vide, cim OK, cex commit (normalisation config) - allow-plugins symfony/runtime ajouté Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @file
|
||||
* Audiofield build AudioJs audio player.
|
||||
*/
|
||||
|
||||
(($, Drupal, once) => {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldAudiojs = {};
|
||||
|
||||
/**
|
||||
* Generate an audio.js player.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {jQuery} settings
|
||||
* The Drupal settings for this player.
|
||||
*/
|
||||
Drupal.AudiofieldAudiojs.generate = (context, settings) => {
|
||||
// Create the media player.
|
||||
const elements = once('generate-audiojs', `#${settings.element}`, context);
|
||||
$.each(elements, (index, item) => {
|
||||
// Initialize the audio player.
|
||||
const audioPlayer = audiojs.create($(item).find('audio').get(0), {
|
||||
css: false,
|
||||
createPlayer: {
|
||||
markup: false,
|
||||
playPauseClass: 'play-pauseZ',
|
||||
scrubberClass: 'scrubberZ',
|
||||
progressClass: 'progressZ',
|
||||
loaderClass: 'loadedZ',
|
||||
timeClass: 'timeZ',
|
||||
durationClass: 'durationZ',
|
||||
playedClass: 'playedZ',
|
||||
errorMessageClass: 'error-messageZ',
|
||||
playingClass: 'playingZ',
|
||||
loadingClass: 'loadingZ',
|
||||
errorClass: 'errorZ',
|
||||
},
|
||||
// Handle the end of a track.
|
||||
trackEnded: () => {
|
||||
let next = $(context).find(`#${settings.element} ol li.playing`).next();
|
||||
if (!next.length) {
|
||||
next = $(context).find(`#${settings.element} ol li:first`);
|
||||
}
|
||||
next.addClass('playing').siblings().removeClass('playing');
|
||||
audioPlayer.load($('a', next).attr('data-src'));
|
||||
audioPlayer.play();
|
||||
},
|
||||
});
|
||||
|
||||
// Load in the first track.
|
||||
$(item).find('ol li:first').addClass('playing');
|
||||
audioPlayer.load($(item).find('ol a:first').attr('data-src'));
|
||||
|
||||
// Load in a track on click.
|
||||
$(item).find('ol li').click((event) => {
|
||||
event.preventDefault();
|
||||
$(event.currentTarget).addClass('playing').siblings().removeClass('playing');
|
||||
audioPlayer.load($('a', event.currentTarget).attr('data-src'));
|
||||
audioPlayer.play();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the behaviors to generate the audio player.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches generation of audio.js audio players.
|
||||
*/
|
||||
Drupal.behaviors.audiofieldaudiojs = {
|
||||
attach: (context, settings) => {
|
||||
$.each(settings.audiofieldaudiojs, (key, settingEntry) => {
|
||||
Drupal.AudiofieldAudiojs.generate(context, settingEntry);
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, once) {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldAudiojs = {};
|
||||
|
||||
Drupal.AudiofieldAudiojs.generate = function (context, settings) {
|
||||
var elements = once('generate-audiojs', '#' + settings.element, context);
|
||||
$.each(elements, function (index, item) {
|
||||
var audioPlayer = audiojs.create($(item).find('audio').get(0), {
|
||||
css: false,
|
||||
createPlayer: {
|
||||
markup: false,
|
||||
playPauseClass: 'play-pauseZ',
|
||||
scrubberClass: 'scrubberZ',
|
||||
progressClass: 'progressZ',
|
||||
loaderClass: 'loadedZ',
|
||||
timeClass: 'timeZ',
|
||||
durationClass: 'durationZ',
|
||||
playedClass: 'playedZ',
|
||||
errorMessageClass: 'error-messageZ',
|
||||
playingClass: 'playingZ',
|
||||
loadingClass: 'loadingZ',
|
||||
errorClass: 'errorZ'
|
||||
},
|
||||
|
||||
trackEnded: function trackEnded() {
|
||||
var next = $(context).find('#' + settings.element + ' ol li.playing').next();
|
||||
if (!next.length) {
|
||||
next = $(context).find('#' + settings.element + ' ol li:first');
|
||||
}
|
||||
next.addClass('playing').siblings().removeClass('playing');
|
||||
audioPlayer.load($('a', next).attr('data-src'));
|
||||
audioPlayer.play();
|
||||
}
|
||||
});
|
||||
|
||||
$(item).find('ol li:first').addClass('playing');
|
||||
audioPlayer.load($(item).find('ol a:first').attr('data-src'));
|
||||
|
||||
$(item).find('ol li').click(function (event) {
|
||||
event.preventDefault();
|
||||
$(event.currentTarget).addClass('playing').siblings().removeClass('playing');
|
||||
audioPlayer.load($('a', event.currentTarget).attr('data-src'));
|
||||
audioPlayer.play();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.behaviors.audiofieldaudiojs = {
|
||||
attach: function attach(context, settings) {
|
||||
$.each(settings.audiofieldaudiojs, function (key, settingEntry) {
|
||||
Drupal.AudiofieldAudiojs.generate(context, settingEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* @file
|
||||
* Audiofield build jPlayer audio players of various types.
|
||||
*/
|
||||
|
||||
(($, Drupal, once) => {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldJplayer = {};
|
||||
|
||||
/**
|
||||
* Generate a jplayer player for the default single file layout.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {jQuery} settings
|
||||
* The Drupal settings for this player.
|
||||
*/
|
||||
Drupal.AudiofieldJplayer.generate = (context, settings) => {
|
||||
// Create the media player.
|
||||
const element = once('generate-jplayer', '#jquery_jplayer_' + settings.unique_id, context);
|
||||
$(element).jPlayer(
|
||||
{
|
||||
cssSelectorAncestor: `#jp_container_${settings.unique_id}`,
|
||||
},
|
||||
{
|
||||
ready: () => {
|
||||
const mediaArray = {
|
||||
title: settings.description,
|
||||
};
|
||||
mediaArray[settings.filetype] = settings.file;
|
||||
$(`#jquery_jplayer_${settings.unique_id}`, context).jPlayer('setMedia', mediaArray);
|
||||
},
|
||||
canplay: () => {
|
||||
// Handle autoplay.
|
||||
if (!!settings.autoplay) {
|
||||
$(`#jquery_jplayer_${settings.unique_id}`, context).jPlayer('play');
|
||||
}
|
||||
},
|
||||
swfPath: '/libraries/jplayer/dist/jplayer',
|
||||
supplied: settings.filetype,
|
||||
wmode: 'window',
|
||||
useStateClassSkin: true,
|
||||
autoBlur: false,
|
||||
preload: settings.lazyload,
|
||||
smoothPlayBar: true,
|
||||
keyEnabled: true,
|
||||
remainingDuration: false,
|
||||
toggleDuration: false,
|
||||
volume: settings.volume,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a jplayer formatter for a player.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {jQuery} settings
|
||||
* The Drupal settings for this player.
|
||||
*/
|
||||
Drupal.AudiofieldJplayer.generatePlaylist = (context, settings) => {
|
||||
var elements = once('generate-jplayer', '#jquery_jplayer_' + settings.unique_id, context);
|
||||
$.each(elements, (index, item) => {
|
||||
// Initialize the container audio player.
|
||||
const thisPlaylist = new jPlayerPlaylist({
|
||||
jPlayer: $(item),
|
||||
cssSelectorAncestor: `#jp_container_${settings.unique_id}`,
|
||||
}, [], {
|
||||
canplay: () => {
|
||||
// Handle autoplay.
|
||||
if (!!settings.autoplay) {
|
||||
$(item).jPlayer('play');
|
||||
}
|
||||
},
|
||||
playlistOptions: {
|
||||
enableRemoveControls: false,
|
||||
},
|
||||
swfPath: '/libraries/jplayer/dist/jplayer',
|
||||
wmode: 'window',
|
||||
useStateClassSkin: true,
|
||||
autoBlur: false,
|
||||
preload: settings.lazyload,
|
||||
smoothPlayBar: true,
|
||||
keyEnabled: true,
|
||||
volume: settings.volume,
|
||||
});
|
||||
|
||||
// Loop over each file.
|
||||
$.each(settings.files, (key, fileEntry) => {
|
||||
// Build the media array.
|
||||
const mediaArray = {
|
||||
title: fileEntry.description,
|
||||
};
|
||||
mediaArray[fileEntry.filetype] = fileEntry.file;
|
||||
// Add the file to the playlist.
|
||||
thisPlaylist.add(mediaArray);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a jplayer circle player.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {array} file
|
||||
* The audio file for which we are generating a player.
|
||||
*/
|
||||
Drupal.AudiofieldJplayer.generateCircle = (context, file) => {
|
||||
// Create the media player.
|
||||
var elements = once('generate-jplayer', '#jquery_jplayer_' + file.fid, context);
|
||||
$.each(elements, (index, item) => {
|
||||
// Build the media array for this player.
|
||||
const mediaArray = {};
|
||||
mediaArray[file.filetype] = file.file;
|
||||
|
||||
// Initialize the player.
|
||||
new CirclePlayer(
|
||||
$(item),
|
||||
mediaArray,
|
||||
{
|
||||
cssSelectorAncestor: `#cp_container_${file.fid}`,
|
||||
canplay: () => {
|
||||
// Handle autoplay.
|
||||
if (!!file.autoplay) {
|
||||
$(item).jPlayer('play');
|
||||
}
|
||||
},
|
||||
swfPath: '/libraries/jplayer/dist/jplayer',
|
||||
wmode: 'window',
|
||||
preload: file.lazyload,
|
||||
keyEnabled: true,
|
||||
supplied: file.filetype,
|
||||
},
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the behaviors to generate the audio player.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches generation of Jplayer audio players.
|
||||
*/
|
||||
Drupal.behaviors.audiofieldjplayer = {
|
||||
attach: (context, settings) => {
|
||||
$.each(settings.audiofieldjplayer, (key, settingEntry) => {
|
||||
// Default audio player.
|
||||
if (settingEntry.playertype === 'default') {
|
||||
// We can just initialize the audio player direcly.
|
||||
Drupal.AudiofieldJplayer.generate(context, settingEntry);
|
||||
}
|
||||
// Playlist audio player.
|
||||
else if (settingEntry.playertype === 'playlist') {
|
||||
Drupal.AudiofieldJplayer.generatePlaylist(context, settingEntry);
|
||||
}
|
||||
// Circle audio player.
|
||||
else if (settingEntry.playertype === 'circle') {
|
||||
// Loop over the files.
|
||||
$.each(settingEntry.files, (key2, fileEntry) => {
|
||||
// Create the player.
|
||||
Drupal.AudiofieldJplayer.generateCircle(context, fileEntry);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, once) {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldJplayer = {};
|
||||
|
||||
Drupal.AudiofieldJplayer.generate = function (context, settings) {
|
||||
var element = once('generate-jplayer', '#jquery_jplayer_' + settings.unique_id, context);
|
||||
$(element).jPlayer({
|
||||
cssSelectorAncestor: '#jp_container_' + settings.unique_id
|
||||
}, {
|
||||
ready: function ready() {
|
||||
var mediaArray = {
|
||||
title: settings.description
|
||||
};
|
||||
mediaArray[settings.filetype] = settings.file;
|
||||
$('#jquery_jplayer_' + settings.unique_id, context).jPlayer('setMedia', mediaArray);
|
||||
},
|
||||
canplay: function canplay() {
|
||||
if (!!settings.autoplay) {
|
||||
$('#jquery_jplayer_' + settings.unique_id, context).jPlayer('play');
|
||||
}
|
||||
},
|
||||
swfPath: '/libraries/jplayer/dist/jplayer',
|
||||
supplied: settings.filetype,
|
||||
wmode: 'window',
|
||||
useStateClassSkin: true,
|
||||
autoBlur: false,
|
||||
preload: settings.lazyload,
|
||||
smoothPlayBar: true,
|
||||
keyEnabled: true,
|
||||
remainingDuration: false,
|
||||
toggleDuration: false,
|
||||
volume: settings.volume
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.AudiofieldJplayer.generatePlaylist = function (context, settings) {
|
||||
var elements = once('generate-jplayer', '#jquery_jplayer_' + settings.unique_id, context);
|
||||
$.each(elements, function (index, item) {
|
||||
var thisPlaylist = new jPlayerPlaylist({
|
||||
jPlayer: $(item),
|
||||
cssSelectorAncestor: '#jp_container_' + settings.unique_id
|
||||
}, [], {
|
||||
canplay: function canplay() {
|
||||
if (!!settings.autoplay) {
|
||||
$(item).jPlayer('play');
|
||||
}
|
||||
},
|
||||
playlistOptions: {
|
||||
enableRemoveControls: false
|
||||
},
|
||||
swfPath: '/libraries/jplayer/dist/jplayer',
|
||||
wmode: 'window',
|
||||
useStateClassSkin: true,
|
||||
autoBlur: false,
|
||||
preload: settings.lazyload,
|
||||
smoothPlayBar: true,
|
||||
keyEnabled: true,
|
||||
volume: settings.volume
|
||||
});
|
||||
|
||||
$.each(settings.files, function (key, fileEntry) {
|
||||
var mediaArray = {
|
||||
title: fileEntry.description
|
||||
};
|
||||
mediaArray[fileEntry.filetype] = fileEntry.file;
|
||||
|
||||
thisPlaylist.add(mediaArray);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.AudiofieldJplayer.generateCircle = function (context, file) {
|
||||
var elements = once('generate-jplayer', '#jquery_jplayer_' + file.fid, context);
|
||||
$.each(elements, function (index, item) {
|
||||
var mediaArray = {};
|
||||
mediaArray[file.filetype] = file.file;
|
||||
|
||||
new CirclePlayer($(item), mediaArray, {
|
||||
cssSelectorAncestor: '#cp_container_' + file.fid,
|
||||
canplay: function canplay() {
|
||||
if (!!file.autoplay) {
|
||||
$(item).jPlayer('play');
|
||||
}
|
||||
},
|
||||
swfPath: '/libraries/jplayer/dist/jplayer',
|
||||
wmode: 'window',
|
||||
keyEnabled: true,
|
||||
preload: file.lazyload,
|
||||
supplied: file.filetype
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.behaviors.audiofieldjplayer = {
|
||||
attach: function attach(context, settings) {
|
||||
$.each(settings.audiofieldjplayer, function (key, settingEntry) {
|
||||
if (settingEntry.playertype === 'default') {
|
||||
Drupal.AudiofieldJplayer.generate(context, settingEntry);
|
||||
} else if (settingEntry.playertype === 'playlist') {
|
||||
Drupal.AudiofieldJplayer.generatePlaylist(context, settingEntry);
|
||||
} else if (settingEntry.playertype === 'circle') {
|
||||
$.each(settingEntry.files, function (key2, fileEntry) {
|
||||
Drupal.AudiofieldJplayer.generateCircle(context, fileEntry);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @file
|
||||
* Audiofield jPlayer Circleplayer issue fix.
|
||||
*
|
||||
* Circleplayer is not properly namespaced, it assumes $ = jQuery.
|
||||
* We have to define that namespace equivalence here to prevent issues.
|
||||
*/
|
||||
|
||||
var $ = jQuery;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
var $ = jQuery;
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file
|
||||
* Audiofield build MediaElement audio player.
|
||||
*/
|
||||
|
||||
(($, Drupal, once) => {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldMediaelement = {};
|
||||
|
||||
/**
|
||||
* Generate a mediaelement player.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {array} file
|
||||
* The audio file for which we are generating a player.
|
||||
* @param {jQuery} settings
|
||||
* The Drupal settings for this player..
|
||||
*/
|
||||
Drupal.AudiofieldMediaelement.generate = (context, file, settings) => {
|
||||
// Create the media player.
|
||||
const element = once('generate-mediaelement', file, context);
|
||||
$(element).mediaelementplayer({
|
||||
startVolume: settings.volume,
|
||||
loop: false,
|
||||
enableAutosize: true,
|
||||
isVideo: false,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the behaviors to generate the audio player.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches generation of MediaElement audio players.
|
||||
*/
|
||||
Drupal.behaviors.audiofieldmediaelement = {
|
||||
attach: (context, settings) => {
|
||||
$.each(settings.audiofieldmediaelement, (key, settingEntry) => {
|
||||
// Loop over each file.
|
||||
$.each(settingEntry.elements, (key2, fileEntry) => {
|
||||
// Create the media player.
|
||||
Drupal.AudiofieldMediaelement.generate(context, fileEntry, settingEntry);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, once) {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldMediaelement = {};
|
||||
|
||||
Drupal.AudiofieldMediaelement.generate = function (context, file, settings) {
|
||||
var element = once('generate-mediaelement', file, context);
|
||||
$(element).mediaelementplayer({
|
||||
startVolume: settings.volume,
|
||||
loop: false,
|
||||
enableAutosize: true,
|
||||
isVideo: false
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.behaviors.audiofieldmediaelement = {
|
||||
attach: function attach(context, settings) {
|
||||
$.each(settings.audiofieldmediaelement, function (key, settingEntry) {
|
||||
$.each(settingEntry.elements, function (key2, fileEntry) {
|
||||
Drupal.AudiofieldMediaelement.generate(context, fileEntry, settingEntry);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file
|
||||
* Audiofield build Projekktor audio player.
|
||||
*/
|
||||
|
||||
(($, Drupal, once) => {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldProjekktor = {};
|
||||
|
||||
/**
|
||||
* Generate a projekktor player.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {array} file
|
||||
* The audio file for which we are generating a player.
|
||||
* @param {jQuery} settings
|
||||
* The Drupal settings for this player..
|
||||
*/
|
||||
Drupal.AudiofieldProjekktor.generate = (context, file, settings) => {
|
||||
const elements = once('generate-projekktor', `#${file}`, context);
|
||||
$.each(elements, (index, item) => {
|
||||
projekktor($(item), {
|
||||
debug: false,
|
||||
playerFlashMP4: settings.swfpath,
|
||||
playerFlashMP3: settings.swfpath,
|
||||
enableFullscreen: false,
|
||||
streamType: 'http',
|
||||
controls: true,
|
||||
thereCanBeOnlyOne: true,
|
||||
volume: settings.volume,
|
||||
autoplay: !!settings.autoplay,
|
||||
plugin_display: {},
|
||||
}, {});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the behaviors to generate the audio player.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches generation of Projekktor audio players.
|
||||
*/
|
||||
Drupal.behaviors.audiofieldprojekktor = {
|
||||
attach: (context, settings) => {
|
||||
// Have to encapsulate because of the way library is created.
|
||||
jQuery(() => {
|
||||
$.each(settings.audiofieldprojekktor, (key, settingEntry) => {
|
||||
// Loop over the attached files.
|
||||
$.each(settingEntry.files, (key2, file) => {
|
||||
// Create the audioplayer for each file.
|
||||
Drupal.AudiofieldProjekktor.generate(context, file, settingEntry);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, once) {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldProjekktor = {};
|
||||
|
||||
Drupal.AudiofieldProjekktor.generate = function (context, file, settings) {
|
||||
var elements = once('generate-projekktor', '#' + file, context);
|
||||
$.each(elements, function (index, item) {
|
||||
projekktor($(item), {
|
||||
debug: false,
|
||||
playerFlashMP4: settings.swfpath,
|
||||
playerFlashMP3: settings.swfpath,
|
||||
enableFullscreen: false,
|
||||
streamType: 'http',
|
||||
controls: true,
|
||||
thereCanBeOnlyOne: true,
|
||||
volume: settings.volume,
|
||||
autoplay: !!settings.autoplay,
|
||||
plugin_display: {}
|
||||
}, {});
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.behaviors.audiofieldprojekktor = {
|
||||
attach: function attach(context, settings) {
|
||||
jQuery(function () {
|
||||
$.each(settings.audiofieldprojekktor, function (key, settingEntry) {
|
||||
$.each(settingEntry.files, function (key2, file) {
|
||||
Drupal.AudiofieldProjekktor.generate(context, file, settingEntry);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @file
|
||||
* Audiofield build SoundManager audio player.
|
||||
*/
|
||||
|
||||
(($, Drupal, once) => {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Attach the behaviors to generate the audio player.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches generation of Soundmanager audio players.
|
||||
*/
|
||||
Drupal.behaviors.audiofieldsoundmanager = {
|
||||
attach: (context, settings) => {
|
||||
// Soundmanager intercepts everything so the setup is very simple.
|
||||
soundManager.setup({
|
||||
// Required: path to directory containing SM2 SWF files.
|
||||
url: settings.audiofieldsoundmanager.swfpath,
|
||||
preferFlash: false,
|
||||
defaultOptions: {
|
||||
volume: settings.audiofieldsoundmanager.volume,
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, once) {
|
||||
'use strict';
|
||||
|
||||
Drupal.behaviors.audiofieldsoundmanager = {
|
||||
attach: function attach(context, settings) {
|
||||
soundManager.setup({
|
||||
url: settings.audiofieldsoundmanager.swfpath,
|
||||
preferFlash: false,
|
||||
defaultOptions: {
|
||||
volume: settings.audiofieldsoundmanager.volume
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,346 @@
|
||||
/**
|
||||
* @file
|
||||
* Audiofield build Wavesurfer audio player.
|
||||
*/
|
||||
|
||||
(($, Drupal, once) => {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldWavesurfer = {};
|
||||
|
||||
/**
|
||||
* Generate a wavesurfer player.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {array} file
|
||||
* The audio file for which we are generating a player.
|
||||
* @param {jQuery} settings
|
||||
* The Drupal settings for this player..
|
||||
*/
|
||||
Drupal.AudiofieldWavesurfer.generate = (context, file, settings) => {
|
||||
const elements = once('generate-waveform', `#${file.id}`, context);
|
||||
$.each(elements, (index, wavecontainer) => {
|
||||
// Create waveform.
|
||||
const wavesurfer = WaveSurfer.create({
|
||||
container: `#${$(wavecontainer).attr('id')} .waveform`,
|
||||
backend: settings.backend,
|
||||
audioRate: settings.audioRate,
|
||||
autoCenter: settings.autoCenter,
|
||||
barGap: settings.barGap,
|
||||
barHeight: settings.barHeight,
|
||||
barWidth: settings.barWidth,
|
||||
cursorColor: settings.cursorColor,
|
||||
cursorWidth: settings.cursorWidth,
|
||||
forceDecode: settings.forceDecode,
|
||||
normalize: settings.normalize,
|
||||
progressColor: settings.progressColor,
|
||||
responsive: settings.responsive,
|
||||
waveColor: settings.waveColor,
|
||||
});
|
||||
|
||||
// Check if a peak file has been provided.
|
||||
if (typeof file.peakpath !== 'undefined') {
|
||||
// Fetch the provided file.
|
||||
fetch(file.peakpath)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("HTTP error " + response.status);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(peaks => {
|
||||
// Normalize the provided peaks data.
|
||||
Drupal.AudiofieldWavesurfer.normalizePeaks(peaks);
|
||||
|
||||
// Load the file.
|
||||
wavesurfer.load(file.path, peaks.data);
|
||||
$(wavecontainer).find('.player-button.playpause').html('Play');
|
||||
})
|
||||
.catch((e) => {
|
||||
// Failed to load peaks, just load file normally.
|
||||
wavesurfer.load(file.path);
|
||||
console.error('error', e);
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Load file without peaks.
|
||||
wavesurfer.load(file.path);
|
||||
}
|
||||
|
||||
// Set the default volume.
|
||||
wavesurfer.setVolume(settings.volume);
|
||||
|
||||
// Handle play/pause.
|
||||
$(wavecontainer).find('.player-button.playpause').on('click', (event) => {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
});
|
||||
|
||||
// Handle volume change.
|
||||
$(wavecontainer).find('.volume').on('change', (event) => {
|
||||
wavesurfer.setVolume(($(event.currentTarget).val() / 10));
|
||||
});
|
||||
|
||||
// Handle autoplay.
|
||||
if (!!settings.autoplay) {
|
||||
wavesurfer.on('ready', wavesurfer.play.bind(wavesurfer));
|
||||
}
|
||||
Drupal.AudiofieldWavesurfer.instance = wavesurfer;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize a peak file
|
||||
*
|
||||
* @param {jQuery} peaks
|
||||
* The Wavesurfer peaks data for which we are normalizing data.
|
||||
*/
|
||||
Drupal.AudiofieldWavesurfer.normalizePeaks = function (peaks) {
|
||||
var max = peaks.data[0], min = peaks.data[0];
|
||||
var X, scale;
|
||||
for (X = 1; X < peaks.data.length; X++) {
|
||||
if (max < peaks.data[X]) {
|
||||
max = peaks.data[X];
|
||||
}
|
||||
if (min > peaks.data[X]) {
|
||||
min = peaks.data[X];
|
||||
}
|
||||
}
|
||||
scale = 1.0 / Math.max(Math.abs(min), Math.abs(max));
|
||||
for (X = 0; X < peaks.data.length; X++) {
|
||||
peaks.data[X] *= scale;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a wavesurfer playlist player.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {jQuery} settings
|
||||
* The Drupal settings for this player.
|
||||
*/
|
||||
Drupal.AudiofieldWavesurfer.generatePlaylist = (context, settings) => {
|
||||
const elements = once('generate-waveform', `#wavesurfer_playlist-${settings.unique_id}`, context);
|
||||
$.each(elements, (index, wavecontainer) => {
|
||||
// Create waveform.
|
||||
const wavesurfer = WaveSurfer.create({
|
||||
container: `#${$(wavecontainer).attr('id')} .waveform`,
|
||||
audioRate: settings.audioRate,
|
||||
autoCenter: settings.autoCenter,
|
||||
barGap: settings.barGap,
|
||||
barHeight: settings.barHeight,
|
||||
barWidth: settings.barWidth,
|
||||
cursorColor: settings.cursorColor,
|
||||
cursorWidth: settings.cursorWidth,
|
||||
forceDecode: settings.forceDecode,
|
||||
normalize: settings.normalize,
|
||||
progressColor: settings.progressColor,
|
||||
responsive: settings.responsive,
|
||||
waveColor: settings.waveColor,
|
||||
});
|
||||
|
||||
// Set the default volume.
|
||||
wavesurfer.setVolume(settings.volume);
|
||||
|
||||
// Load the first file.
|
||||
const first = $(wavecontainer).find('.playlist .track').first();
|
||||
// Get the label and update it with the first filename.
|
||||
const label = $(wavecontainer).find('label').first();
|
||||
label.html(`Playing: ${first.html()}`);
|
||||
// Set the playing class on the first element.
|
||||
first.addClass('playing');
|
||||
|
||||
// Load the file.
|
||||
Drupal.AudiofieldWavesurfer.Load(wavecontainer, wavesurfer, first, false);
|
||||
|
||||
// Handle play/pause.
|
||||
$(wavecontainer).find('.player-button.playpause').on('click', (event) => {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
});
|
||||
|
||||
// Handle next/previous.
|
||||
$(wavecontainer).find('.player-button.next').on('click', (event) => {
|
||||
Drupal.AudiofieldWavesurfer.Next(wavecontainer, wavesurfer);
|
||||
});
|
||||
$(wavecontainer).find('.player-button.previous').on('click', (event) => {
|
||||
Drupal.AudiofieldWavesurfer.Previous(wavecontainer, wavesurfer);
|
||||
});
|
||||
|
||||
// Handle clicking track.
|
||||
$(wavecontainer).find('.playlist .track').on('click', (event) => {
|
||||
// Check if the track is already playing.
|
||||
if ($(this).hasClass('playing')) {
|
||||
// Play/pause the track if it is already loaded.
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
}
|
||||
else {
|
||||
// Load the track.
|
||||
Drupal.AudiofieldWavesurfer.Load(wavecontainer, wavesurfer, $(event.currentTarget));
|
||||
}
|
||||
});
|
||||
|
||||
// Handle volume change.
|
||||
$(wavecontainer).find('.volume').on('change', (event) => {
|
||||
wavesurfer.setVolume(($(event.currentTarget).val() / 10));
|
||||
});
|
||||
|
||||
// Handle autoplay.
|
||||
if (!!settings.autoplay) {
|
||||
wavesurfer.on('ready', wavesurfer.play.bind(wavesurfer));
|
||||
}
|
||||
|
||||
// Handle track finishing.
|
||||
if (settings.autoplayNextTrack) {
|
||||
wavesurfer.on('finish', (event) => {
|
||||
Drupal.AudiofieldWavesurfer.Next(wavecontainer, wavesurfer);
|
||||
});
|
||||
}
|
||||
Drupal.AudiofieldWavesurfer.instance = wavesurfer;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Play or pause the wavesurfer and set appropriate classes.
|
||||
*
|
||||
* @param {jQuery} wavecontainer
|
||||
* The container of the wavesurfer element we are accessing.
|
||||
* @param {jQuery} wavesurfer
|
||||
* The wavesurfer player we are accessing.
|
||||
*/
|
||||
Drupal.AudiofieldWavesurfer.PlayPause = (wavecontainer, wavesurfer) => {
|
||||
wavesurfer.playPause();
|
||||
const button = $(wavecontainer).find('.player-button.playpause');
|
||||
if (wavesurfer.isPlaying()) {
|
||||
$(wavecontainer).addClass('playing');
|
||||
button.html('Pause');
|
||||
}
|
||||
else {
|
||||
$(wavecontainer).removeClass('playing');
|
||||
button.html('Play');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Load track on wavesurfer and set appropriate classes.
|
||||
*
|
||||
* @param {jQuery} wavecontainer
|
||||
* The container of the wavesurfer element we are accessing.
|
||||
* @param {jQuery} wavesurfer
|
||||
* The wavesurfer player we are accessing.
|
||||
* @param {jQuery} track
|
||||
* The track being loaded into the player.
|
||||
*/
|
||||
Drupal.AudiofieldWavesurfer.Load = (wavecontainer, wavesurfer, track, playonload = true) => {
|
||||
// Check for peak file.
|
||||
const peakpath = track.attr('data-peakpath');
|
||||
if (peakpath !== '') {
|
||||
// Fetch the peak file.
|
||||
fetch(peakpath)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("HTTP error " + response.status);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(peaks => {
|
||||
// Normalize the peaks.
|
||||
Drupal.AudiofieldWavesurfer.normalizePeaks(peaks);
|
||||
|
||||
// Load the file with peaks data.
|
||||
wavesurfer.load(track.attr('data-src'), peaks.data);
|
||||
})
|
||||
.catch((e) => {
|
||||
// Error loading peaks, load file normally.
|
||||
wavesurfer.load(track.attr('data-src'));
|
||||
console.error('error', e);
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Load the track normally.
|
||||
wavesurfer.load(track.attr('data-src'));
|
||||
}
|
||||
|
||||
wavesurfer.on('ready', (event) => {
|
||||
if (playonload) {
|
||||
$(wavecontainer).removeClass('playing');
|
||||
$(wavecontainer).addClass('playing');
|
||||
$(wavecontainer).find('.player-button.playpause').html('Pause');
|
||||
wavesurfer.play();
|
||||
}
|
||||
});
|
||||
// Remove playing from all other tracks.
|
||||
$(wavecontainer).find('.track').removeClass('playing');
|
||||
// Set the class on this track.
|
||||
track.addClass('playing');
|
||||
// Show what's playing.
|
||||
$(wavecontainer).find('label').first().html(`Playing: ${track.html()}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* Skip track forward on wavesurfer and set appropriate classes.
|
||||
*
|
||||
* @param {jQuery} wavecontainer
|
||||
* The container of the wavesurfer element we are accessing.
|
||||
* @param {jQuery} wavesurfer
|
||||
* The wavesurfer player we are accessing.
|
||||
*/
|
||||
Drupal.AudiofieldWavesurfer.Next = (wavecontainer, wavesurfer) => {
|
||||
if (wavesurfer.isPlaying()) {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
}
|
||||
// Find the next track.
|
||||
let track = $(wavecontainer).find('.track.playing').next();
|
||||
if (typeof track.attr('data-src') === 'undefined') {
|
||||
track = $(wavecontainer).find('.track').first();
|
||||
}
|
||||
// Load the track.
|
||||
Drupal.AudiofieldWavesurfer.Load(wavecontainer, wavesurfer, track);
|
||||
};
|
||||
|
||||
/**
|
||||
* Skip track back on wavesurfer and set appropriate classes.
|
||||
*
|
||||
* @param {jQuery} wavecontainer
|
||||
* The container of the wavesurfer element we are accessing.
|
||||
* @param {jQuery} wavesurfer
|
||||
* The wavesurfer player we are accessing.
|
||||
*/
|
||||
Drupal.AudiofieldWavesurfer.Previous = (wavecontainer, wavesurfer) => {
|
||||
if (wavesurfer.isPlaying()) {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
}
|
||||
// Find the next track.
|
||||
let track = $(wavecontainer).find('.track.playing').prev();
|
||||
if (typeof track.attr('data-src') === 'undefined') {
|
||||
track = $(wavecontainer).find('.track').last();
|
||||
}
|
||||
// Load the track.
|
||||
Drupal.AudiofieldWavesurfer.Load(wavecontainer, wavesurfer, track);
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the behaviors to generate the audio player.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches generation of Wavesurfer audio players.
|
||||
*/
|
||||
Drupal.behaviors.audiofieldwavesurfer = {
|
||||
attach: (context, settings) => {
|
||||
$.each(settings.audiofieldwavesurfer, (key, settingEntry) => {
|
||||
// Default audio player.
|
||||
if (settingEntry.playertype === 'default') {
|
||||
// Loop over the files.
|
||||
$.each(settingEntry.files, (key2, file) => {
|
||||
Drupal.AudiofieldWavesurfer.generate(context, file, settingEntry);
|
||||
});
|
||||
}
|
||||
else if (settingEntry.playertype === 'playlist') {
|
||||
Drupal.AudiofieldWavesurfer.generatePlaylist(context, settingEntry);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,248 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, once) {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldWavesurfer = {};
|
||||
|
||||
Drupal.AudiofieldWavesurfer.generate = function (context, file, settings) {
|
||||
var elements = once('generate-waveform', '#' + file.id, context);
|
||||
$.each(elements, function (index, wavecontainer) {
|
||||
var wavesurfer = WaveSurfer.create({
|
||||
container: '#' + $(wavecontainer).attr('id') + ' .waveform',
|
||||
backend: settings.backend,
|
||||
audioRate: settings.audioRate,
|
||||
autoCenter: settings.autoCenter,
|
||||
barGap: settings.barGap,
|
||||
barHeight: settings.barHeight,
|
||||
barWidth: settings.barWidth,
|
||||
cursorColor: settings.cursorColor,
|
||||
cursorWidth: settings.cursorWidth,
|
||||
forceDecode: settings.forceDecode,
|
||||
normalize: settings.normalize,
|
||||
progressColor: settings.progressColor,
|
||||
responsive: settings.responsive,
|
||||
waveColor: settings.waveColor
|
||||
});
|
||||
|
||||
if (typeof file.peakpath !== 'undefined') {
|
||||
fetch(file.peakpath)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("HTTP error " + response.status);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(peaks => {
|
||||
Drupal.AudiofieldWavesurfer.normalizePeaks(peaks);
|
||||
|
||||
wavesurfer.load(file.path, peaks.data);
|
||||
$(wavecontainer).find('.player-button.playpause').html('Play');
|
||||
})
|
||||
.catch((e) => {
|
||||
wavesurfer.load(file.path);
|
||||
console.error('error', e);
|
||||
});
|
||||
}
|
||||
else {
|
||||
wavesurfer.load(file.path);
|
||||
}
|
||||
|
||||
wavesurfer.setVolume(settings.volume);
|
||||
|
||||
$(wavecontainer).find('.player-button.playpause').on('click', function (event) {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
});
|
||||
|
||||
$(wavecontainer).find('.volume').on('change', function (event) {
|
||||
wavesurfer.setVolume($(event.currentTarget).val() / 10);
|
||||
});
|
||||
|
||||
if (!!settings.autoplay) {
|
||||
wavesurfer.on('ready', wavesurfer.play.bind(wavesurfer));
|
||||
}
|
||||
Drupal.AudiofieldWavesurfer.instance = wavesurfer;
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.AudiofieldWavesurfer.normalizePeaks = function (peaks) {
|
||||
var max = peaks.data[0], min = peaks.data[0];
|
||||
var X, scale;
|
||||
for (X = 1; X < peaks.data.length; X++) {
|
||||
if (max < peaks.data[X]) {
|
||||
max = peaks.data[X];
|
||||
}
|
||||
if (min > peaks.data[X]) {
|
||||
min = peaks.data[X];
|
||||
}
|
||||
}
|
||||
scale = 1.0 / Math.max(Math.abs(min), Math.abs(max));
|
||||
for (X = 0; X < peaks.data.length; X++) {
|
||||
peaks.data[X] *= scale;
|
||||
}
|
||||
}
|
||||
|
||||
Drupal.AudiofieldWavesurfer.generatePlaylist = function (context, settings) {
|
||||
var elements = once('generate-waveform', '#wavesurfer_playlist-' + settings.unique_id, context);
|
||||
$.each(elements, function (index, wavecontainer) {
|
||||
var wavesurfer = WaveSurfer.create({
|
||||
container: '#' + $(wavecontainer).attr('id') + ' .waveform',
|
||||
audioRate: settings.audioRate,
|
||||
autoCenter: settings.autoCenter,
|
||||
barGap: settings.barGap,
|
||||
barHeight: settings.barHeight,
|
||||
barWidth: settings.barWidth,
|
||||
cursorColor: settings.cursorColor,
|
||||
cursorWidth: settings.cursorWidth,
|
||||
forceDecode: settings.forceDecode,
|
||||
normalize: settings.normalize,
|
||||
progressColor: settings.progressColor,
|
||||
responsive: settings.responsive,
|
||||
waveColor: settings.waveColor
|
||||
});
|
||||
|
||||
wavesurfer.setVolume(settings.volume);
|
||||
|
||||
var first = $(wavecontainer).find('.playlist .track').first();
|
||||
|
||||
var label = $(wavecontainer).find('label').first();
|
||||
label.html('Playing: ' + first.html());
|
||||
|
||||
Drupal.AudiofieldWavesurfer.Load(wavecontainer, wavesurfer, first, false);
|
||||
|
||||
$(wavecontainer).find('.player-button.playpause').on('click', function (event) {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
});
|
||||
|
||||
$(wavecontainer).find('.player-button.next').on('click', function (event) {
|
||||
Drupal.AudiofieldWavesurfer.Next(wavecontainer, wavesurfer);
|
||||
});
|
||||
$(wavecontainer).find('.player-button.previous').on('click', function (event) {
|
||||
Drupal.AudiofieldWavesurfer.Previous(wavecontainer, wavesurfer);
|
||||
});
|
||||
|
||||
$(wavecontainer).find('.playlist .track').on('click', function (event) {
|
||||
if ($(this).hasClass('playing')) {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
}
|
||||
else {
|
||||
Drupal.AudiofieldWavesurfer.Load(wavecontainer, wavesurfer, $(event.currentTarget));
|
||||
}
|
||||
});
|
||||
|
||||
$(wavecontainer).find('.volume').on('change', function (event) {
|
||||
wavesurfer.setVolume($(event.currentTarget).val() / 10);
|
||||
});
|
||||
|
||||
if (!!settings.autoplay) {
|
||||
wavesurfer.on('ready', wavesurfer.play.bind(wavesurfer));
|
||||
}
|
||||
|
||||
if (settings.autoplayNextTrack) {
|
||||
wavesurfer.on('finish', function (event) {
|
||||
Drupal.AudiofieldWavesurfer.Next(wavecontainer, wavesurfer);
|
||||
});
|
||||
}
|
||||
|
||||
Drupal.AudiofieldWavesurfer.instance = wavesurfer;
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.AudiofieldWavesurfer.PlayPause = function (wavecontainer, wavesurfer) {
|
||||
wavesurfer.playPause();
|
||||
var button = $(wavecontainer).find('.player-button.playpause');
|
||||
if (wavesurfer.isPlaying()) {
|
||||
$(wavecontainer).addClass('playing');
|
||||
button.html('Pause');
|
||||
} else {
|
||||
$(wavecontainer).removeClass('playing');
|
||||
button.html('Play');
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.AudiofieldWavesurfer.Load = function (wavecontainer, wavesurfer, track, playonload = true) {
|
||||
|
||||
var peakpath = track.attr('data-peakpath');
|
||||
if (peakpath !== '') {
|
||||
fetch(peakpath)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("HTTP error " + response.status);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(peaks => {
|
||||
Drupal.AudiofieldWavesurfer.normalizePeaks(peaks);
|
||||
|
||||
wavesurfer.load(track.attr('data-src'), peaks.data);
|
||||
})
|
||||
.catch((e) => {
|
||||
wavesurfer.load(track.attr('data-src'));
|
||||
console.error('error', e);
|
||||
});
|
||||
}
|
||||
else {
|
||||
wavesurfer.load(track.attr('data-src'));
|
||||
}
|
||||
|
||||
wavesurfer.on('ready', function (event) {
|
||||
if (playonload) {
|
||||
$(wavecontainer).removeClass('playing');
|
||||
$(wavecontainer).addClass('playing');
|
||||
$(wavecontainer).find('.player-button.playpause').html('Pause');
|
||||
wavesurfer.play();
|
||||
}
|
||||
});
|
||||
|
||||
$(wavecontainer).find('.track').removeClass('playing');
|
||||
|
||||
track.addClass('playing');
|
||||
|
||||
$(wavecontainer).find('label').first().html('Playing: ' + track.html());
|
||||
};
|
||||
|
||||
Drupal.AudiofieldWavesurfer.Next = function (wavecontainer, wavesurfer) {
|
||||
if (wavesurfer.isPlaying()) {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
}
|
||||
|
||||
var track = $(wavecontainer).find('.track.playing').next();
|
||||
if (typeof track.attr('data-src') === 'undefined') {
|
||||
track = $(wavecontainer).find('.track').first();
|
||||
}
|
||||
|
||||
Drupal.AudiofieldWavesurfer.Load(wavecontainer, wavesurfer, track);
|
||||
};
|
||||
|
||||
Drupal.AudiofieldWavesurfer.Previous = function (wavecontainer, wavesurfer) {
|
||||
if (wavesurfer.isPlaying()) {
|
||||
Drupal.AudiofieldWavesurfer.PlayPause(wavecontainer, wavesurfer);
|
||||
}
|
||||
|
||||
var track = $(wavecontainer).find('.track.playing').prev();
|
||||
if (typeof track.attr('data-src') === 'undefined') {
|
||||
track = $(wavecontainer).find('.track').last();
|
||||
}
|
||||
|
||||
Drupal.AudiofieldWavesurfer.Load(wavecontainer, wavesurfer, track);
|
||||
};
|
||||
|
||||
Drupal.behaviors.audiofieldwavesurfer = {
|
||||
attach: function attach(context, settings) {
|
||||
$.each(settings.audiofieldwavesurfer, function (key, settingEntry) {
|
||||
if (settingEntry.playertype === 'default') {
|
||||
$.each(settingEntry.files, function (key2, file) {
|
||||
Drupal.AudiofieldWavesurfer.generate(context, file, settingEntry);
|
||||
});
|
||||
} else if (settingEntry.playertype === 'playlist') {
|
||||
Drupal.AudiofieldWavesurfer.generatePlaylist(context, settingEntry);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @file
|
||||
* Audiofield build WordPress audio player.
|
||||
*/
|
||||
|
||||
(($, Drupal, once) => {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldWordpress = {};
|
||||
|
||||
/**
|
||||
* Generate a wordpress player.
|
||||
*
|
||||
* @param {jQuery} context
|
||||
* The Drupal context for which we are finding and generating this player.
|
||||
* @param {array} file
|
||||
* The audio file for which we are generating a player.
|
||||
* @param {jQuery} settings
|
||||
* The Drupal settings for this player.
|
||||
*/
|
||||
Drupal.AudiofieldWordpress.generate = (context, file, settings) => {
|
||||
let autostartSetting = 'no';
|
||||
if (!!settings.autoplay) {
|
||||
autostartSetting = 'yes';
|
||||
}
|
||||
const elements = once('generate-waveform', '#wordpressaudioplayer_' + file.unique_id, context);
|
||||
$.each(elements, (index, item) => {
|
||||
AudioPlayer.embed($(item).attr('id'), {
|
||||
soundFile: file.file,
|
||||
titles: file.title,
|
||||
autostart: autostartSetting,
|
||||
loop: 'no',
|
||||
initialvolume: settings.volume,
|
||||
checkpolicy: 'yes',
|
||||
animation: settings.animate,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the behaviors to generate the audio player.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches generation of Wordpress audio players.
|
||||
*/
|
||||
Drupal.behaviors.audiofieldwordpress = {
|
||||
attach: function buildWordpressPlayers(context, settings) {
|
||||
$.each(settings.audiofieldwordpress, (key, settingEntry) => {
|
||||
// Initialize the audioplayer.
|
||||
AudioPlayer.setup('/libraries/wordpress-audio/player.swf', {
|
||||
width: 400,
|
||||
initialvolume: settingEntry.volume,
|
||||
transparentpagebg: 'yes',
|
||||
});
|
||||
// Loop over the files.
|
||||
$.each(settingEntry.files, (key2, fileEntry) => {
|
||||
// Generate the player for each file.
|
||||
Drupal.AudiofieldWordpress.generate(context, fileEntry, settingEntry);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal, once) {
|
||||
'use strict';
|
||||
|
||||
Drupal.AudiofieldWordpress = {};
|
||||
|
||||
Drupal.AudiofieldWordpress.generate = function (context, file, settings) {
|
||||
var autostartSetting = 'no';
|
||||
if (!!settings.autoplay) {
|
||||
autostartSetting = 'yes';
|
||||
}
|
||||
var elements = once('generate-waveform', '#wordpressaudioplayer_' + file.unique_id, context);
|
||||
$.each(elements, function (index, item) {
|
||||
AudioPlayer.embed($(item).attr('id'), {
|
||||
soundFile: file.file,
|
||||
titles: file.title,
|
||||
autostart: autostartSetting,
|
||||
loop: 'no',
|
||||
initialvolume: settings.volume,
|
||||
checkpolicy: 'yes',
|
||||
animation: settings.animate
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Drupal.behaviors.audiofieldwordpress = {
|
||||
attach: function buildWordpressPlayers(context, settings) {
|
||||
$.each(settings.audiofieldwordpress, function (key, settingEntry) {
|
||||
AudioPlayer.setup('/libraries/wordpress-audio/player.swf', {
|
||||
width: 400,
|
||||
initialvolume: settingEntry.volume,
|
||||
transparentpagebg: 'yes'
|
||||
});
|
||||
|
||||
$.each(settingEntry.files, function (key2, fileEntry) {
|
||||
Drupal.AudiofieldWordpress.generate(context, fileEntry, settingEntry);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal, once);
|
||||
Reference in New Issue
Block a user