Please wait...
Cezame Music Agency
77, rue Charlot, 75003 Paris, France
Tél. : + 33 1 42 22 00 68
© 2024 Frederic Leibovitz Editeur
Legal Notice
0){
if( (actif.attr('id')=="Pl_play") && actif.attr('data-wait-until')=="true"){
$("#Pl_play").trigger('click');
}
if(actif.attr('id')=="Pl_pause"){
$("#Pl_pause").trigger('click');
$("#Pl_pause").removeClass('active');
$('#Pl_play').attr('data-wait-until','true');
}
return false;
}
}
hasRegionStartingWith = function(prefix= "") {
const regionsList = myPlaylist.regions.list;
if(prefix!= ""){
for (const key in regionsList) {
if (regionsList.hasOwnProperty(key) && key.startsWith(prefix)) {
return key; // Retourne la clé trouvée
}
}
}else{
if (regionsList && typeof regionsList === 'object') {
return Object.keys(regionsList);
}
}
return null;
}
getUrlAlbumFromID = function(Vid_album){
}
function millisToMinutesAndSeconds(millis) {
var minutes = Math.floor(millis / 60000);
var seconds = Math.floor( ((millis % 60000) / 1000));
return (seconds == 60 ? (minutes+1) + ":00" : minutes + ":" + (seconds < 10 ? "0" : "") + seconds);
}
wPlayerSendEvent = function(type,val){
var idm=myPlaylist.playlist[val].id_media;
if(Pl_debug) {
console.log("fct:wPlayerSendEvent "+type +" rang:"+ val+" id"+idm);
}
if(type=="SEEK"){
return void(0);
}
//23/05/24 a voir si on garde, regression possible
$('#Pl_stop').removeClass('active');
if(type=="ITEM" || type=="REGION"){
//remove les actifs
$(".boxcontroleplayer button.Tl_listening").hide();
$(".boxcontroleplayer button.Tl_play").show();
$(".boxcommand button").removeClass("active");
$(".boxcontroletracks button").removeClass("active");
$(".boxcontroleplayer button:not(.Tl_favorite)").removeClass('active');
//player
$('#Pl_play').hide();
$('#Pl_pause').show().addClass("active");
$('#Pl_playcover').hide();
$('#Pl_pausecover').show();
//tl
$("#boxcontrol_"+idm).find('.Tl_play').hide();
$("#boxcontrol_"+idm).find('.Tl_listening').show().addClass('active');
//Lts
$(".boxcontroletracks").find('.Lts_play').hide();
$(".boxcontroletracks").find('.Lts_listening').show().addClass('active');
$('.TexteDescriptionTrackOver').removeClass('TexteDescriptionTrackOver').addClass('TexteDescriptionTrackVisited');
$(".TexteDescriptionTrack[id_media='"+ idm +"']").addClass('TexteDescriptionTrackOver');
$(".TexteDescriptionTrack[id_media='0"+ idm +"']").addClass('TexteDescriptionTrackOver');
if(from_last_click=="videoedit" || from_last_click=="videosharing"){
let typeframe;
if(from_last_click == "videoedit"){
typeframe = frames['espaceprive'].document;
}else{
typeframe = document;
}
$(".controllistprivate button.Ve_listening", typeframe).hide();
$(".controllistprivate button.Ve_play", typeframe).show();
$(".controllistprivate button", typeframe).removeClass('active');
$(".controllistprivate button", typeframe).removeClass('active');
$(".controllistprivate button.Ve_play", typeframe).hide();
$(".controllistprivate button.Ve_listening", typeframe).show().addClass('active');
}
//private
if(from_last_click=="private"){
/**YOHANN :: si la ligne n'existe pas, sauter d''un cran**/
if ($("tr[id_media='"+ idm +"']", frames['espaceprive'].document).length ==0 ){
if(parseInt(val) < parseInt(curIndex)){
//en arriere
if(Number(val) == 0){
//debut de chaine on fait rien
}else{
wPlayerSendEvent("ITEM",(Number(val)-1));
}
}else{
//en avant
if(val ==(myPlaylist.playlist.length - 1)){
//fin de chaine on fait rien
}else{
wPlayerSendEvent("ITEM",(Number(val)+1));
}
}
return;
}
$(".controllistprivate button.Tl_listening").hide();
$(".controllistprivate button.Tl_play").show();
$(".controllistprivate button").removeClass('active');
$(".controllistprivate button", frames['espaceprive'].document).removeClass('active');
$("tr[id_media='"+ idm +"'] .Tl_play", frames['espaceprive'].document).hide();
$("tr[id_media='"+ idm +"'] .Tl_listening", frames['espaceprive'].document).show().addClass('active');
}
if( from_last_click!="private" &&
($(".divTrackAlt[id_media='" + idm + "']").is(':hidden')
||
$(".divTrackAlt[id_media='0" + idm + "']").is(':hidden'))
) {
//est ce qu'on va en avant ou en arriere
if(parseInt(val) < parseInt(curIndex)){
//en arriere
if(Number(val) == 0){
clickPrevScrolledTrack();
}else{
wPlayerSendEvent("ITEM",(Number(val)-1));
}
}else{
if(val ==(myPlaylist.playlist.length - 1)){
clickNextScrolledTrack();
}else{
wPlayerSendEvent("ITEM",(Number(val)+1));
}
}
return;
}
/**Revenir Ici***/
if(type != "REGION"){
setCurrentSong(val);
}
myPlaylist.on('ready', function() {
if(from_last_click == "videoedit"){
//region.update
/*region.update({
dragSelection: {
slop: 5
}
});*/
$( "#video-montage-loop",frames['espaceprive'].document ).on( "change", function(e) {
region.update({
loop: $(this).is(':checked')
});
});
}
if(type !== "REGION"){ //pour type = item // permet de creer une pause dans une region
//yohanndev region
const regionKey = hasRegionStartingWith('video_');
if (regionKey) {
const region = myPlaylist.regions.list[regionKey];
const start = region.start;
const end = region.end;
$("#espaceprive").contents().find('#video-montage-start').val(start);
$("#espaceprive").contents().find('#video-montage-end').val(end);
myPlaylist.play(start, end);
} else {
myPlaylist.play();
}
}
});
return;
}
if(type=="PLAY"){
//remove les actifs
$(".boxcontroleplayer button.Tl_listening").hide();
$(".boxcontroleplayer button.Tl_play").show();
$(".boxcommand button").removeClass("active");
$(".boxcontroletracks button").removeClass("active");
$(".boxcontroleplayer button:not(.Tl_favorite)").removeClass('active');
//player
$('#Pl_play').hide();
$('#Pl_pause').show().addClass("active");
$('#Pl_playcover').hide();
$('#Pl_pausecover').show();
//tl
$("#boxcontrol_"+idm).find('.Tl_play').hide();
$("#boxcontrol_"+idm).find('.Tl_listening').show().addClass('active');
//lts cartouche
$(".boxcontroletracks").find('.Lts_play').hide();
$(".boxcontroletracks").find('.Lts_listening').show().addClass('active');
$('.TexteDescriptionTrackOver').removeClass('TexteDescriptionTrackOver').addClass('TexteDescriptionTrackVisited');
$(".TexteDescriptionTrack[id_media='"+ idm +"']").addClass('TexteDescriptionTrackOver');
$(".TexteDescriptionTrack[id_media='0"+ idm +"']").addClass('TexteDescriptionTrackOver');
//Thumbs carousel
if($('.item_wrap').length > 0){
$('.item_wrap ul.active').find('.Th_pausecover').show();
$('.item_wrap ul.active').find('.Th_playcover').hide();
}
//private
if(from_last_click=="private"){
$(".controllistprivate button.Tl_listening").hide();
$(".controllistprivate button.Tl_play").show();
$(".controllistprivate button").removeClass('active');
$(".controllistprivate button", frames['espaceprive'].document).removeClass('active');
$("tr[id_media='"+ idm +"'] .Tl_play", frames['espaceprive'].document).hide();
$("tr[id_media='"+ idm +"'] .Tl_listening", frames['espaceprive'].document).show().addClass('active');
}
if(from_last_click=="videoedit" || from_last_click=="videosharing"){
let typeframe;
if(from_last_click == "videoedit"){
typeframe = frames['espaceprive'].document;
}else{
typeframe = document;
}
$(".controllistprivate button.Ve_listening", typeframe).hide();
$(".controllistprivate button.Ve_play", typeframe).show();
$(".controllistprivate button", typeframe).removeClass('active');
$(".controllistprivate button", typeframe).removeClass('active');
$(".controllistprivate button.Ve_play", typeframe).hide();
$(".controllistprivate button.Ve_listening", typeframe).show().addClass('active');
}
//init
//$('#current_id_media').val(val);
}
if(type=="LOAD"){
$(".boxcontroleplayer button:not(.Tl_favorite)").removeClass('active');
//player
$('#Pl_play').show().addClass("active");
$('#Pl_pause').hide();
$('#Pl_playcover').show();
$('#Pl_pausecover').hide();
//tl
$("#boxcontrol_"+idm).find('.Tl_play').show().addClass('active');
$("#boxcontrol_"+idm).find('.Tl_listening').hide();
//lts cartouche
$(".boxcontroletracks").find('.Lts_play').show().addClass('active');
$(".boxcontroletracks").find('.Lts_listening').hide();
if(from_last_click=="videoedit" || from_last_click=="videosharing"){
let typeframe;
if(from_last_click == "videoedit"){
typeframe = frames['espaceprive'].document;
}else{
typeframe = document;
}
$(".controllistprivate button", typeframe).removeClass('active');
$(".controllistprivate button.Ve_listening", typeframe).hide();
$(".controllistprivate button.Ve_play", typeframe).show();
}
setCurrentSong(val);
return;
}
if(type=="PAUSE"){
//remove les actifs
//on supprime pas ici les actifs car il permette de recuperer la currentpos
$(".boxcontroleplayer button:not(.Tl_favorite)").removeClass('active');
//player
$('#Pl_play').show().addClass("active");
$('#Pl_pause').hide();
$('#Pl_playcover').show();
$('#Pl_pausecover').hide();
//tl
$("#boxcontrol_"+idm).find('.Tl_play').show().addClass('active');
$("#boxcontrol_"+idm).find('.Tl_listening').hide();
//lts cartouche
$(".boxcontroletracks").find('.Lts_play').show().addClass('active');
$(".boxcontroletracks").find('.Lts_listening').hide();
//Thumbs carousel
if($('.item_wrap').length > 0){
$('.item_wrap').find('.Th_playcover').show();
$('.item_wrap').find('.Th_pausecover').hide().removeClass('active');
}
if(from_last_click=="private"){
$(".controllistprivate button").removeClass('active');
$("tr[id_media='"+ idm +"'] .Tl_listening", frames['espaceprive'].document).hide();
$("tr[id_media='"+ idm +"'] .Tl_play", frames['espaceprive'].document).show().addClass('active');
}
if(from_last_click=="videoedit" || from_last_click=="videosharing"){
let typeframe;
if(from_last_click == "videoedit"){
typeframe = frames['espaceprive'].document;
}else{
typeframe = document;
}
$(".controllistprivate button", typeframe).removeClass('active');
$(".controllistprivate .Ve_listening", typeframe).hide().removeClass('active');
$(".controllistprivate .Ve_play", typeframe).show().addClass('active');
}
}
if(type=="STOP"){
//remove les actifs
$(".boxcommand button").removeClass("active");
$(".boxcontroletracks button").removeClass("active");
$(".boxcontroleplayer button:not(.Tl_favorite)").removeClass('active');
$(".controllistprivate button").removeClass('active');
//player
$('#Pl_stop').addClass("active");
$('#Pl_play').show();
$('#Pl_pause').hide();
$('#Pl_playcover').show();
$('#Pl_pausecover').hide();
//tl
$(".boxcontroleplayer button.Tl_listening").hide();
$(".boxcontroleplayer button.Tl_play").show();
//lts cartouche
$(".boxcontroletracks button.Lts_listening").hide();
$(".boxcontroletracks button.Lts_play").show();
$(".boxcontroletracks button.Lts_play").show();
//Thumbs carousel
if($('.item_wrap').length > 0){
$('.item_wrap ul').removeClass('active');
$('.item_wrap').find('.Th_playcover').show();
$('.item_wrap').find('.Th_pausecover').hide().removeClass('active');
}
//$('#current_id_media').val(val);
if(from_last_click=="private"){
$("tr", frames['espaceprive'].document).removeClass('titrepriveplay');
$("tr[id_media='"+ idm +"'] .Tl_listening", frames['espaceprive'].document).hide().removeClass('active');
$("tr[id_media='"+ idm +"'] .Tl_play", frames['espaceprive'].document).show().removeClass('active');
}
if(from_last_click=="videoedit" || from_last_click=="videosharing"){
let typeframe;
if(from_last_click == "videoedit"){
typeframe = frames['espaceprive'].document;
}else{
typeframe = document;
}
$(".controllistprivate button.Ve_listening", typeframe).hide();
$(".controllistprivate button.Ve_play", typeframe).show();
}
pos= val;
}
if(type=="NEXT"){
//recupere l'ancien id joué et replace les boutons
//tl
$("#boxcontrol_"+idm).find('.Tl_play').show();
$("#boxcontrol_"+idm).find('.Tl_listening').hide();
$('.TexteDescriptionTrackOver').removeClass('TexteDescriptionTrackOver').addClass('TexteDescriptionTrackVisited');
$(".TexteDescriptionTrack[id_media='"+ idm +"']").addClass('TexteDescriptionTrackOver');
$(".TexteDescriptionTrack[id_media='0"+ idm +"']").addClass('TexteDescriptionTrackOver');
}
if(type=="PREVIOUS"){
//recupere l'ancien id joué et replace les boutons
//tl
$("#boxcontrol_"+idm).find('.Tl_play').show();
$("#boxcontrol_"+idm).find('.Tl_listening').hide();
$('.TexteDescriptionTrackOver').removeClass('TexteDescriptionTrackOver').addClass('TexteDescriptionTrackVisited');
$(".TexteDescriptionTrack[id_media='"+ idm +"']").addClass('TexteDescriptionTrackOver');
$(".TexteDescriptionTrack[id_media='0"+ idm +"']").addClass('TexteDescriptionTrackOver');
}
}
wPlayerLaunch = function(start,loadItemOnly){
if(typeof loadItemOnly !== 'undefined' && loadItemOnly!= ""){
wPlayerSendEvent('LOAD',start);
}else{
wPlayerSendEvent('ITEM',start);
///!\espaceprivé :: click sur la video
}
if(Pl_debug) {
console.log("fct:wPlayerLaunch "+start);
}
}
wPlayerGetCurrentItemNumber2 = function(){
//recupere la piste courante qui est joué selon les attributs html
//var curItem = 0;
//si le bouton hautparleur est bleu donc actif, la lecture est en cours
var curItemPosPlaying = $('.Tl_listening.active:visible').closest("ul");
//si le bouton play est bleu, donc actif, la lecture est en pause
var curItemPosPause = $('.Tl_play.active:visible').closest("ul");
//espace prive box // espace prive window
if($('#espaceprive').length || $('#espaceprive', parent).length || window.location.pathname == "/privatewidget.php") {
var curItemPosEP = $("tr.titreprive",frames['espaceprive'].document).hasClass('titrepriveplay');
}
var curItemPosCF = $("ul.compo_musique_originale").hasClass('compo_listSelected');
if(curItemPosPlaying.length>0 && from_last_click=="public"){
curItem=curItemPosPlaying.attr('curposition');
}else if(curItemPosPause.length>0 && from_last_click=="public"){
curItem=curItemPosPause.attr('curposition');
}else{
//il existe deja un current index, si oui on le prend
if(typeof curIndex != "undefined"){
var curItem = 0;
}else{
curItem=0;
}
if(typeof pos != "undefined" && pos!=""){
curItem = pos;
}
}
if(curItemPosEP==true && from_last_click=="private"){
curItem=$("tr.titrepriveplay",frames['espaceprive'].document).attr('curposition');
}
if(curItemPosCF==true && from_last_click=="composers"){
curItem=$("ul.compo_listSelected").attr('curposition');
}
if(Pl_debug) {
console.log("fct:wPlayerGetCurrentItemNumber2 - curentitem:"+curItem);
}
return curItem;
}
function playRegion(resume,from){
const regionKey = hasRegionStartingWith('video_');
if(resume){
wPlayerSendEvent('REGION',0);
if(regionKey){
myPlaylist.play();
}else{
window.parent.xajax_load_player_playlist($('#id_media',frames['espaceprive'].document).val(),'','0',from,'',$('#id_video',frames['espaceprive'].document).val());
}
}else{
wPlayerSendEvent('REGION',0);
if(regionKey){
myPlaylist.regions.list[regionKey].play();
}else{
window.parent.xajax_load_player_playlist($('#id_media',frames['espaceprive'].document).val(),'','0',from,'',$('#id_video',frames['espaceprive'].document).val());
}
}
}
function fctclearRegions(){
const regionKey = hasRegionStartingWith();
//ne jamais clear les (climax[0-9])
//if(regionKey.some(item => item.startsWith('climax'))){
if(regionKey){
regionKey.forEach(key => {
if (!key.startsWith('climax')) {
// Si la clé ne commence pas par "climax", appeler remove() sur l'élément correspondant dans regionsList
if (myPlaylist.regions.list.hasOwnProperty(key)) {
myPlaylist.regions.list[key].remove();
}
}
});
}else{
//on efface tout
myPlaylist.clearRegions();
}
}
function createRegion(regionStart, regionEnd, readOnly,loop,maxLength,id) {
const maxDuration = 60; // Durée maximale en secondes provenant de la video ( plus tard!!)
const duration = parseInt(myPlaylist.getDuration());
if(regionStart == 0 && regionEnd == 0){
const regionEnd = Math.min(regionStart + maxDuration, duration);
}
if(readOnly !== null && readOnly !== '' && readOnly == true){
defaultEdit = {
drag: false,
resize: false
};
}else{
defaultEdit = {
drag: true,
resize: true
};
}
if(loop !== null && loop !== '' && loop == true){
defaultLoop = {
loop: true
};
}else{
defaultLoop = {
loop: false
};
}
if (typeof maxLength !== 'undefined' && maxLength !== null) {
defaultOptions = {
id:id,
start: regionStart,
end: regionEnd,
color: 'rgba(0, 123, 255, 0.3)'
//maxLength: maxLength,//bug wavesurfer on drag
};
} else {
defaultOptions = {
id:id,
start: regionStart,
end: regionEnd,
color: 'rgba(0, 123, 255, 0.3)',
};
}
region = myPlaylist.addRegion({
...defaultOptions,
...defaultEdit,
...defaultLoop
});
}
// Create a WaveSurfer instance
wPlayerLaunchPlayer = function(position,autostartplayer){
if($("#Pl_waveform").length == 0){
if(Pl_debug) {
console.log("not exist Pl_waveform : wPlayerLaunchPlayer");
}
return false;
}
// Create a canvas gradient
const ctx1 = document.createElement('canvas').getContext('2d')
const gradient = ctx1.createLinearGradient(0, 0, 0, 150)
gradient.addColorStop(0, 'rgb(35, 149, 255)')
gradient.addColorStop(0.7, 'rgb(28, 111, 195)')
gradient.addColorStop(1, 'rgb(0, 0, 0)')
const ctx2 = document.createElement('canvas').getContext('2d')
const gradientdefault = ctx2.createLinearGradient(0, 0, 0, 150)
gradientdefault.addColorStop(0, 'rgb(193, 193, 193)')
gradientdefault.addColorStop(0.7, 'rgb(124, 124, 124)')
gradientdefault.addColorStop(1, 'rgb(0, 0, 0)')
/*init*/
myPlaylist = WaveSurfer.create({
container: '#Pl_waveform',
backend: 'MediaElement',
mediaType:'audio',
cursorColor:'#1daee0',
reflection:false,
closeAudioContext:true,
plugins: [
WaveSurfer.regions.create({
dragSelection: {slop: 5}
}),
WaveSurfer.cursor.create({
showTime: true,
hideOnBlur: true,
opacity: 1,
customShowTimeStyle: {
'background-color': '#1daee0',
'color': '#fff',
'padding': '2px',
'font-size': '10px',
'borderRightColor':'#1daee0'
}
})
],
//waveColor: '#c1c1c1',
waveColor: gradientdefault,
//progressColor: '#2395ff',
progressColor:gradient,
height: dimPeak,
barWidth: 3,
responsive:true,
normalize: true
});
if(playList.length == 0){
return false;
}
/**assignation de la playlist**/
myPlaylist.playlist = playList;
myPlaylist.setVolume(volume);
/*stop spinner*/
spinnerStop();
/*timer*/
myPlaylist.on('ready', function() {
var totalTime = myPlaylist.getDuration();
$('#time-total').html(millisToMinutesAndSeconds(Math.round(totalTime * 1000)));
spinnerStop();
/*sliderzoom.oninput = function () {
var zoomLevel = Number(sliderzoom.value);
myPlaylist.zoom(zoomLevel);
};*/
/*myPlaylist.once('decode', () => {
document.querySelector('input#zoom-range[type="range"]').oninput = (e) => {
const minPxPerSec = Number(e.target.value)
myPlaylist.zoom(minPxPerSec)
}
})*/
myPlaylist.on('region-updated', function(e){
const url = window.location.href;
var iframe = $('#espaceprive');
var regionid=e.id;
var regionsList = myPlaylist.regions.list;
if(defaultEdit.drag == false && defaultEdit.resize== false){
//partage
if (url.includes("lire_titres")) {
const keys = Object.keys(regionsList);
if (keys.length > 1 && typeof keys[1] !== 'undefined') {
secondRegion = keys[1];
regionsList[secondRegion].remove() ;
}
}else{
fctclearRegions();
}
}else{
//cad d'edition sur une fenetre ouverte espace video : detail video
if($('#voletConteneurEspacePrive').hasClass('openprivate') ){
if(iframe.contents().find('#lien_prive_liste_videos').hasClass('active')){
if(iframe.contents().find('#form_video_montage').length){
let dureeRegion = (e.end - e.start);
let dureeVideo = $("#espaceprive").contents().find('#videoDuration').val();
if(Number(dureeRegion) > Number(dureeVideo)){
e.end = (parseFloat(e.start) + Number(dureeVideo));
}
for (const key in regionsList) {
if (regionsList.hasOwnProperty(key) && key!=regionid) {
regionsList[key].remove()
}
}
}
}
}else{
fctclearRegions();
}
}
if($('#voletConteneurEspacePrive').hasClass('openprivate') ){
if(iframe.contents().find('#lien_prive_liste_videos').hasClass('active')){
if(iframe.contents().find('#form_video_montage').length){
$("#espaceprive").contents().find('#video-montage-start').val(e.start);
$("#espaceprive").contents().find('#video-montage-end').val(e.end);
$("#espaceprive").contents().find('video#video-montage').get(0).pause();
if($('#video-montage').length > 0 ){
document.getElementById('video-montage').pause();
}
$("#Pl_stop").trigger('click');
}
}
}
});
});
idm = myPlaylist.playlist[position].id_media;
myPlaylist.on('audioprocess', function() {
var totalTime = myPlaylist.getDuration();
$('#time-total').html(millisToMinutesAndSeconds(Math.round(totalTime * 1000)));
if(myPlaylist.isPlaying()) {
var currentTime = myPlaylist.getCurrentTime();
var remainingTime = totalTime - currentTime;
currentMod = parseInt(parseInt(currentTime*1000) % 10000 );
if(currentMod < lastcurrentMod){
$.ajax({
url: '/ajax/ajax_stats.php',
type:'POST',
data:'id_media='+idm+"&stats="+millisToMinutesAndSeconds(Math.round(myPlaylist.getCurrentTime() * 1000)),
});
}else{
}
lastcurrentMod = currentMod;
$('#time-current').html(millisToMinutesAndSeconds(Math.round(currentTime * 1000)));
$('#time-remaining').html(millisToMinutesAndSeconds(Math.round(remainingTime * 1000)));
}
});
myPlaylist.on('destroy', function () {
if(Pl_debug) {
console.log('!!!!!!!!!!!!!! Wavesurfer destroy !!!!!!!!!!!!!!');
}
});
if(position>0){
wPlayerSendEvent("ITEM",position)
}
if(autostartplayer){
wPlayerSendEvent("PLAY");
}
$('#volume').on('input', function () {
$(this).trigger('change');
myPlaylist.setVolume($(this).val());
});
$('#zoom').on('input', function () {
$(this).trigger('change');
myPlaylist.zoom(Number(this.value));
});
$("#Pl_thumblink,#toggleplaycover").on('click', function(e) {
//myPlaylist.playPause();
e.preventDefault();
});
$("#Pl_mute").on('click', function(e) {
$(this).toggleClass("active");
myPlaylist.toggleMute();
e.preventDefault();
});
$("#Pl_download").on('click', function(e) {
Tip('',BGCOLOR,'#FFFFFF',FONTCOLOR,'#000000',BORDERWIDTH,1,BORDERCOLOR,'#CCCCCC',CLOSEBTN, false,STICKY,true,OPACITY,90,PADDING,7,ABOVE,true,CENTERMOUSE,true, DURATION, -1000,WIDTH,350);
xajax_tip_download($('#current_id_media').val());
e.preventDefault();
});
$("#Pl_add").on('click', function(e){
Tip('',BGCOLOR,'#FFFFFF',FONTCOLOR,'#000000',BORDERWIDTH,1,BORDERCOLOR,'#CCCCCC',CLOSEBTN, true,CLOSEBTNCOLORS, ['#FFFFFF', '#000000', '#B6BBC1', '#9A9FA5'], CLOSEBTNTEXT, 'Close X',STICKY,true,OPACITY,90,PADDING,7,ABOVE,true,CENTERMOUSE,true, DURATION, -1000,OFFSETY,80,WIDTH,'calc(300px + 20%)');
xajax_tip_basket($('#current_id_media').val());
e.preventDefault();
});
$("#Pl_similarto").on('click', function(e) {
var t = $('#egale_id_media_' + $('#current_id_media').val() );
var ididid = $('#current_id_media').val();
var u = $('#Pl_waveform audio').attr('src').replace(/\?.*$/,'');
launch_recommendation(u,ididid);
e.preventDefault();
});
$("#Pl_pref").on('click', function(e) {
xajax_tip_favorites($('#current_id_media').val(),'player');
e.preventDefault();
});
$("#Pl_share").on('click', function(e) {
var urlSocialShare = getShareURL('','','',$('#current_id_media').val());
socialSharePopup(urlSocialShare);
});
$("#Pl_copyright").on('click', function(e) {
if(Pl_debug) {
console.log("copyright"+'#infoBoxListePlayerPage_'+$('#current_id_media').val());
}
//$('#infoBoxListePlayerPage_'+$('#current_id_media').val()).show();
$this = $(this);
$.fancybox({
autoSize: true,
href: '#infoBoxListePlayerPage_'+$('#current_id_media').val(),
fitToView : true,
minWidth : '70%',
openEffect :'fade',
openSpeed :300,
title: this.title,
helpers : {
title: { type: 'outside'},
}
});
return false;
e.preventDefault();
});
$("#Pl_stop").on('click', function(e) {
if( $('#voletConteneurEspacePrive').is(':visible') && $('#voletConteneurEspacePrive').hasClass('openprivate') ){
if(from_last_click!="" && from_last_click == "videoedit"){
from_last_click = 'videoedit';
}else{
from_last_click = 'private';
}
}else if(window.location.pathname == "/privatewidget.php" ){
from_last_click = 'private';
}else{
if(from_last_click == ""){
from_last_click = 'public';
}else{
from_last_click = from_last_click;
}
}
var pos=wPlayerGetCurrentItemNumber2();
wPlayerSendEvent('STOP',pos);
myPlaylist.stop();
e.preventDefault();
});
$("#Pl_pause,#Pl_pausecover").on('click', function(e,current) {
flag = false;
if( $('#voletConteneurEspacePrive').is(':visible') && $('#voletConteneurEspacePrive').hasClass('openprivate') ){
if(from_last_click!="" && from_last_click== "videoedit"){
from_last_click = 'videoedit';
}else{
from_last_click = 'private';
}
}else if(window.location.pathname == "/privatewidget.php" ){
from_last_click = 'private';
}else{
if(from_last_click == ""){
from_last_click = 'public';
}else{
from_last_click = from_last_click;
}
}
//si current est passé en parametre, ca provient d'un trigger, d'une liste de lecture (tentative abordée, mais fontionnelle)
if (current !== undefined) {
var pos = current;
flag = true;
}else{
//si on presse pause, il y forcement un bouton lecture actif, sinon on fait rien
var pos=wPlayerGetCurrentItemNumber2();
flag = true;
}
if(flag){
wPlayerSendEvent('PAUSE',pos);
myPlaylist.pause();
}
e.preventDefault();
});
$("#Pl_play,#Pl_playcover").on('click', function(e) {
if( $('#voletConteneurEspacePrive').is(':visible') && $('#voletConteneurEspacePrive').hasClass('openprivate') ){
if(from_last_click!= "" && from_last_click=="videoedit"){
from_last_click = 'videoedit';
}else{
from_last_click = 'private';
}
}else if(window.location.pathname == "/privatewidget.php" ){
from_last_click = 'private';
}else{
if(from_last_click == ""){
from_last_click = 'public';
}else{
from_last_click = from_last_click;
}
}
var pos=wPlayerGetCurrentItemNumber2();
wPlayerSendEvent('PLAY',pos);
myPlaylist.play();
e.preventDefault();
});
$("#Pl_next").on('click', function(e) {
var pos=curIndex;
wPlayerSendEvent('NEXT',pos);
if(pos ==(myPlaylist.playlist.length - 1)){
clickNextScrolledTrack();
return;
}else{
wPlayerSendEvent("ITEM",(Number(pos)+1));
}
e.preventDefault();
});
$("#Pl_previous").on('click', function(e) {
var pos=curIndex;
wPlayerSendEvent('PREVIOUS',pos);
if(Number(pos) == 0){
clickPrevScrolledTrack();
return;
}else{
wPlayerSendEvent("ITEM",(Number(pos)-1));
}
e.preventDefault();
});
$("#Pl_minimyseme").on('click', function(e) {
if( $('.Pl_wrap').hasClass('minimizeme')){
setCookie("minimizeme",'false',1000);
}else{
setCookie("minimizeme",'true',1000);
}
$('.Pl_wrap').toggleClass( 'minimizeme',800 );
myPlaylist.drawer.containerWidth = myPlaylist.drawer.container.clientWidth;
myPlaylist.drawBuffer();
check_status_drawer('fromminimize');
e.preventDefault();
});
myPlaylist.on('play', function() {
//pendant que le morceau joue
});
myPlaylist.on('finish', function() {
wPlayerSendEvent('NEXT',curIndex);
if(curIndex == (myPlaylist.playlist.length - 1)){
clickNextScrolledTrack();
if(Pl_debug) {
console.log("fct:clickNextScrolledTrack fin de liste pagination");
}
return;
}else{
wPlayerSendEvent("ITEM",(Number(curIndex)+1));
}
});
myPlaylist.on('region-click', function(region, e) {
//myPlaylist.play(region.start);
//region.playLoop()
//e.stopPropagation();
// Play on click, loop on shift click
//e.shiftKey ? region.playLoop() : region.play();
});
}
window.setCurrentSong = function(index) {
if( typeof myPlaylist == 'undefined'){
return false;
}
var playlist = myPlaylist.playlist;
previousTrack = curIndex;
curIndex = index;
info_media = playlist[index];
if(Pl_debug) {
console.log(info_media);
}
$("#Pl_url").attr("href",info_media.linkalbum);
$("#Pl_thumbs").attr("src",info_media.img);
$("#Pl_thumbs").attr("alt",info_media.titre);
$("#Pl_title").html(info_media.titre);
$("#Pl_album").html(info_media.titre_album);
$("#Pl_ref").html(info_media.ref);
$("#Pl_position").html(info_media.position);
if(Pl_debug) {
console.log("fct:setCurrentSong index"+curIndex );
}
$.ajax({
url: '/jsonfy.php',
type:'POST',
data:'id_media='+info_media.id_media+"&ref="+info_media.ref,
success: function(result_waveform){
data_peaks = (result_waveform);
},
async: false
});
if(from_last_click=='public'){
//YOHANNDEV a l'ouverture de la page uniquement ( chargement du 1 titre) et sur le play d'un titre ?!
$('.TexteDescriptionTrackOver').removeClass('TexteDescriptionTrackOver').addClass('TexteDescriptionTrackVisited');
$(".TexteDescriptionTrack[id_media='"+ tabTitlesPage[curIndex] +"']").addClass('TexteDescriptionTrackOver');
$(".TexteDescriptionTrack[id_media='0"+ tabTitlesPage[curIndex] +"']").addClass('TexteDescriptionTrackOver');
}
if(from_last_click=='private'){
/**espace privé**/
//init
$("tr.titreprive", frames['espaceprive'].document).removeClass('titrepriveplay');
$("tr.titreprive .Tl_play", frames['espaceprive'].document).show();
$("tr.titreprive .Tl_listening", frames['espaceprive'].document).hide().removeClass('active');
//Act
$("tr[id_media='"+ tabTitlesPage[curIndex] +"']", frames['espaceprive'].document).addClass('titrepriveplay');
$("tr[id_media='"+ tabTitlesPage[curIndex] +"'] .Tl_play", frames['espaceprive'].document).hide();
$("tr[id_media='"+ tabTitlesPage[curIndex] +"'] .Tl_listening", frames['espaceprive'].document).addClass('active').show();
}
/* if(from_last_click=='videoedit'){
//init
//$(".controllistprivate .Ve_play", frames['espaceprive'].document).show();
//$(".controllistprivate .Ve_listening", frames['espaceprive'].document).hide().removeClass('active');
//Act
//$(".controllistprivate .Ve_play", frames['espaceprive'].document).hide();
//$(".controllistprivate .Ve_listening", frames['espaceprive'].document).addClass('active').show();
}
*/
if(from_last_click=='composers'){
$(".compo_musique_originale").removeClass('compo_listSelected');
$(".compo_musique_originale img.button_compo_musique_originale").attr('src','/themes/cezame/assets_cezame/images/compo_mini_lectureBLACK.png');
$("#compo_musique_originale_" + tabTitlesPage[curIndex]).addClass('compo_listSelected');
$("#compo_musique_originale_" + tabTitlesPage[curIndex] +" img.button_compo_musique_originale").attr('src','/themes/cezame/assets_cezame/images/compo_mini_lectureBLUE.png');
}
myPlaylist.song = info_media.mp3;
myPlaylist.backend.peaks = data_peaks.data;
myPlaylist.drawBuffer();
/**climax**/
myPlaylist.clearRegions();
myPlaylist.load(myPlaylist.song, myPlaylist.backend.peaks);
if(info_media.climaxJson !== undefined && info_media.climaxJson !== 'false' && info_media.climaxJson !== '0' ){
var someDataFinal = [];
var arrClimax = decodeURIComponent(info_media.climaxJson);
var arrJsonClimax = JSON.parse(arrClimax);
arrJsonClimax.forEach(function(objectcl,i) {
var values = objectcl.timing.split(/'/);
var kkeys = ["mtiming", "stiming"];
var ffinal = {};
for(var j = 0 ; j < values.length; j++){
ffinal[kkeys[j]] = parseInt(values[j].trim());
}
var timing=((ffinal.mtiming*60) + ffinal.stiming);
var str = {id:'climax'+i,start: timing, end: timing+1, color:'rgb(255, 255, 255, 0)', attributes: {label: '◆',title:objectcl.desc},title:objectcl.desc,drag:false, resize:false};
someDataFinal.push(str);
});
setTimeout(function(){
for(var k = 0 ; k < someDataFinal.length; k++){
myPlaylist.addRegion(someDataFinal[k]);
}
}, 200);
}
itemMonitor();
if(Pl_debug) console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
};
/**clavier**/
var in_search = false;
/**définition des touches**/
KEY_DOWN = 40;
KEY_UP = 38;
KEY_LEFT = 37;
KEY_RIGHT = 39;
KEY_END = 35;
KEY_BEGIN = 36;
KEY_BACK_TAB = 8;
KEY_TAB = 9;
KEY_SH_TAB = 16;
KEY_ENTER = 13;
KEY_ESC = 27;
KEY_SPACE = 32;
KEY_DEL = 46;
KEY_A = 65;
KEY_B = 66;
KEY_C = 67;
KEY_D = 68;
KEY_E = 69;
KEY_F = 70;
KEY_G = 71;
KEY_H = 72;
KEY_I = 73;
KEY_J = 74;
KEY_K = 75;
KEY_L = 76;
KEY_M = 77;
KEY_N = 78;
KEY_O = 79;
KEY_P = 80;
KEY_Q = 81;
KEY_R = 82;
KEY_S = 83;
KEY_T = 84;
KEY_U = 85;
KEY_V = 86;
KEY_W = 87;
KEY_X = 88;
KEY_Y = 89;
KEY_Z = 90;
KEY_PF1 = 112;
KEY_PF2 = 113;
KEY_PF3 = 114;
KEY_PF4 = 115;
KEY_PF5 = 116;
KEY_PF6 = 117;
KEY_PF7 = 118;
KEY_PF8 = 119;
REMAP_KEY_T = 5019;
function checkEventObj ( _event_ ){
// --- IE explorer
if ( window.event )
return window.event;
// --- Netscape and other explorers
else
return _event_;
}
/**fonctions pour catcher les flèches gauches et droite, à appliquer sur la liste de **/
function applyKey (_event_){
if(in_search==true)
{
return;
}
// --- Retrieve event object from current web explorer
var winObj = checkEventObj(_event_);
var intKeyCode = winObj.keyCode;
var intAltKey = winObj.altKey;
var intCtrlKey = winObj.ctrlKey;
// 1° --- Access with [ALT/CTRL+Key]
if (intAltKey || intCtrlKey) {
if ( intKeyCode == KEY_RIGHT || intKeyCode == KEY_LEFT ){
// --- Display Message
if(intKeyCode == KEY_RIGHT){
getNextTitle();
}
if(intKeyCode == KEY_LEFT){
getPrevTitle();
}
sendEvent('ITEM',curIndex);
// 3° --- Map the keyCode in another keyCode not used
winObj.keyCode = intKeyCode = REMAP_KEY_T;
winObj.returnValue = false;
return false;
}
}
// 2 ° --- Access without [ALT/CTRL+Key]
else {
if ( intKeyCode == KEY_RIGHT || intKeyCode == KEY_LEFT ){
// --- Display Message
if(intKeyCode == KEY_RIGHT){
getNextTitle();
}
if(intKeyCode == KEY_LEFT){
getPrevTitle();
}
jPlayerSendEvent('ITEM',curIndex);
// 3° --- Map the keyCode in another keyCode not used
winObj.keyCode = intKeyCode = REMAP_KEY_T;
winObj.returnValue = false;
return false;
}
}
}
function clickFormeTiming(e,that, offset){
return;
var x = e.clientX - offset - 8.5;
var duration = parseInt(myPlaylist.getDuration());
var duration_finale;
duration_finale=duration;
w=(parseInt(duration_finale) / visual_width) * x;
w=parseInt(w);
wPlayerSendEvent('SEEK', w );
if(!myPlaylist.isPlaying() && myPlaylist.getCurrentTime()>0){
wPlayerSendEvent('PLAY',false);
}
}
function clickForme(e,that){
return;
var offset = that.offset();
var x = e.clientX - offset.left + 5;
var duration = parseInt(myPlaylist.getDuration());
var duration_finale;
duration_finale=duration;
w=(parseInt(duration_finale) / visual_width) * x;
w=parseInt(w);
wPlayerSendEvent('SEEK', w );
if(!myPlaylist.isPlaying() && myPlaylist.getCurrentTime()>0){
wPlayerSendEvent('PLAY',false);
}
}
-->
fonction searchExternalRecommendation() mise dans l'element directement
// $('#btn_search_external_recommendation_youtube').on('click', function() {
// searchExternalRecommendation(document.getElementById('search_external_recommendation_youtube').value);
// });
function searchExternalRecommendation(url) {
var p = /^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/i;
var p2 =/^(?:https?:\/\/open\.spotify\.com|spotify)/i;
var p3 =/^(?:https?:\/\/.*soundcloud.com\/)/i;
var p4 =/^(?:https?:\/\/.*disco.ac\/)/i;
var tab_url = url.split('?');
url = tab_url[0];
var v_param = "";
if ( tab_url[1] ) {
var params_get = tab_url[1].split('&');
for (let i = 0; i < params_get.length; i++) {
var tmp_param = params_get[i].split('=');
if ( tmp_param[0] == 'v' ) {
v_param = tmp_param[1];
}
}
}
url = url + (v_param != "" ? "?v=" + v_param : "");
let logged_in = false;
jQuery.ajax({url: "/ajax/check_conn.php",
type: "GET",
async: false,
success: function(JSONreponseFromAjax){
logged_in = JSONreponseFromAjax;
}}
);
if (1==1 || logged_in == "OK" ) {
if((url.match(p) || url.match(p2) || url.match(p3) || url.match(p4)) && !launch_yt_progress){
if(url.match(p)){
var providerURL = "Youtube URL";
}else if(url.match(p2)){
var providerURL = "Spotify URL";
}else if(url.match(p3)){
var providerURL = "SoundCloud URL";
}else if(url.match(p4)){
var providerURL = "Disco URL";
}else{
var providerURL = "Youtube URL";
}
var message = providerURL + " : " + "The scan may take several minutes. Would you like to continue?";
var topito = jQuery('#header-search-query').offset();
$('#searchbtn').prop('disabled', true);
jcConfirm(
message,
function(){
if(url.match(p)){
/**clean the url before sending it to alain**/
url=url.replace(/\?si=.*$/,'');
}
launch_yt_progress=true;
///////////$('progress').show();
$('progress').hide();
spinnerStartCancellable();
//////////randomBar( );
jq_xhr.reset();
jq_xhr.addCancelCallback(resetSearchExternalRecommendation);
jq_xhr.instance = $.ajax({url: "https://cdn.cezamemusic.com/recog/upload.php",
type: "GET",
data: {url: url,lang:'en'},
success: function(JSONreponseFromAjax){
resetSearchExternalRecommendation();
$('#searchbtn').prop('disabled', false);
if(JSONreponseFromAjax=="ERR"){
getAlert("An error has occured","header-search-query");
clearTimeout(mytimeoutrb);
progress = document.getElementById('uploadprogress');
progress.value = progress.innerHTML = 0;
///////////$('progress').show();
$('progress').hide();
// $('.external_recommendationbox')[0].style.display = 'none';
}else if(JSONreponseFromAjax=="ERR_NOT_CONNECTED"){
//jQuery('#infoBoxListePage_connect').show();
TipNotConnected();
$('progress').hide();
// $('.external_recommendationbox')[0].style.display = 'none';
}else if(JSONreponseFromAjax.match(/^ERR_/)){
$('progress').hide();
// $('.external_recommendationbox')[0].style.display = 'none';
}else{
clearTimeout(mytimeoutrb);
progress = document.getElementById('uploadprogress');
progress.value = progress.innerHTML = 0;
///////////$('progress').show();
$('progress').hide();
/** SG 20/10/2021 : ajout pour cacher la box après requête et vider le champs **/
// $('#search_external_recommendation_youtube').val('');
// $('.external_recommendationbox').hide();
reponses = JSON.parse(JSONreponseFromAjax);
reponsesMots = reponses.mots;
JSONreponse = JSONreponseFromAjax;
suggestiontitres(url,'yt');
}
},
error: function(res, textStatus, errorThrown){
resetSearchExternalRecommendation();
if (textStatus !== 'abort') {
var text_alert = "An error occured, please try again later ";
//if (errorThrown.search(/time[- ]?out/i) !== -1)
// text_alert += ".Error : Processing time limit exceeded ";
getAlert(text_alert);
}
}
});
},
function(){
jQuery('#header-search-query').val('');
},
"continue",
"Cancel",
{}
);
}
} else {
TipNotConnectedPubAi(true);
}
}
function searchExternalRecommendationFromBrief(brief) {
let logged_in = false;
spinnerStart();
jQuery.ajax({url: "/ajax/check_conn.php",
type: "GET",
async: true,
success: function(JSONreponseFromAjax){
logged_in = JSONreponseFromAjax;
}}
);
/**pour les tests on rend la fonction accessible (demo) */
if ( 1==1 || logged_in == "OK" ) {
jQuery.ajax({
url: "/ajax/get_keywords_from_brief.php",
type: "POST",
data: { brief : brief },
dataType: "html",
async: true,
success: function(JSONreponseFromAjax){
var parsedRes = JSON.parse(JSONreponseFromAjax);
var div_error = document.getElementById('external_brief_errors');
if ( parsedRes.error !== undefined ) {
var txt_error = "Error : ";
if ( parsedRes.error == "brief_empty" ) {
txt_error += "Your brief is empty";
} else if ( parsedRes.error == "brief_too_long" ) {
txt_error += "Your brief is too long, it must be 1000 characters long maximum";
}
div_error.innerHTML = txt_error;
div_error.style.display = 'block';
spinnerStop();
} else {
div_error.innerHTML = '';
div_error.style.display = 'none';
var responseJSON = parsedRes;
var response = responseJSON;
var url = "/liste_resultats.php?";
resetSearchExternalRecommendation();
var params = [];
var tab_mots = [];
//var nbi = 1;
//for( var key in response ) {
for( var valou of response ) {
//if(nbi < 5){
//params.push("mot[]=" + encodeURI(response[key] + "@@@@" + response[key] + "@@@@" + response[key]));
params.push("mot[]=" + encodeURI(valou + "@@@@" + valou + "@@@@" + valou));
//tab_mots.push(response[key]);
tab_mots.push(valou);
//}
//nbi++;
}
if ( params.length == 0 ) {
div_error.innerHTML = 'No results found, please try again later.';
div_error.style.display = 'block';
spinnerStop();
return;
}
url += params.join("&");
xajax_check_multiple_words(tab_mots.join(' '), [], false, true, false, brief);
//window.location.href = url;
}
}
}
);
} else {
TipNotConnectedPubAi(true);
spinnerStop();
}
}
function resetSearchExternalRecommendation() {
spinnerStopCancellable();
launch_yt_progress = false;
$('#search_external_recommendation_youtube').val('');
$('.external_recommendationbox').hide();
}
/** SG 20/10/2021 : RAJOUT POUR LE FILE AREA DE L'EXTERNAL RECOMMENDATION **/
$("#file_external_recommendation").on("change", function(e) {
let logged_in = false;
jQuery.ajax({url: "/ajax/check_conn.php",
type: "GET",
async: false,
success: function(JSONreponseFromAjax){
logged_in = JSONreponseFromAjax;
}}
);
if (1==1 || logged_in == "OK" ) {
spinnerStart();
var lbl_external = document.getElementById('file_external_recommendation_lbl');
var old_txt = lbl_external.innerHTML;
lbl_external.innerHTML = e.target.files[0].name;
if ( !e.target.files[0].name ) {
return;
}
var fileExtension = e.target.files[0].name.split('.').pop();
if ( accepted_files.includes(fileExtension.toLowerCase())){
if ( accepted_files_music.includes(fileExtension.toLowerCase())){
readfiles(e.target.files);
}else{
readfiles_image(e.target.files);
}
} else {
spinnerStop();
$('#progress_external_recommendation_file').hide();
getAlertDanger("Only MP3, WAV, AIFF, JPG and PNG files are accepted");
lbl_external.innerHTML = old_txt;
e.target.files = null;
}
} else {
TipNotConnectedPubAi(true);
}
});
//---
//- FUNCTIONS!!
//---
//---
//- autocomplete EXPLICATION : lance l'autocomplete sur la recherche quand un titre est directement renseigne, suggestion
//---
var svg_header_search_query = ""; /////////jQuery('#header-search-query').val();
/**************EV 19/01/2021 : retiré de la recherche
if($("#header-search-query").length > 0) $("#header-search-query").autocomplete({
source: "/ajax/searchv4.php",
position: {
my: "left+0 top+2"
},
create: function(){
$(this).data('ui-autocomplete')._renderItem = function (ul, item) {
svg_header_search_query = jQuery('#header-search-query').val();
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "$1 ");
return $(" ")
.addClass("ac-li_"+item.type)
.data("item.autocomplete", item)
.append("" + item.label + " ")
.appendTo(ul);
};
},
focus: function( event, ui ) {
if(ui.item.txt!='') {
$("#header-search-query").val(ui.item.txt);
//svg_header_search_query = jQuery('#header-search-query').val();
}else{
$("#header-search-query").val(svg_header_search_query);
}
return false;
},
select: function( event, ui ) {
if(ui.item.url!='' && ui.item.url!='#'){
document.location.href=ui.item.url;
}
return false;
},
response: function( event, ui ) {
if(ui.content!=null){
//launchSearch();
}
}
}).autocomplete( "widget" ).addClass( "autocomplete_search_page" );
******/
//---
//- recog clickOnTag
//---
clickOnTag = function(el){
//////empty_search_form();
spinnerStart();
var inz = el.find('input');
if(el.hasClass('recogbuttondisabled')) {
/**ne rien faire, sortir de cette fonction, car le mot n'est pas sélectionnable**/
return null;
}else if(el.hasClass('recogbuttonselected')){
inz.prop('disabled', true);
el.removeClass('recogbuttonselected').addClass('recogbuttondefault');
}else if(el.hasClass('recogbuttondefault')){
inz.prop('disabled', false);
el.removeClass('recogbuttondefault').addClass('recogbuttonselected');
}
jQuery('.recogbutton').each(function(){jQuery(this).removeClass('recogbuttondisabled').addClass('recogbuttondefault');});
//xajax_get_recog_results_keywords(xajax.getFormValues('alain_search_form'),$('#recogtags').html(),JSONreponse);
xajax_get_recog_results_keywords(xajax.getFormValues('alain_search_form'),'',JSONreponse);
}
//---
//- recog launch_recog_search
//---
launch_recog_search = function(){
var zurl="";
var taburl = [ ];
taburl.push("last_item_played=" + global_last_item_played);
taburl.push("type_suggestion=" + global_type_suggestion);
jQuery('.recogbutton').each(function(){
/**verifier si disabled ou pas**/
if(jQuery(this).hasClass('recogbuttonselected')){
var zinput=jQuery(this).find('input');
taburl.push( zinput.attr('name') + "=" + zinput.val() );
}
});
similartracks=JSON.parse(JSONreponse);
similartracks=similartracks.similartracks;
if(similartracks.length > 0){
tabids=new Array();
for(var i=0;i"
+ " " + lib + ""
tagz.push(tag);
}
}
strz+="";
$('#cartouche-similar_content').html(strz);
//$('#search_form').append(strz);
/*$('#recogtags').css('margin-top', (0 - ($('#recogtags').css('height')/2)) + 'px');*/
/**mémoriser le grid**/
//xajax_get_recog_results_keywords(xajax.getFormValues('search_form'),$('#recogtags').html(),JSONreponse);
//xajax_get_recog_results_tracks(xajax.getFormValues('search_form'),$('#recogtags').html());
}
//---
//- recog suggestionmots
//---
suggestionmots = function(){
jQuery('#recogtags').show();
//jQuery('.recogbutton').each(function(){
//jQuery(this).removeClass("recogbuttonselected").addClass("recogbuttondefault");
//jQuery(this).find('input').removeAttr('disabled');
//});
//xajax_get_recog_results_keywords(xajax.getFormValues('search_form'),$('#recogtags').html(),JSONreponse);
}
var global_last_item_played;
var global_type_suggestion;
//---
//- recog suggestiontitres
//---
suggestiontitres = function(last_item_played,type_suggestion){
/**
last_item_played : le titre de réference sur une recommendation (signe égal)
type_suggestion : (equal,yt,mp3)
**/
global_last_item_played=last_item_played;
global_type_suggestion=type_suggestion;
//xajax_get_recog_results_tracks(xajax.getFormValues('alain_search_form'),$('#recogtags').html(),JSONreponse, last_item_played, type_suggestion);
xajax_get_recog_results_tracks(xajax.getFormValues('alain_search_form'),'',JSONreponse, last_item_played, type_suggestion);
}
//---
//- recog previewfile
//---
previewfile = function (file) {
if (tests.filereader === true && acceptedTypes[file.type] === true) {
var reader = new FileReader();
reader.onload = function (event) {
};
reader.readAsDataURL(file);
} else {
holder.innerHTML += 'Loading ' + file.name + ' ' + (file.size ? (file.size/1024|0) + 'K' : '');
fichier=file.name;
}
}
//---
//- recog readfiles
//---
readfiles = function(files) {
var formData = tests.formdata ? new FormData() : null;
for (var i = 0; i < files.length; i++) {
if (tests.formdata) formData.append('file', files[i]);
// previewfile(files[i]); en commentaire pcq nom du fichier pas important et pas beau
}
formData.set('lang','en');
// now post a new XHR request
if (tests.formdata) {
var xhr = new XMLHttpRequest();
xhr.open('POST', '/recog/upload.php');
xhr.onload = function() {
progress.value = progress.innerHTML = 100;
};
xhr.onloadend = function() {
JSONreponse= xhr.responseText.trim();
if(JSONreponse=="ERR"){
spinnerStopCancellable();
$('#progress_external_recommendation_file').hide();
document.getElementById('file_external_recommendation').files = null;
document.getElementById('file_external_recommendation_lbl').innerHTML = 'Choose file from your computer';
getAlertDanger("An error has occured, please try again with another file");
}else if(JSONreponse=="ERR_NOT_CONNECTED"){
//jQuery('#infoBoxListePage_connect').show();
TipNotConnected();
}else{
$('#fichiercharge').remove();
$('#chargementde').remove();
$('progress').hide();
spinnerStop();
reponses = JSON.parse(JSONreponse);
reponsesMots = reponses.mots;
suggestiontitres(files[0].name, 'mp3');
/** SG 21/10/2021 : POUR CACHER LA BOX QD RESULTAT AFFICHÉ **/
if($('.external_recommendationbox').length){
/** SG 22/10/2021 : POUR PROGRESS BAR EXTERNAL_RECOMMENDATION **/
$('#progress_external_recommendation_file').width('100%');
$('.external_recommendationbox').hide();
$('#progress_external_recommendation_file').width('0%');
$('#progress_external_recommendation_file').hide();
$('#file_external_recommendation').val('');
document.getElementById('file_external_recommendation_lbl').innerHTML = 'Drop your file here.';
}
}
};
if (tests.progress) {
$('progress').show();
$('#progress_external_recommendation_file').show();
spinnerStart();
xhr.upload.onprogress = function (event) {
if (event.lengthComputable) {
var complete = (event.loaded / event.total * 100 | 0);
if(complete!=100){
$('#recogdiv').each(function(){$(this).remove();});
}
/** SG 22/10/2021 : PR PROGRESS BAR EXTERNAL_RECOMMENDATION **/
if($('#progress_external_recommendation_file').length){
$('#progress_external_recommendation_file').width((event.loaded/event.total*100)+'%');
}
progress.value = progress.innerHTML = complete;
}
}
}
xhr.send(formData);
}
}
//---
//- recog readfiles
//---
readfiles_image = function(files) {
var formData = tests.formdata ? new FormData() : null;
for (var i = 0; i < files.length; i++) {
if (tests.formdata) formData.append('file', files[i]);
// previewfile(files[i]); en commentaire pcq nom du fichier pas important et pas beau
}
formData.set('lang','en');
// now post a new XHR request
if (tests.formdata) {
var xhr = new XMLHttpRequest();
xhr.open('POST', '/ajax/get_keywords_from_brief.php');
xhr.onload = function() {
progress.value = progress.innerHTML = 100;
};
xhr.onloadend = function() {
JSONreponse= xhr.responseText.trim();
if(JSONreponse=="ERR"){
spinnerStopCancellable();
$('#progress_external_recommendation_file').hide();
document.getElementById('file_external_recommendation').files = null;
document.getElementById('file_external_recommendation_lbl').innerHTML = 'Choose file from your computer';
getAlertDanger("XXXXXAn error has occured, please try again with another file");
}else if(JSONreponse=="ERR_NOT_CONNECTED"){
//jQuery('#infoBoxListePage_connect').show();
TipNotConnected();
}else{
$('#fichiercharge').remove();
$('#chargementde').remove();
$('progress').hide();
spinnerStop();
var parsedRes = JSON.parse(JSONreponse);
var div_error = document.getElementById('external_brief_errors');
if ( parsedRes.error !== undefined ) {
var txt_error = "Error : ";
if ( parsedRes.error == "brief_empty" ) {
txt_error += "Your brief is empty";
} else if ( parsedRes.error == "brief_too_long" ) {
txt_error += "Your brief is too long, it must be 1000 characters long maximum";
}
div_error.innerHTML = txt_error;
div_error.style.display = 'block';
spinnerStop();
} else {
div_error.innerHTML = '';
div_error.style.display = 'none';
var responseJSON = parsedRes;
var response = responseJSON;
var url = "/liste_resultats.php?";
var params = [];
var tab_mots = [];
for( var valou of response ) {
params.push("mot[]=" + encodeURI(valou + "@@@@" + valou + "@@@@" + valou));
tab_mots.push(valou);
}
if ( params.length == 0 ) {
div_error.innerHTML = 'No results found, please try again later.';
div_error.style.display = 'block';
spinnerStop();
return;
}
url += params.join("&");
xajax_check_multiple_words(tab_mots.join(' '), [], false, true, false, '');
//window.location.href = url;
}
}
};
if (tests.progress) {
$('progress').show();
$('#progress_external_recommendation_file').show();
spinnerStart();
xhr.upload.onprogress = function (event) {
if (event.lengthComputable) {
var complete = (event.loaded / event.total * 100 | 0);
if(complete!=100){
$('#recogdiv').each(function(){$(this).remove();});
}
/** SG 22/10/2021 : PR PROGRESS BAR EXTERNAL_RECOMMENDATION **/
if($('#progress_external_recommendation_file').length){
$('#progress_external_recommendation_file').width((event.loaded/event.total*100)+'%');
}
progress.value = progress.innerHTML = complete;
}
}
}
xhr.send(formData);
}
}
//---
//- afficherPanneauEntree
//---
afficherPanneauEntree = function(){
var zeObj = $('#header-search-query');
if(zeObj.val()!=""){
$('#boiteAdviceRico').show(500);
}
}
//---
//- jelancenoresult
//---
jelancenoresult = function(){
in_search=false;
$('#msgdbg').text($("#header-search-query").attr('value'));
spinnerStart();
//xajax_check_multiple_words($("#header-search-query").attr('value'), xajax.getFormValues('search_form'));
};
var mytimeoutrb;
var randomPercent = 0
randomBar = function( ){
randomPercent = randomPercent + 5
if(randomPercent > 100)
{
randomPercent = 0
}
progress = document.getElementById('uploadprogress');
progress.value = progress.innerHTML = randomPercent;
mytimeoutrb = setTimeout( function(){randomBar( );} , 300);
}
todoOnKeyDown = function(zeObj,e){
$carousel_gallery_home.flickity('pausePlayer');
/**
le moteur suggest est désactivé
quand on tape une touche, cela empeche le masque "Entrée" de s'afficher,
et lance le timeout de 3 secondes pour l'ouvrir
**/
spinnerStop();
clearTimeout(timeoutAfficherPanneauEntree);
in_search=true;
timeoutAfficherPanneauEntree = setTimeout(function(){afficherPanneauEntree();},3000);
//var kc=e.keyCode;
var kc = e.key || e.code;
if(kc=="Enter" || kc==13 || kc==37 || kc==38 || kc==39 || kc==40 || zeObj.value=='' || zeObj.value.indexOf('?+')!=-1){
spinnerStop();
}
if($('#btn_external_recommendation').length > 0){
/** SG 21/20/2021 : POUR CACHER BOUTON external_recommendation QD QQUE CHOSE DE TAPER **/
if((zeObj.value).length>0){
/////16/04/2024 Eric / on ne le retire plus. : document.getElementById('btn_external_recommendation').style.display = 'none';
}else{
document.getElementById('btn_external_recommendation').style.display = 'flex';
}
}
if(( kc==13 || kc=='Enter') && zeObj.value!='' ){
var r = $(".text-tags .text-label").map( function(){return $(this).text();}).get().join(' ');
if(r!=''){
var phrase=r + ' ' + zeObj.value;
}else{
var phrase=zeObj.value;
}
$.ajax({
type: "POST",
url: "/ajax/check_is_prompt.php",
data: { phrase: phrase, langue: 'en' }
}).done(function(reponse) {
if (reponse === "OK") {
/**vider le formulaire de recherche**/
empty_search_form();
/**appeler la fonction de recommandation par brief**/
searchExternalRecommendationFromBrief(phrase);
} else {
//bouton entrée tappé
fct_menuzonehidden();
spinnerStart();
clearTimeout('jelancelenoresultdansxsecondes');
xajax_check_multiple_words(phrase, xajax.getFormValues('search_form'));
}
});
}else if(( kc==13 || kc=='Enter') && zeObj.value==''){
fct_menuzonehidden();
}
}
todoOnBlur = function(zeObj,e){
var v = zeObj.value;
$carousel_gallery_home.flickity('pausePlayer');
spinnerStop();
clearTimeout(timeoutAfficherPanneauEntree);
in_search=true;
timeoutAfficherPanneauEntree = setTimeout(function(){afficherPanneauEntree();},3000);
spinnerStop();
/** SG 24/10/2023 : POUR CACHER BOUTON external_recommendation QD QQUE CHOSE DE TAPER **/
if($('#btn_external_recommendation').length > 0){
if((zeObj.value).length>0){
/////16/04/2024 Eric / on ne le retire plus. : document.getElementById('btn_external_recommendation').style.display = 'none';
}else{
document.getElementById('btn_external_recommendation').style.display = 'flex';
}
}
if(v!=''){
fct_menuzonehidden();
spinnerStart();
clearTimeout('jelancelenoresultdansxsecondes');
zeObj.value = '';
var r = $(".text-tags .text-label").map( function(){return $(this).text();}).get().join(' ');
var phrase = '';
if ( r!='' ) {
phrase = r + ' ' + v;
} else {
phrase = v;
}
$.ajax({
type: "POST",
url: "/ajax/check_is_prompt.php",
data: { phrase: phrase, langue: 'en' }
}).done(function(reponse) {
if (reponse === "OK") {
/**vider le formulaire de recherche**/
empty_search_form();
/**appeler la fonction de recommandation par brief**/
searchExternalRecommendationFromBrief(phrase);
} else {
//bouton entrée tappé
fct_menuzonehidden();
spinnerStart();
clearTimeout('jelancelenoresultdansxsecondes');
xajax_check_multiple_words(phrase, xajax.getFormValues('search_form'));
////////show_bpm_key_zone("search");
}
});
} else {
//fct_menuzonehidden(); //remettre cette ligne si problème sur le onblur
//SG 03/11/2023 : afin que la cartouche ne se ferme plus au onblur de l'input et que le bouton ai search se cache quand des mots sont présents dans l'input
var r = $(".text-tags .text-label").map( function(){return $(this).text();}).get().join(' ');
if ( r!="" ) {
/////16/04/2024 Eric / on ne le retire plus. : $("#btn_external_recommendation").hide();
} else {
if (document.getElementsByClassName('recogbutton').length == 0) {
fct_menuzonehidden();
}
}
}
}
//Tooltip sur liste track search v4 pour les recommandations
tooltip_menu_media = function(button,id_media,content){
$('.tooltip_menu_recommandation').removeClass('persistent').fadeOut();
//CONTENT:: id="tooltiprecommandation_66414"
const $tooltip = $("#"+content+"_" + id_media);
$tooltip.stop(true, true).fadeIn(); // Stop toute animation en cours et montre le tooltip
$tooltip.addClass('persistent');
//on charge pour ce contenu le code pour la region
if(content === "tooltiprecommandation"){
if (!myPlaylist || typeof myPlaylist.playlist !== 'object') {
//console.error("myPlaylist.playlist n'est pas un objet valide.");
return;
}
// Convertir en tableau
//--si c'est la grosse playlist avec les alternates
if (String(id_media).startsWith("0")) {
//console.log("alt");
id_media_alt = String(id_media).slice(1); // Supprime le premier caractère
pos = $('#boxcontrol_'+id_media_alt).attr('curposition');
//--sinon c'est la petite playlist celle au chargement de la page
}else{
const playlistValues = Object.values(myPlaylist.playlist);
// Rechercher l'index
const index = myPlaylist.playlist.findIndex(
item => String(item.id_media) === id_media
);
if (index !== -1) {
const currentItem = playlistValues[index];
pos = index;
//console.log("Index trouvé :", index, "Données :", currentItem);
}
}
//console.log("Index trouvé :", pos, "Données :", myPlaylist.playlist[pos]);
from_last_click ="recommandationedit";
window.setCurrentSongLOAD(pos);
//createRegion(regionStart, regionEnd, readOnly,loop,maxLength,id)
//id=time-total recup le timing
setTimeout(() => {
let dureetrack = $("#time-total").html();
let [minutesDT, secondsDT] = dureetrack.split(':').map(Number);
let newseconds = (minutesDT * 60) + secondsDT;
console.log(newseconds);
window.createRegion('0', newseconds, 'false', 'false', '', 'recommandation_' + id_media);
}, 150);
$tooltip.on("click", ".Ttr_validate", function (e) {
let timingdebut = $tooltip.find('.Ttr_timingdebut').val();
let timingfin = $tooltip.find('.Ttr_timingfin').val();
console.log(timingdebut+" "+timingfin+" Suivant");
closeTooltip_media(id_media);
});
}
// Gestion des délais pour le masquage
let hideTimeout;
// Quand la souris quitte le bouton
$(button).on("mouseout", function () {
hideTimeout = setTimeout(() => {
if (!$tooltip.is(":hover") && !$tooltip.hasClass("persistent")) {
$tooltip.fadeOut();
}
}, 200);
});
// Quand la souris entre dans le tooltip
$tooltip.on("mouseover", function () {
clearTimeout(hideTimeout); // Annuler le délai de masquage si la souris entre dans le tooltip
});
// Quand la souris quitte le tooltip
$tooltip.on("mouseout", function () {
hideTimeout = setTimeout(() => {
if (!$tooltip.is(":hover") && !$tooltip.hasClass("persistent")) {
$tooltip.fadeOut();
}
}, 200);
});
//$tooltip.fadeOut();
}
function closeTooltip_media(id_media='') {
let $tooltip;
if(id_media!=''){
$tooltip = $("#tooltiprecommandation_"+id_media);
}else{
$tooltip = $(this).closest(".tooltip_menu_recommandation");
}
$tooltip.removeClass("persistent").fadeOut();
if(from_last_click === "recommandationedit"){
from_last_click = 'public';
fctclearRegions();
const $tooltip = $(this).closest(".tooltip_menu_recommandation");
$tooltip.find('.Ttr_timingdebut').val('');
$tooltip.find('.Ttr_timingfin').val('');
}
}
launch_recommendation = function(localurl,last_item_played){
let logged_in = false;
jQuery.ajax({url: "/ajax/check_conn.php",
type: "GET",
async: false,
success: function(JSONreponseFromAjax){
logged_in = JSONreponseFromAjax;
}}
);
var cookiepubai = document.cookie.match('(^|;) ?no_pub_ai=([^;]*)(;|$)');
var test_pubai = false;
if ( cookiepubai !== null ) {
test_pubai = cookiepubai[2];
}
//SG 14/11/2023 : si pas connecté, on affiche la popup de pub pour les fonctionnalités complémentaires de l'IA
// if ( logged_in != "OK" && !test_pubai ) {
///pour l'instant on met ça de côté ... TipNotConnectedPubAi(false);
// }
$('progress').hide();
spinnerStart();
/**on supprime le div de recog, vu que l'on va en charger un nouveau**/
jQuery('#recogdiv').remove();
if ( !$('body').hasClass('mobile') ) {
randomBar( );
}
jQuery.ajax({url: "/recog/upload.php",
type: "POST",
data : {localurl: localurl, id_media: last_item_played,lang:'en'},
success: function(JSONreponseFromAjax){
if(JSONreponseFromAjax=="ERR"){
$('progress').hide();
spinnerStop();
}else if(JSONreponseFromAjax=="ERR_NOT_CONNECTED"){
TipNotConnected();
$('progress').hide();
spinnerStop();
}else if(JSONreponseFromAjax.match(/^ERR_/) ){
$('progress').hide();
spinnerStop();
clearTimeout(mytimeoutrb);
}else {
clearTimeout(mytimeoutrb);
if ( !$('body').hasClass('mobile') ) {
progress = document.getElementById('uploadprogress');
progress.value = progress.innerHTML = 0;
}
jQuery('progress').hide();
spinnerStop();
reponses = JSON.parse(JSONreponseFromAjax);
reponsesMots = reponses.mots;
JSONreponse = JSONreponseFromAjax;
suggestiontitres(last_item_played,'equal');
}
}
});
}
//---
//- changeScrollHeight
//---
changeScrollHeight = function() {
var h = parseInt(window.prompt('Please type new scroll height (number in pixels):', jQuery.Autocompleter.defaults.scrollHeight));
if(h > 0) {
$("#suggest1").setOptions({
scrollHeight: h
});
}
}
//---
//- focus_header_search_query
//---
focus_header_search_query = function(){
//$("#header-search-query").trigger("activate.autocomplete");
$("#header-search-query").click();
}
//---
//- RemoveAccents
//---
RemoveAccents = function(strAccents) {
var strAccents = strAccents.split('');
var strAccentsOut = new Array();
var strAccentsLen = strAccents.length;
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñÿý';
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz";
for (var y = 0; y < strAccentsLen; y++) {
if (accents.indexOf(strAccents[y]) != -1) {
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1);
} else
strAccentsOut[y] = strAccents[y];
}
strAccentsOut = strAccentsOut.join('');
//return strAccentsOut.replace(/ +/,"-");
strAccentsOut=strAccentsOut.replace(/'/g,"-").replace(/&+/g," ").replace(/ +/g,"-").replace(/\-+/,'-');
return strAccentsOut;
}
//---
//- addAlbumAndLaunch
//---
addAlbumAndLaunch = function(id_album,e,f){
e.after(" ");
f.submit();
}
//---
//- launchSearch
//---
launchSearch = function(){
jQuery('.loupe').click();
}
/**tout ce qui se rapoporte au filtrage par bpm et key**/
load_bpm_key_slider = function(){
jQuery('#slider').slider({
range: true,
min: 10,
max: 300,
step: 1,
values: [ 10, 300 ],
slide: function( event, ui ) {
jQuery('.slider-min').html(ui.values[ 0 ]);
jQuery('.slider-max').html(ui.values[ 1 ]);
},
change: function( event, ui ) {
var min = ui.values[ 0 ];
var max = ui.values[ 1 ];
jQuery('#customFilterBpm').val('');
jQuery.ajax({
url: '/ajax/ajax_search_filters.php?minbpm='+min+'&maxbpm='+max}
).done(function(){
var only_word_search = jQuery('#search_form').serialize().replace('search_external_recommendation_youtube=&search_external_recommendation_brief=', '');
const url_params = new URLSearchParams(window.location.search);
const id_media_str = url_params.get('id_media_str');
var tmp_url = "";
if ( id_media_str !== null ) {
tmp_url = '/liste_resultats.php?id_media_str='+id_media_str+'&randkeybpm='+Math.random().toString(36).substring(7);
}else if(only_word_search!=''){
tmp_url = '/liste_resultats.php?'+jQuery('#search_form').serialize()+'&randkeybpm='+Math.random().toString(36).substring(7);
}
goLaunchAjaxify(tmp_url,'#searchlink','search_' + Math.random().toString(36).substring(7));
});
}
});
}
-->