/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //https://www.w3schools.com/jsref/dom_obj_video.asp var CueBaseURL="https://1000epicop.rivagepro.com/classe/cVideoCues"; var InpEmptyBGCol='#FFB9B9' var gVideos=new Object(); var gCurrentCue=''; function CueHighLight(IdCue) { if(gCurrentCue!='') { $('#TRCUE'+gCurrentCue).css({backgroundColor:'transparent'}) } gCurrentCue=IdCue $('#TRCUE'+gCurrentCue).css({backgroundColor:'#cdfefe'}) } function VideoSceneDel(IdVideo,IdSeq) { if(!confirm(oLangTxt['LNG_ASQ_DEL_VIDEO'])) {return;} sURL=CueBaseURL + "/VideoCuesBasic.php"; $.ajax({ type: "POST", encoding: "UTF-8", url:CueBaseURL + "/VideoCuesBasic.php", //$AdminReponse,$IdExo,$Type,$IdPropositoin,$Value,$ExoNbEssai data: { CueAction: 'DEL_VIDEO_FROM_SEQ', times: new Date().getTime(), IdVideo:IdVideo, IdSeq:IdSeq, IdSession: IdSession}, success: function (responseText) { console.log(responseText); SceneElementHTMLDel("VIDEO"+oLangTxt['SEPARATEUR_CHAMP']+IdVideo); //SceneElementHTMLDel(IdElement); return; }, error: function (resultat, statut, erreur) { var output = ''; for (var property in resultat) { output += "\n##"+property + ': ' + resultat[property]+'; '; } alert("CueInfoSet error\n" + resultat + "("+output+")\nStatut : " + statut + "\nErreur :" + erreur); } }); } function CueDelete(IdVideo,Id,sCueDest,LngRef,LngTrad) { if(!confirm("Voulez-vous supprimer le texte")) { return; } sURL=CueBaseURL + "/VideoCuesBasic.php"; $.ajax({ type: "POST", encoding: "UTF-8", url:CueBaseURL + "/VideoCuesBasic.php", //$AdminReponse,$IdExo,$Type,$IdPropositoin,$Value,$ExoNbEssai data: { CueAction: 'CueDel', times: new Date().getTime(), IdVideo:IdVideo, lRef:LngRef, lTrad:LngTrad, Id:Id, IdSession: IdSession}, success: function (responseText) { var jRep=JSON.parse(responseText); if($('#'+sCueDest)[0]) { $('#'+sCueDest).html(jRep['html']); } CueTrackLoad(IdVideo,'fr'); return; }, error: function (resultat, statut, erreur) { var output = ''; for (var property in resultat) { output += "\n##"+property + ': ' + resultat[property]+'; '; } alert("CueInfoSet error\n" + resultat + "("+output+")\nStatut : " + statut + "\nErreur :" + erreur); } }); } function CueAction(Id,Action,IdVideo) { sURL=CueBaseURL + "/VideoCuesBasic.php?"; sURL+="CueAction=CueInfoGet"; sURL+="×="+new Date().getTime(); sURL+="&Id="+Id; sURL+="&Action="+Action ; sURL+="&IdSession="+IdSession; $.ajax({ type: "POST", encoding: "UTF-8", url:CueBaseURL + "/VideoCuesBasic.php", //$AdminReponse,$IdExo,$Type,$IdPropositoin,$Value,$ExoNbEssai data: {CueAction: 'CueInfoGet', times: new Date().getTime(),Id:Id, Action:Action , 'IdSession': IdSession}, success: function (responseText) { console.log(CueBaseURL + "/VideoCuesBasic.php?"+sURL); console.log(responseText); var InfRes=JSON.parse(responseText); gVideos[IdVideo].currentTime=InfRes[Id]['START_SEC']*1.0; gVideos[IdVideo].play(); /*var jRep=JSON.parse( responseText); console.log(jRep); if(IdDest!='') { if($("#"+IdDest)[0]!=null) { $("#"+IdDest).val(jRep.html); } }*/ return; }, error: function (resultat, statut, erreur) { var output = ''; for (var property in resultat) { output += "\n##"+property + ': ' + resultat[property]+'; '; } alert("CueInfoSet error\n" + resultat + "("+output+")\nStatut : " + statut + "\nErreur :" + erreur); } }); } function CueAddFromVideo(Id,VBlocElmnt,sCueDest,LngRef,LngTrad) { var curtime =$('#'+VBlocElmnt).find('video').get(0).currentTime; var DefDElta=1000; CueAdd(Id,curtime,curtime+DefDElta,sCueDest,LngRef,LngTrad); } function CueTrackLoad(IdVideo,Lang) { var sTrackSrc='TRACK_'+Lang+'_'+IdVideo; if($("#"+sTrackSrc)[0]) { //console.log($("#"+sTrackSrc).attr('src')); VttUrl=CueBaseURL + "/VideoCuesBasic.php?CueAction=VIDEO_GET_VTT&IdVideo="+IdVideo+"&Tm="+new Date().getTime(); //console.log(VttUrl); $("#"+sTrackSrc).attr('src',VttUrl); //console.log($("#"+sTrackSrc).attr('src')); } } function CueAdd(IdVideo,vDebut,vFin,sCueDest,LngRef,LngTrad,jEnd) { sURL=CueBaseURL + "/VideoCuesBasic.php"; //console.log(sURL); $.ajax({ type: "POST", encoding: "UTF-8", url:CueBaseURL + "/VideoCuesBasic.php", //$AdminReponse,$IdExo,$Type,$IdPropositoin,$Value,$ExoNbEssai data: { CueAction: 'CueAdd', times: new Date().getTime(), lRef:LngRef, lTrad:LngTrad, IdVideo:IdVideo, vDebut:vDebut, vFin:vFin, 'IdSession': IdSession}, success: function (responseText) { //console.log(responseText); var jRep=JSON.parse( responseText); if($('#'+sCueDest)[0]) { $('#'+sCueDest).html(jRep['html']); if(jRep['js']!=''){ eval(jRep['js']); } } CueTrackLoad(IdVideo,lRef) //console.log(responseText); return; }, error: function (resultat, statut, erreur) { var output = ''; for (var property in resultat) { output += "\n##"+property + ': ' + resultat[property]+'; '; } alert("CueInfoSet error\n" + resultat + "("+output+")\nStatut : " + statut + "\nErreur :" + erreur); } }); } function CueInfoFromVideoSet(IdVideo,Id,What,VBlocElmnt,IdDest) { var curtime =$('#'+VBlocElmnt).find('video').get(0).currentTime; CueInfoSet(IdVideo,Id,What,curtime,'',IdDest); CueTrackLoad(Id,'fr') } function CueInfoSet(IdVideo,Id,What,Val,lang,IdDest,hInp) { if(IdDest==undefined){IdDest='';} if(hInp==undefined){hInp=null;} sURL=CueBaseURL + "/VideoCuesBasic.php"; SURL=CueBaseURL + "/VideoCuesBasic.php?CueAction=CueInfoFromVideoSet&lang="+lang+"×="+ new Date().getTime()+"&Id="+Id+"&What="+What+"&Val="+encode_utf8(Val)+"&IdSession="+IdSession; //console.log(SURL); $.ajax({ type: "POST", encoding: "UTF-8", url:CueBaseURL + "/VideoCuesBasic.php", //$AdminReponse,$IdExo,$Type,$IdPropositoin,$Value,$ExoNbEssai data: {CueAction: 'CueInfoFromVideoSet',lang:lang, times: new Date().getTime(),Id:Id, What:What, Val:encode_utf8(Val) , IdSession: IdSession}, success: function (responseText) { var jRep=JSON.parse( responseText); if(IdDest!='') { if($("#"+IdDest)[0]!=null) { $("#"+IdDest).val(jRep.html); $("#"+IdDest).html(jRep.html); } } if(hInp!=null) { hInp.style.backgroundColor=(hInp.value=='')?InpEmptyBGCol:''; } CueTrackLoad(IdVideo,'fr'); return; }, error: function (resultat, statut, erreur) { var output = ''; for (var property in resultat) { output += "\n##"+property + ': ' + resultat[property]+'; '; } alert("CueInfoSet error\n" + resultat + "("+output+")\nStatut : " + statut + "\nErreur :" + erreur); } }); } function VideoPauseToggle(hBtPause,eVideoId) { //console.log($('#'+eVideoId)[0].paused); } function VideoLangueTradSet(IdVideo,lRef,lTrad,DivDest) { /*console.log(lRef); console.log(lTrad); console.log(DivDest);*/ sData="CueAction=VIDEO_CUTE_GET"; sData+="&lRef="+lRef; sData+="&lTrad="+lTrad; sData+="&IdVideo="+IdVideo; sData+="&IdSession="+IdSession ; $.ajax({ type: "POST", url: BASE_URL + "/classe/cVideoCues/VideoCuesBasic.php", data: sData, dataType: "json", success: function(responseText) { $('#'+DivDest).html(responseText['html']); }, error: function(resultat, statut, erreur) { alert(resultat + "\nStatut : " + statut + "\nErreur :" + erreur); } }); } var video=new Object(); function VideoTrackCuesChange(IdVideo,IdVideoBlock,NumLangDef) { var span1 = document.querySelector('div#ST'+IdVideoBlock); var span2 = document.querySelector('div#ST2'+IdVideoBlock); //console.log( $(span1)); // if (!video[IdVideo].textTracks) return; var track = video[IdVideo].textTracks[NumLangDef * 1]; track.mode = 'hidden'; vers=3; var idx = 0; for (t = 0; t < video[IdVideo].textTracks.length; t++) { video[IdVideo].textTracks[t].oncuechange = function (e) { switch(vers) { case 1 : if(idx==0) { e1=span1; e2=span2; } else { e2=span1; e1=span2; } var cue = this.activeCues[0]; if (cue) { //e2.style.backgroundColor="gray"; e2.classList.remove('DivSTGrow'); e2.classList.add('DivSTShrink'); e2.style.display="none"; e1.innerHTML = ''; e1.appendChild(cue.getCueAsHTML()); //e1.style.backgroundColor="transparent"; e2.style.display=""; e1.classList.add('DivSTGrow'); //e1.classList.add("zoomInRight"); //$(span1).removeClass().addClass('zoomInRight animated'); idx = ++idx % 2; } break; case 2 : e1=span1; var cue = this.activeCues[0]; if (cue) { //e2.style.backgroundColor="gray"; e1.classList.remove('DivSTGrow'); e1.classList.add('DivSTShrink'); e1.innerHTML = ''; e1.appendChild(cue.getCueAsHTML()); e1.classList.add('DivSTGrow'); } break; case 3 : e1=span1; e2=span2; var cue = this.activeCues[0]; if (cue) { e2.innerHTML=e1.innerHTML; e2.style.backgroundColor="gray"; e1.innerHTML = ''; e1.appendChild(cue.getCueAsHTML()); } break; case 4 : idx==0; span1.classList.add('DivST'); span2.classList.add('DivST'); if(idx==0) { e1=span1; e2=span2; } else { e2=span1; e1=span2; } var cue = this.activeCues[0]; if (cue) { //e2.style.backgroundColor="gray"; e2.classList.remove('DivST-open'); e2.classList.add('DivST-close'); e1.innerHTML = ''; e1.appendChild(cue.getCueAsHTML()); //e1.style.backgroundColor="transparent"; e2.classList.remove('DivST-open'); //e1.classList.add("zoomInRight"); //$(span1).removeClass().addClass('zoomInRight animated'); idx = ++idx % 2; } break; } }; } } function VideoTrackInit(IdVideo,IdVideoElement) { video[IdVideo] = document.querySelector('video#'+IdVideoElement); video[IdVideo].onplay=function (a,b){ for (var index in video) { if(IdVideo!=index) video[index].pause(); } } } function VideoSwapLangue(Num,IdVideo) { $('.vFlagsBt'+IdVideo).removeClass('CueBtDiscretOn'); $('.vFlagsBt'+IdVideo).addClass('CueBtDiscretOff'); for(t=0;t