diff --git a/lib/controller/getHistorySessionView.php b/lib/controller/getHistorySessionView.php
index 0475428..31b3695 100644
--- a/lib/controller/getHistorySessionView.php
+++ b/lib/controller/getHistorySessionView.php
@@ -136,7 +136,7 @@
width: 75,
scale: 'small',
handler: function(){
- mSesPlay.play();
+ mSesPlay.triggerPlay();
}
},{
xtype: 'spacer',
@@ -150,7 +150,7 @@
pressed: true,
scale: 'small',
handler: function(){
- mSesPlay.toggleLoop();
+ mSesPlay.triggerLoop();
}
},{
xtype: 'spacer',
@@ -172,7 +172,7 @@
xtype: 'spacer',
width: 5
},{
- width: 140,
+ width: 150,
html: '
[timestamp]
'
},{
xtype: 'spacer',
diff --git a/lib/javascript/jsapi_dynamic/argus_monitoring.js b/lib/javascript/jsapi_dynamic/argus_monitoring.js
index e44531c..831d029 100644
--- a/lib/javascript/jsapi_dynamic/argus_monitoring.js
+++ b/lib/javascript/jsapi_dynamic/argus_monitoring.js
@@ -1236,8 +1236,8 @@ function loadMonitoringSessionView( session_id ){
tt.classList.remove('top_status_red_lbl');
tt.classList.remove('top_status_green_lbl');
tt.classList.add('top_status_orange_lbl');
- mSesPlay = new argusSessionPlayer( mon_selectedEventId );
- mSesPlay.play();
+ mSesPlay = new argusSessionPlayer( mon_selectedEventId, true );
+ //mSesPlay.triggerPlay();
fetchStatus();
};
},
diff --git a/lib/javascript/jsapi_dynamic/argus_reports.js b/lib/javascript/jsapi_dynamic/argus_reports.js
index 08b0398..64cbdde 100644
--- a/lib/javascript/jsapi_dynamic/argus_reports.js
+++ b/lib/javascript/jsapi_dynamic/argus_reports.js
@@ -1610,6 +1610,470 @@ function getSize( i ){
};
class argusSessionPlayer{
+ sessionId;
+ mMapID;
+ startTime;
+ endTime;
+ currentTime;
+ rVideoJS = null;
+ lVideoJS = null;
+ rVideoJS_id = null;
+ lVideoJS_id = null;
+ rVideoJS_playing = false;
+ rVideoJS_exists = false;
+ lVideoJS_playing = false;
+ lVideoJS_exists = false;
+ rVideoJS_cid = -1;
+ lVideoJS_cid = -1;
+ mapLayout;
+ Videos;
+ Events;
+ basePath;
+ mTimer = null;
+ mPaused = true;
+ mLooping = true;
+ mAutoPlay = false;
+ nextTimestamp = 0.0;
+ mSvgElements;//076.png
+ mMainVideo = 0;
+ constructor( session_id, autoplay ) {
+ this.sessionId = session_id;
+ this.currentTime = 0;
+ this.startTime = 0;
+ this.endTime = 0;
+ this.Videos = [];
+ this.Events = [];
+ this.rVideoJS_exists = false;
+ this.lVideoJS_exists = false;
+ this.rEvents = [];
+ this.lEvents = [];
+ this.mSvgElements = [];
+ if( autoplay != undefined ) this.mAutoPlay = autoplay;
+ Ext.Ajax.request({
+ url: '/lib/controller/getSessionData.php',
+ params: {
+ SESSION: this.sessionId,
+ UID: =$UserID;?>,
+ SID: '=$Session;?>'
+ },
+ success: function( response, opts ){
+ var data = Ext.decode( response.responseText );
+ //debugger;
+ if( data.status == 'ok' ){
+ mSesPlay.mapLayout = data.layout;
+ //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
+ //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
+ mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
+ //debugger;
+ if( data.data_ok ){
+ // Correct TS will get from Events/Videos
+ mSesPlay.startTime = data.start_ts + data.length;//data.start_ts;
+ mSesPlay.endTime = 0;//data.start_ts + data.length;
+ mSesPlay.basePath = window.location.origin + data.basepath +'/';
+ mSesPlay.Videos = [];
+ mSesPlay.mPaused = true;
+ mSesPlay.nextTimestamp = 0.0;
+ sesVideosListRName = data.r_module_name;
+ sesVideosListLName = data.l_module_name;
+ if( data.composed_video ){
+ if( data.composed_video_status == 'D' ){
+ CompositeVideoStatus = 2;
+ sesVideosListRExists = data.composed_right_video_exists;
+ sesVideosListLExists = data.composed_left_video_exists;
+ if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null;
+ if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null;
+ } else {
+ CompositeVideoStatus = 1;
+ CompositeVideoProgress = data.composed_video_progress;
+ CompositeVideoLeftInfo = null;
+ CompositeVideoRightInfo = null;
+ sesVideosListRExists = false;
+ sesVideosListLExists = false;
+ }
+ } else CompositeVideoStatus = 0;
+
+ if( data.events.length ){
+ mSesPlay.Events = data.events;
+ for( var i=0; i < data.events.length; i++ ){
+ if( data.events[i].side == 'L' ){
+ mSesPlay.lEvents.push( data.events[i] );
+ } else {
+ mSesPlay.rEvents.push( data.events[i] );
+ };
+ if( data.events[i].ts < mSesPlay.startTime ) mSesPlay.startTime = data.events[i].ts;
+ if( data.events[i].ts > mSesPlay.endTime ) mSesPlay.endTime = data.events[i].ts;
+ };
+ };
+
+ if( data.videos.length ){
+ videosListStore.loadData( data, false );
+ for( var i=0; i < data.videos.length; i++ ){
+ if( mSesPlay.currentTime == 0 ){
+ mSesPlay.currentTime = data.videos[i].sts;
+ } else {
+ if( data.videos[i].sts < mSesPlay.currentTime ) mSesPlay.currentTime = data.videos[i].sts;
+ };
+ if( data.videos[i].side == 'R' ) mSesPlay.rVideoJS_exists = true; else mSesPlay.lVideoJS_exists = true;
+ mSesPlay.Videos.push( data.videos[i] );
+ if( data.videos[i].sts < mSesPlay.startTime ) mSesPlay.startTime = data.videos[i].sts;
+ if( (data.videos[i].sts+60000) > mSesPlay.endTime ) mSesPlay.endTime = data.videos[i].sts + 60000;
+ };
+ sesVideosStartTS = mSesPlay.currentTime;
+ } else {
+ sesVideosStartTS = 0;//mSesPlay.currentTime;
+ videosListStore.removeAll();
+ };
+
+ //Init slider parameters
+ var tt = Ext.getCmp('hpl_slider');
+ tt.setMinValue( 0 );
+ tt.setMaxValue( parseInt( ( mSesPlay.endTime - mSesPlay.startTime ) / 1000 ) );
+ tt.suspendEvents();
+ tt.setValue( 0, false );
+ tt.resumeEvents();
+
+ if( mSesPlay.rVideoJS_exists ) {
+ mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
+ mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
+
+ mSesPlay.rVideoJS.on("click", function(){ mSesPlay.triggerPlay(); });
+ mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
+ // New imp
+ mSesPlay.rVideoJS.on('play', () => {
+ if( mSesPlay.mMainVideo == 1 ){
+ mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
+ };
+ });
+
+ mSesPlay.rVideoJS.on( 'timeupdate', () => {
+ //if( mSesPlay.mMainVideo == 1 ){
+ mSesPlay.checkVideoTime();
+ //};
+ });
+
+ mSesPlay.rVideoJS.on('seeking', () => {
+ mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
+ });
+
+ mSesPlay.rVideoJS.on('videotick', (e) => {
+ if( mSesPlay.mMainVideo == 1 ){
+ mSesPlay.action( mSesPlay.rVideos[mSesPlay.rVideoJS_cid].sts + e.timestamp*1000 );
+ };
+ });
+ mSesPlay.rVideoJS.on('ended', function() {
+ //console.log("Video Ended!");
+ mSesPlay.rVideoJS_playing = false;
+ mSesPlay.onVideoEnded( 1 );
+ });
+ };
+ if( mSesPlay.lVideoJS_exists ){
+ mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
+ mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
+
+ mSesPlay.lVideoJS.on("click", function(){ mSesPlay.triggerPlay(); });
+ mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
+
+ mSesPlay.lVideoJS.on('play', () => {
+ if( mSesPlay.mMainVideo == 0 ){
+ mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
+ };
+ });
+
+ mSesPlay.lVideoJS.on( 'timeupdate', () => {
+ //if( mSesPlay.mMainVideo == 0 ){
+ mSesPlay.checkVideoTime();
+ //};
+ });
+
+ mSesPlay.lVideoJS.on('seeking', () => {
+ if( mSesPlay.mMainVideo == 0 ){
+ mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
+ };
+ });
+
+ mSesPlay.lVideoJS.on('videotick', (e) => {
+ if( mSesPlay.mMainVideo == 0 ){
+ mSesPlay.action( mSesPlay.lVideos[mSesPlay.lVideoJS_cid].sts + e.timestamp*1000 );
+ };
+ });
+ mSesPlay.lVideoJS.on('ended', function() {
+ console.log("Video Ended!");
+ mSesPlay.lVideoJS_playing = false;
+ mSesPlay.onVideoEnded( 0 );
+ });
+ };
+ drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
+
+ //mSesPlay.setPosition( 0 );
+ if( mSesPlay.Videos.length ){
+ if( mSesPlay.Videos[0].side == 'L' ){
+ var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.Videos[0].name };
+ mSesPlay.lVideoJS.src( ns );
+ mSesPlay.lVideoJS_playing = true;
+ mSesPlay.lVideoJS_cid = 0;
+ mSesPlay.mMainVideo = 0;
+ } else {
+ var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.Videos[0].name };
+ mSesPlay.rVideoJS.src( ns );
+ mSesPlay.rVideoJS_playing = true;
+ mSesPlay.rVideoJS_cid = 0;
+ mSesPlay.mMainVideo = 1;
+ };
+ var zz = document.getElementById('hpl_time_mon');
+ zz.innerHTML = ts2dts( mSesPlay.Videos[0].sts );
+ };
+ if( mSesPlay.mAutoPlay ) mSesPlay.triggerPlay();
+ } else {
+ Ext.Msg.show({
+ title:'=$Labels->GetLabel('_SESSION_DATA_');?>',
+ msg: '=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
+ buttons: Ext.Msg.OK,
+ icon: Ext.MessageBox.ERROR
+ });
+ }
+ };
+ },
+ failure: failureAJAXFunction
+ });
+ }
+ getNextVideo( side ){
+ var rv = -1;
+ if( this.Videos.length ){
+ if( side ){
+ for( i= this.rVideoJS_cid+1; i < this.Videos.length; i++ ){
+ if( this.Videos[i].side == 'R' ){
+ rv = i;
+ break;
+ };
+ };
+ } else {
+ for( i= this.lVideoJS_cid+1; i < this.Videos.length; i++ ){
+ if( this.Videos[i].side == 'L' ){
+ rv = i;
+ break;
+ };
+ };
+ };
+ };
+ return rv;
+ }
+ setPosition( pos_time ){
+ var nt = this.startTime + pos_time*1000;
+ var zz = document.getElementById('hpl_time_mon');
+ zz.innerHTML = ts2dts( nt );
+ if( mSesPlay.rVideoJS_exists ){
+ var tcid = -1;
+ for( var i=0; i < mSesPlay.Videos.length; i++ ){
+ if( mSesPlay.Videos[i].side == 'R' ){
+ if( ( nt >= mSesPlay.Videos[i].sts ) && ( nt <= ( mSesPlay.Videos[i].sts + 60000 )) ) {
+ tcid = i;
+ break;
+ }
+ }
+ };
+ //debugger;
+ if( tcid < 0 ){
+ this.rVideoJS_playing = false; // Shut video off
+ //var ns = {type: 'image/png', src: '/style/assets/no-signal_h.png' };
+ //this.rVideoJS.src( ns );
+
+ //this.src([]);
+ //this.rVideoJS.poster( '/style/assets/no-signal_h.png' );
+ //this.rVideoJS.posterImage.show();
+
+ this.rVideoJS_cid = -1;
+ } else {
+ if( /*this.rVideoJS_playing && */ ( tcid == this.rVideoJS_cid ) ) this.rVideoJS.currentTime( ( nt - this.Videos[this.rVideoJS_cid].sts ) / 1000 );
+ else {
+ // open other video
+ this.rVideoJS_cid = tcid;
+ this.rVideoJS_playing = true;
+ //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
+ var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
+ this.rVideoJS.src( ns );
+ //this.rVideoJS.posterImage.hide();
+ this.rVideoJS.play();
+ //this.rVideoJS.currentTime( ( nt - this.Videos[this.rVideoJS_cid].sts ) / 1000 );
+
+ };
+ };
+ };
+ //if( mSesPlay.rVideoJS_exists ){
+ // if( this.lVideoJS_playing )
+ // this.lVideoJS.currentTime( ( nt - this.Videos[this.lVideoJS_cid].sts ) / 1000 );
+ //};
+ }
+ checkVideoTime(){
+ if( this.mMainVideo == 0 ){
+ const t = this.lVideoJS.currentTime();
+ if( t >= this.nextTimestamp ){
+ //this.lVideoJS.trigger({ type: 'videotick', timestamp: this.nextTimestamp });
+ this.action( parseInt( this.Videos[this.lVideoJS_cid].sts + t*1000 ) );
+ this.nextTimestamp += 0.1; // next 100 ms of video time
+ };
+ } else {
+ const t = this.rVideoJS.currentTime();
+ if( t >= this.nextTimestamp ){
+ //this.rVideoJS.trigger({ type: 'videotick', timestamp: this.nextTimestamp });
+ this.action( parseInt( this.Videos[this.rVideoJS_cid].sts + t*1000 ) );
+ this.nextTimestamp += 0.1; // next 100 ms of video time
+ };
+ };
+
+ }
+ triggerPlay(){
+ var zz = Ext.getCmp( 'hpl_pl_btn' );
+ if( this.mPaused ){
+ this.mPaused = false;
+ zz.setIconClass( 'plr_op_pause' );
+ zz.setText('Pause');
+ if( this.rVideoJS_exists ){
+ this.rVideoJS.play();
+ this.rVideoJS_playing = true;
+ };
+ if( this.lVideoJS_exists ){
+ this.lVideoJS.play();
+ this.lVideoJS_playing = true;
+ };
+ } else {
+ this.mPaused = true;
+ zz.setIconClass( 'plr_op_play' );
+ zz.setText('Play');
+ if( this.rVideoJS_exists ){
+ this.rVideoJS.pause();
+ this.rVideoJS_playing = false;
+ };
+ if( this.lVideoJS_exists ){
+ this.rVideoJS.pause();
+ this.lVideoJS_playing = false;
+ };
+ };
+ }
+ triggerLoop(){
+ this.mLooping = !this.mLooping;
+ }
+ onVideoEnded( side ){
+ if( this.mMainVideo == side ){
+ var nid = this.getNextVideo( side );
+ if( nid > -1 ){
+ if( side ){
+ this.rVideoJS_cid = nid;
+ this.rVideoJS_playing = true;
+ //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
+ var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
+ this.rVideoJS.src( ns );
+ this.nextTimestamp = 0.0;
+ this.rVideoJS.play();
+ } else {
+ this.lVideoJS_cid = nid;
+ this.lVideoJS_playing = true;
+ //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
+ var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
+ this.lVideoJS.src( ns );
+ this.nextTimestamp = 0.0;
+ this.lVideoJS.play();
+ };
+ } else if( this.mLooping ){
+ if( side ){
+ this.rVideoJS_cid = -1;
+ this.rVideoJS_cid = this.getNextVideo( side );
+ this.rVideoJS_playing = true;
+ //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
+ var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
+ this.rVideoJS.src( ns );
+ this.nextTimestamp = 0.0;
+ this.rVideoJS.play();
+ } else {
+ this.lVideoJS_cid = -1;
+ this.lVideoJS_cid = this.getNextVideo( side );
+ this.lVideoJS_playing = true;
+ //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
+ var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
+ this.lVideoJS.src( ns );
+ this.nextTimestamp = 0.0;
+ this.lVideoJS.play();
+ };
+ };
+ };
+ }
+ action( currentTime = 0 ){
+ //console.log( currentTime );
+ if( !this.mPaused ){
+ this.currentTime = currentTime;
+ if( this.currentTime == 0 ) this.currentTime = this.startTime;
+ var tt = Ext.getCmp('hpl_slider');
+ if( tt!= undefined ){
+ tt.suspendEvents();
+ tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
+ tt.resumeEvents();
+ };
+ var zz = document.getElementById('hpl_time_mon');
+ if( zz != undefined ) zz.innerHTML = ts2dts( this.currentTime );
+
+ if( this.Events.length ){
+ var sid = -1;
+ for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
+ sid = i;
+ break;
+ };
+ if( sid > -1 ){
+ for( var i=0; i< max_grad_levels; i++ ){
+ var cid = sid-i;
+ var csize = getSize( i );
+ //debugger;
+ if( typeof this.mSvgElements[i] === 'undefined') {
+ if( cid > -1 ){
+ var svgns = "http://www.w3.org/2000/svg";
+ this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
+ this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
+ this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
+ this.mSvgElements[i].setAttribute('height', ''+csize);
+ this.mSvgElements[i].setAttribute('width', ''+csize);
+ this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
+ var tt = document.getElementById('svgTrackMap');
+ var zz = document.getElementById('scheme_anch');
+ tt.insertBefore( this.mSvgElements[i], zz );
+ //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
+ };
+ } else {
+ if( cid > -1 ){
+ this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
+ this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
+ this.mSvgElements[i].setAttribute('height', ''+csize);
+ this.mSvgElements[i].setAttribute('width', ''+csize);
+ this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
+ } else {
+ this.mSvgElements[i].setAttribute('fill', '#FF000000');
+ };
+ };
+ };
+ } else
+ for( var i=0; i< max_grad_levels; i++ )
+ if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
+ };
+
+ //this.currentTime += 250;
+ if( this.currentTime > this.endTime ) if( this.mLooping ){
+ this.currentTime = 0;
+ } else {
+ //Stop
+ //this.play();
+ };
+ };
+ }
+ dispose(){
+ if( this.rVideoJS_exists ) {
+ this.rVideoJS.dispose();
+ this.rVideoJS = null;
+ };
+ if( this.lVideoJS_exists ) {
+ this.lVideoJS.dispose();
+ this.lVideoJS = null;
+ };
+ }
+};
+
+class argusSessionPlayer33{
sessionId;
mMapID;
startTime;