-
-
-
+
+
+
-
+
@@ -99,15 +92,19 @@
-
+
-
-
-
-
-
+
+
+
+
+
-
+
{{generatedName}}
@@ -119,12 +116,13 @@
diff --git a/front/src/app/scene/video/video.ts b/front/src/app/scene/video/video.ts
index 2234e57..1aee9b4 100644
--- a/front/src/app/scene/video/video.ts
+++ b/front/src/app/scene/video/video.ts
@@ -5,93 +5,109 @@
*/
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
-import { DataService, VideoService, SeriesService, SeasonService, ArianeService } from 'app/service';
+import { UserMediaAdvancement } from 'app/model/user-media-advancement';
+import { DataService, VideoService, SeriesService, SeasonService, ArianeService, AdvancementService } from 'app/service';
import { HttpWrapperService } from 'common/service';
import { isNullOrUndefined } from 'common/utils';
@Component({
selector: 'app-video',
templateUrl: './video.html',
- styleUrls: [ './video.less' ]
+ styleUrls: ['./video.less']
})
export class VideoScene implements OnInit {
- videoGlobal:any;
+ videoGlobal: any;
@ViewChild('globalVideoElement')
- set mainDivEl(el: ElementRef) {
- if(el !== null && el !== undefined) {
- this.videoGlobal = el.nativeElement;
+ set mainDivEl(el: ElementRef) {
+ if (!isNullOrUndefined(el)) {
+ this.videoGlobal = el.nativeElement;
}
}
videoPlayer: HTMLVideoElement;
@ViewChild('videoPlayer')
- set mainVideoEl(el: ElementRef) {
- if(el !== null && el !== undefined) {
- this.videoPlayer = el.nativeElement;
+ set mainVideoEl(el: ElementRef) {
+ if (!isNullOrUndefined(el)) {
+ this.videoPlayer = el.nativeElement;
}
}
videoCanva: any;
@ViewChild('canvascreenshoot')
- set mainCanvaEl(el: ElementRef) {
- if(el !== null && el !== undefined) {
- this.videoCanva = el.nativeElement;
+ set mainCanvaEl(el: ElementRef) {
+ if (!isNullOrUndefined(el)) {
+ this.videoCanva = el.nativeElement;
}
}
haveNext = null;
havePrevious = null;
- idVideo:number = -1;
+ idVideo: number = -1;
- mediaIsNotFound:boolean = false;
- mediaIsLoading:boolean = true;
- error:string = '';
+ mediaIsNotFound: boolean = false;
+ mediaIsLoading: boolean = true;
+ error: string = '';
- name:string = '';
- description:string = '';
- episode:number = undefined;
- seriesId:number = undefined;
- seriesName:string = undefined;
- seasonId:number = undefined;
- seasonName:string = undefined;
- dataId:number = -1;
- time:number = undefined;
- typeId:number = undefined;
- generatedName:string = '';
- videoSource:string = '';
+ name: string = '';
+ description: string = '';
+ episode: number = undefined;
+ seriesId: number = undefined;
+ seriesName: string = undefined;
+ seasonId: number = undefined;
+ seasonName: string = undefined;
+ dataId: number = -1;
+ time: number = undefined;
+ typeId: number = undefined;
+ generatedName: string = '';
+ videoSource: string = '';
covers: string[];
- playVideo:boolean = false;
- displayVolumeMenu:boolean = false;
- isPlaying:boolean = false;
- isFullScreen:boolean = false;
- currentTime:number = 0;
- currentTimeDisplay:string = '00';
- duration:number = 0;
- durationDisplay:string = '00';
- volumeValue:number = 100;
+ playVideo: boolean = false;
+ displayVolumeMenu: boolean = false;
+ isPlaying: boolean = false;
+ isFullScreen: boolean = false;
+ currentTime: number = 0;
+ currentTimeDisplay: string = '00';
+ duration: number = 0;
+ durationDisplay: string = '00';
+ volumeValue: number = 100;
- displayNeedHide:boolean = false;
+ displayNeedHide: boolean = false;
timeLeft: number = 10;
interval = null;
+
+ userMetaData: UserMediaAdvancement = undefined
+
+ previousTime: number = 0;
+ startPlayingTime: number = undefined;
+ hasFullReadTheVideo: {
+ previousTime: number,
+ totalCount: number,
+ registered: boolean
+ } = {
+ previousTime: 0,
+ totalCount: 0,
+ registered: false
+ };
+
constructor(private videoService: VideoService,
- private seriesService: SeriesService,
- private seasonService: SeasonService,
- private httpService: HttpWrapperService,
- private arianeService: ArianeService,
- private dataService: DataService) {
+ private seriesService: SeriesService,
+ private seasonService: SeasonService,
+ private httpService: HttpWrapperService,
+ private arianeService: ArianeService,
+ private dataService: DataService,
+ private advancementService: AdvancementService) {
}
startHideTimer() {
this.displayNeedHide = false;
this.timeLeft = 5;
- if(this.interval !== null) {
+ if (this.interval !== null) {
return;
}
let self = this;
this.interval = setInterval(() => {
- console.log(`periodic event: ${ self.timeLeft}`);
- if(self.timeLeft > 0) {
+ console.log(`periodic event: ${self.timeLeft}`);
+ if (self.timeLeft > 0) {
self.timeLeft--;
} else {
clearInterval(self.interval);
@@ -106,32 +122,32 @@ export class VideoScene implements OnInit {
this.interval = null;
}
onRequireNext(event: any) {
- console.log(`generate next : ${ this.haveNext.id}`);
+ console.log(`generate next : ${this.haveNext.id}`);
this.arianeService.navigateVideo(this.haveNext.id, event.which === 2, event.ctrlKey);
this.arianeService.setVideo(this.haveNext.id);
}
onRequirePrevious(event: any) {
- console.log(`generate previous : ${ this.havePrevious.id}`);
+ console.log(`generate previous : ${this.havePrevious.id}`);
this.arianeService.navigateVideo(this.havePrevious.id, event.which === 2, event.ctrlKey);
this.arianeService.setVideo(this.havePrevious.id);
}
generateName() {
this.generatedName = '';
- if(this.seriesName !== undefined) {
- this.generatedName = `${this.generatedName }${this.seriesName }-`;
+ if (this.seriesName !== undefined) {
+ this.generatedName = `${this.generatedName}${this.seriesName}-`;
}
- if(this.seasonName !== undefined) {
- if(this.seasonName.length < 2) {
- this.generatedName = `${this.generatedName }s0${ this.seasonName }-`;
+ if (this.seasonName !== undefined) {
+ if (this.seasonName.length < 2) {
+ this.generatedName = `${this.generatedName}s0${this.seasonName}-`;
} else {
- this.generatedName = `${this.generatedName }s${ this.seasonName }-`;
+ this.generatedName = `${this.generatedName}s${this.seasonName}-`;
}
}
- if(this.episode !== undefined) {
- if(this.episode < 10) {
- this.generatedName = `${this.generatedName }e0${ this.episode }-`;
+ if (this.episode !== undefined) {
+ if (this.episode < 10) {
+ this.generatedName = `${this.generatedName}e0${this.episode}-`;
} else {
- this.generatedName = `${this.generatedName }e${ this.episode }-`;
+ this.generatedName = `${this.generatedName}e${this.episode}-`;
}
}
this.generatedName = this.generatedName + this.name;
@@ -139,7 +155,7 @@ export class VideoScene implements OnInit {
this.generatedName = this.generatedName.replace(new RegExp('/', 'g'), '_');
// update the path of the uri request
this.videoSource = this.httpService.createRESTCall2({
- api: `data/${ this.dataId}/${this.generatedName}`,
+ api: `data/${this.dataId}/${this.generatedName}`,
addURLToken: true,
});
}
@@ -153,27 +169,27 @@ export class VideoScene implements OnInit {
/*
let captureStream = this.videoPlayer.audioTracks;
for (let iii=0; iii < captureStream.length; iii++) {
- console.log(" - " + captureStream[iii].language);
- if (captureStream[iii].language.substring(0,2) === "fr") {
- captureStream[iii].enabled = true;
- } else {
- captureStream[iii].enabled = false;
- }
+ console.log(" - " + captureStream[iii].language);
+ if (captureStream[iii].language.substring(0,2) === "fr") {
+ captureStream[iii].enabled = true;
+ } else {
+ captureStream[iii].enabled = false;
+ }
}
*/
}
audioTracks(event) {
- console.log(`list of the stream:${ event}`);
+ console.log(`list of the stream:${event}`);
/*
let captureStream = this.videoPlayer.audioTracks;
for (let iii=0; iii < captureStream.length; iii++) {
- console.log(" - " + captureStream[iii].language);
- if (captureStream[iii].language.substring(0,2) === "fr") {
- captureStream[iii].enabled = true;
- } else {
- captureStream[iii].enabled = false;
- }
+ console.log(" - " + captureStream[iii].language);
+ if (captureStream[iii].language.substring(0,2) === "fr") {
+ captureStream[iii].enabled = true;
+ } else {
+ captureStream[iii].enabled = false;
+ }
}
*/
}
@@ -183,19 +199,19 @@ export class VideoScene implements OnInit {
this.startHideTimer();
this.idVideo = this.arianeService.getVideoId();
this.arianeService.videoChange.subscribe((videoId) => {
- console.log(`Detect videoId change...${ videoId}`);
+ console.log(`Detect videoId change...${videoId}`);
self.idVideo = videoId;
self.updateDisplay();
});
self.updateDisplay();
}
- updateDisplay():void {
+ updateDisplay(): void {
let self = this;
self.haveNext = null;
self.havePrevious = null;
this.videoService.get(this.idVideo)
.then((response) => {
- console.log(`get response of video : ${ JSON.stringify(response, null, 2)}`);
+ console.log(`get response of video : ${JSON.stringify(response, null, 2)}`);
self.error = '';
self.name = response.name;
self.description = response.description;
@@ -205,7 +221,7 @@ export class VideoScene implements OnInit {
self.dataId = response.dataId;
self.time = response.time;
self.generatedName = "????????? TODO: ???????" //response.generatedName;
- if(self.dataId !== -1) {
+ if (self.dataId !== -1) {
self.videoSource = self.httpService.createRESTCall2({
api: `data/${self.dataId}/${self.generatedName}`,
addURLToken: true,
@@ -216,7 +232,7 @@ export class VideoScene implements OnInit {
self.covers = self.dataService.getCoverListUrl(response.covers);
self.generateName();
- if(self.seriesId !== undefined && self.seriesId !== null) {
+ if (self.seriesId !== undefined && self.seriesId !== null) {
self.seriesService.get(self.seriesId)
.then((response2) => {
self.seriesName = response2.name;
@@ -225,7 +241,7 @@ export class VideoScene implements OnInit {
// nothing to do ...
});
}
- if(self.seasonId !== undefined && self.seasonId !== null) {
+ if (self.seasonId !== undefined && self.seasonId !== null) {
self.seasonService.get(self.seasonId)
.then((response4) => {
self.seasonName = response4.name;
@@ -234,30 +250,30 @@ export class VideoScene implements OnInit {
// nothing to do ...
});
self.seasonService.getVideo(self.seasonId)
- .then((response6:any) => {
+ .then((response6: any) => {
// console.log("saison property: " + JSON.stringify(response, null, 2));
self.haveNext = null;
self.havePrevious = null;
- for(let iii = 0; iii < response6.length; iii++) {
- if(isNullOrUndefined(response6[iii].episode)) {
+ for (let iii = 0; iii < response6.length; iii++) {
+ if (isNullOrUndefined(response6[iii].episode)) {
continue;
}
- if(response6[iii].episode < self.episode) {
- if(self.havePrevious === null) {
+ if (response6[iii].episode < self.episode) {
+ if (self.havePrevious === null) {
self.havePrevious = response6[iii];
- } else if(self.havePrevious.episode < response6[iii].episode) {
+ } else if (self.havePrevious.episode < response6[iii].episode) {
self.havePrevious = response6[iii];
}
- } else if(response6[iii].episode > self.episode) {
- if(self.haveNext === null) {
+ } else if (response6[iii].episode > self.episode) {
+ if (self.haveNext === null) {
self.haveNext = response6[iii];
- } else if(self.haveNext.episode > response6[iii].episode) {
+ } else if (self.haveNext.episode > response6[iii].episode) {
self.haveNext = response6[iii];
}
}
//self.covers.push(self.dataService.getCoverUrl(response6[iii]));
}
- }).catch((response7:any) => {
+ }).catch((response7: any) => {
});
}
@@ -281,16 +297,28 @@ export class VideoScene implements OnInit {
self.mediaIsNotFound = true;
self.mediaIsLoading = false;
});
+ this.advancementService.get(this.idVideo)
+ .then((response: UserMediaAdvancement) => {
+ this.userMetaData = response
+ this.startPlayingTime = response.time
+ })
}
onRequirePlay() {
this.startHideTimer();
this.playVideo = true;
+ this.hasFullReadTheVideo = {
+ previousTime: 0,
+ totalCount: 0,
+ registered: false
+ };
this.displayVolumeMenu = false;
}
onRequireStop() {
this.startHideTimer();
+ const startPlayingTime = this.videoPlayer.currentTime
this.playVideo = false;
this.displayVolumeMenu = false;
+ this.startPlayingTime = startPlayingTime;
}
onVideoEnded() {
this.startHideTimer();
@@ -306,7 +334,7 @@ export class VideoScene implements OnInit {
changeStateToPlay() {
this.isPlaying = true;
- if(this.isFullScreen === true) {
+ if (this.isFullScreen === true) {
this.onFullscreen();
}
}
@@ -314,39 +342,82 @@ export class VideoScene implements OnInit {
this.isPlaying = false;
}
- convertIndisplayTime(time:number) : string {
- let tmpp = parseInt(`${ time}`, 10);
- let heures = parseInt(`${ tmpp / 3600}`, 10);
+ convertIndisplayTime(time: number): string {
+ let tmpp = parseInt(`${time}`, 10);
+ let heures = parseInt(`${tmpp / 3600}`, 10);
tmpp = tmpp - heures * 3600;
- let minutes = parseInt(`${ tmpp / 60}`, 10);
+ let minutes = parseInt(`${tmpp / 60}`, 10);
let seconds = tmpp - minutes * 60;
let out = '';
- if(heures !== 0) {
- out = `${out }${heures }:`;
+ if (heures !== 0) {
+ out = `${out}${heures}:`;
}
- if(minutes >= 10) {
- out = `${out }${minutes }:`;
+ if (minutes >= 10) {
+ out = `${out}${minutes}:`;
} else {
- out = `${out }0${ minutes }:`;
+ out = `${out}0${minutes}:`;
}
- if(seconds >= 10) {
+ if (seconds >= 10) {
out = out + seconds;
} else {
- out = `${out }0${ seconds}`;
+ out = `${out}0${seconds}`;
}
return out;
}
+ configureDefaultValue(): boolean {
+ if (!isNullOrUndefined(this.startPlayingTime)) {
+ this.videoPlayer.currentTime = this.startPlayingTime
+ this.startPlayingTime = undefined;
+ return true;
+ }
+ return false;
+ }
changeTimeupdate(currentTime: any) {
// console.log("time change ");
// console.log(" ==> " + this.videoPlayer.currentTime);
+ // Normal display part
this.currentTime = this.videoPlayer.currentTime;
this.currentTimeDisplay = this.convertIndisplayTime(this.currentTime);
+
+ // Cat set default value only at start
+ if (this.configureDefaultValue()) {
+ this.hasFullReadTheVideo.previousTime = this.currentTime;
+ return;
+ }
+ let needAddOneCount = false;
+ // Section to manage the detection of full read of the video
+ if (!this.hasFullReadTheVideo.registered) {
+ console.log(`Check !!!!!!!! ${this.currentTime} / ${this.hasFullReadTheVideo.previousTime} ==> ${this.currentTime - this.hasFullReadTheVideo.previousTime}`);
+ if (Math.abs(this.currentTime - this.hasFullReadTheVideo.previousTime) < 10) {
+ console.log(` ==> step 1`);
+ if (this.currentTime > this.hasFullReadTheVideo.previousTime) {
+ this.hasFullReadTheVideo.totalCount += this.currentTime - this.hasFullReadTheVideo.previousTime;
+ }
+ console.log(` ==> step 2 percent = ${this.currentTime / this.duration}, total=${this.hasFullReadTheVideo.totalCount / 60}`);
+ // Detect the passing of 90%
+ if (this.currentTime / this.duration > 0.9) {
+ console.log(` ==> step 3`);
+ this.hasFullReadTheVideo.registered = true;
+ // Add cont only if the user watching more than 3 minutes
+ if (this.hasFullReadTheVideo.totalCount > 60 * 3) {
+ console.log(` ==> step 4 ==> You win`);
+ needAddOneCount = true;
+ }
+ }
+ }
+ }
+ this.hasFullReadTheVideo.previousTime = this.currentTime;
// console.log(" ==> " + this.currentTimeDisplay);
+ if (needAddOneCount || Math.abs(this.previousTime - this.currentTime) > 15) {
+ this.previousTime = this.currentTime;
+ this.advancementService.updateTime(this.idVideo, this.currentTime, this.duration, needAddOneCount);
+ }
}
changeDurationchange(duration: any) {
console.log('duration change ');
- console.log(` ==> ${ this.videoPlayer.duration}`);
+ console.log(` ==> ${this.videoPlayer.duration}`);
+ this.configureDefaultValue();
this.duration = this.videoPlayer.duration;
this.durationDisplay = this.convertIndisplayTime(this.duration);
}
@@ -354,9 +425,9 @@ export class VideoScene implements OnInit {
onPlay() {
console.log('play');
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.videoPlayer.volume = this.volumeValue / 100;
@@ -366,9 +437,9 @@ export class VideoScene implements OnInit {
onPause() {
console.log('pause');
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.videoPlayer.pause();
@@ -376,7 +447,7 @@ export class VideoScene implements OnInit {
onPauseToggle() {
console.log('pause toggle ...');
- if(this.isPlaying === true) {
+ if (this.isPlaying === true) {
this.onPause();
} else {
this.onPlay();
@@ -386,9 +457,9 @@ export class VideoScene implements OnInit {
onStop() {
console.log('stop');
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.videoPlayer.pause();
@@ -405,12 +476,12 @@ export class VideoScene implements OnInit {
this.startHideTimer();
}
- seek(newValue:any) {
- console.log(`seek ${ newValue.value}`);
+ seek(newValue: any) {
+ console.log(`seek ${newValue.value}`);
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.videoPlayer.currentTime = newValue.value;
@@ -419,9 +490,9 @@ export class VideoScene implements OnInit {
onRewind() {
console.log('rewind');
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.videoPlayer.currentTime = this.currentTime - 10;
@@ -430,9 +501,9 @@ export class VideoScene implements OnInit {
onForward() {
console.log('forward');
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.videoPlayer.currentTime = this.currentTime + 10;
@@ -441,27 +512,27 @@ export class VideoScene implements OnInit {
onMore() {
console.log('more');
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
}
onFullscreen() {
console.log('fullscreen');
this.startHideTimer();
- if(this.videoGlobal === null ||
- this.videoGlobal === undefined) {
- console.log(`error element: ${ this.videoGlobal}`);
+ if (this.videoGlobal === null ||
+ this.videoGlobal === undefined) {
+ console.log(`error element: ${this.videoGlobal}`);
return;
}
- if(this.videoGlobal.requestFullscreen) {
+ if (this.videoGlobal.requestFullscreen) {
this.videoGlobal.requestFullscreen();
- } else if(this.videoGlobal.mozRequestFullScreen) {
+ } else if (this.videoGlobal.mozRequestFullScreen) {
this.videoGlobal.mozRequestFullScreen();
- } else if(this.videoGlobal.webkitRequestFullscreen) {
+ } else if (this.videoGlobal.webkitRequestFullscreen) {
this.videoGlobal.webkitRequestFullscreen();
- } else if(this.videoGlobal.msRequestFullscreen) {
+ } else if (this.videoGlobal.msRequestFullscreen) {
this.videoGlobal.msRequestFullscreen();
}
}
@@ -469,21 +540,21 @@ export class VideoScene implements OnInit {
onFullscreenExit() {
this.onFullscreenExit22(document);
}
- onFullscreenExit22(docc:any) {
+ onFullscreenExit22(docc: any) {
console.log('fullscreen EXIT');
this.startHideTimer();
- if(this.videoGlobal === null ||
- this.videoGlobal === undefined) {
- console.log(`error element: ${ this.videoGlobal}`);
+ if (this.videoGlobal === null ||
+ this.videoGlobal === undefined) {
+ console.log(`error element: ${this.videoGlobal}`);
return;
}
- if(docc.exitFullscreen) {
+ if (docc.exitFullscreen) {
docc.exitFullscreen();
- } else if(docc.mozCancelFullScreen) {
+ } else if (docc.mozCancelFullScreen) {
docc.mozCancelFullScreen();
- } else if(docc.webkitExitFullscreen) {
+ } else if (docc.webkitExitFullscreen) {
docc.webkitExitFullscreen();
- } else if(docc.msExitFullscreen) {
+ } else if (docc.msExitFullscreen) {
docc.msExitFullscreen();
}
}
@@ -491,12 +562,12 @@ export class VideoScene implements OnInit {
onFullscreenChange() {
this.onFullscreenChange22(document);
}
- onFullscreenChange22(element:any) {
+ onFullscreenChange22(element: any) {
let isInFullScreen = element.fullscreenElement && element.fullscreenElement !== null ||
- element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
- element.mozFullScreenElement && element.mozFullScreenElement !== null ||
- element.msFullscreenElement && element.msFullscreenElement !== null;
- console.log(`onFullscreenChange(${ isInFullScreen })`);
+ element.webkitFullscreenElement && element.webkitFullscreenElement !== null ||
+ element.mozFullScreenElement && element.mozFullScreenElement !== null ||
+ element.msFullscreenElement && element.msFullscreenElement !== null;
+ console.log(`onFullscreenChange(${isInFullScreen})`);
this.isFullScreen = isInFullScreen;
}
@@ -505,12 +576,12 @@ export class VideoScene implements OnInit {
this.startHideTimer();
}
- onVolume(newValue:any) {
- console.log(`onVolume ${ newValue.value}`);
+ onVolume(newValue: any) {
+ console.log(`onVolume ${newValue.value}`);
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.volumeValue = newValue.value;
@@ -520,9 +591,9 @@ export class VideoScene implements OnInit {
onVolumeMute() {
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.videoPlayer.muted = true;
@@ -530,9 +601,9 @@ export class VideoScene implements OnInit {
onVolumeUnMute() {
this.startHideTimer();
- if(this.videoPlayer === null ||
- this.videoPlayer === undefined) {
- console.log(`error element: ${ this.videoPlayer}`);
+ if (this.videoPlayer === null ||
+ this.videoPlayer === undefined) {
+ console.log(`error element: ${this.videoPlayer}`);
return;
}
this.videoPlayer.muted = false;
diff --git a/front/src/app/service/GenericInterfaceModelDBv2.ts b/front/src/app/service/GenericInterfaceModelDBv2.ts
new file mode 100644
index 0000000..597b0ec
--- /dev/null
+++ b/front/src/app/service/GenericInterfaceModelDBv2.ts
@@ -0,0 +1,96 @@
+import { isNodeData, NodeData } from "common/model";
+import { HttpWrapperService, BddService } from "common/service";
+import { DataInterface, isArrayOf, isNullOrUndefined, TypeCheck } from "common/utils";
+
+export class GenericInterfaceModelDBv2
{
+ constructor(
+ protected serviceName: string,
+ protected http: HttpWrapperService,
+ protected bdd: BddService,
+ protected checker: (subData: any) => subData is TYPE) {
+ // nothing to do ...
+ }
+
+ gets(): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.bdd.get(self.serviceName)
+ .then((response: DataInterface) => {
+ let data = response.gets();
+ if (isNullOrUndefined(data)) {
+ reject('Data does not exist in the local BDD');
+ return;
+ }
+ if (isArrayOf(data, this.checker)) {
+ resolve(data);
+ } else {
+ reject("The data is not an array of the correct type ...");
+ }
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+ get(id: number): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.bdd.get(self.serviceName)
+ .then((response: DataInterface) => {
+ let data = response.get(id);
+ if (isNullOrUndefined(data)) {
+ reject('Data does not exist in the local BDD');
+ return;
+ }
+ if (this.checker(data)) {
+ resolve(data);
+ } else {
+ reject("The data is not an array of the correct type ...");
+ }
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+
+ getFilter(filter: (subData: any) => boolean): Promise {
+ let self = this;
+ return new Promise((resolve, reject) => {
+ self.bdd.get(self.serviceName)
+ .then((response: DataInterface) => {
+ let data = response.gets();
+ if (isNullOrUndefined(data)) {
+ reject('Data does not exist in the local BDD');
+ return;
+ }
+ let out = [];
+ for (const elem of data) {
+ if (filter(elem)) {
+ out.push(elem);
+ }
+ }
+ resolve(out as TYPE[]);
+ return;
+ }).catch((response) => {
+ reject(response);
+ });
+ });
+ }
+
+ insert(data: object): TYPE {
+ let ret = this.http.postSpecific([this.serviceName], data);
+ return this.bdd.addAfterPost(this.serviceName, ret) as TYPE;
+
+ }
+ put(id: number, data: object): TYPE {
+ let ret = this.http.putSpecific([this.serviceName, id], data);
+ return this.bdd.setAfterPut(this.serviceName, id, ret) as TYPE;
+ }
+
+ delete(id: number): TYPE {
+ let ret = this.http.deleteSpecific([this.serviceName, id]);
+ return this.bdd.delete(this.serviceName, id, ret) as TYPE;
+ }
+
+}
diff --git a/front/src/app/service/advancement.ts b/front/src/app/service/advancement.ts
new file mode 100644
index 0000000..7e4bb09
--- /dev/null
+++ b/front/src/app/service/advancement.ts
@@ -0,0 +1,39 @@
+/** @file
+ * @author Edouard DUPIN
+ * @copyright 2018, Edouard DUPIN, all right reserved
+ * @license PROPRIETARY (see license file)
+ */
+
+import { Injectable } from '@angular/core';
+
+import { HttpWrapperService, BddService } from 'common/service';
+import { isUserMediaAdvancement, UserMediaAdvancement } from 'app/model/user-media-advancement';
+import { GenericInterfaceModelDBv2 } from './GenericInterfaceModelDBv2';
+
+@Injectable()
+export class AdvancementService extends GenericInterfaceModelDBv2 {
+
+ constructor(http: HttpWrapperService,
+ bdd: BddService) {
+ super('advancement', http, bdd, isUserMediaAdvancement);
+ }
+ get(id: number): Promise {
+ return new Promise((resolve, reject) => {
+ super.getFilter((data: any) => { return data.mediaId == id }).then((data: UserMediaAdvancement[]) => {
+ resolve(data[0]);
+ return;
+ }).catch((reason: any) => {
+ reject(reason);
+ });
+ });
+ }
+ updateTime(id: number, time: number, total: number, addCount: boolean) {
+ this.put(id, {
+ time: time,
+ percent: time / total,
+ addCount: addCount
+ });
+ }
+
+}
+
diff --git a/front/src/app/service/index.ts b/front/src/app/service/index.ts
index ac3717d..dc021e5 100644
--- a/front/src/app/service/index.ts
+++ b/front/src/app/service/index.ts
@@ -1,3 +1,4 @@
+import { AdvancementService } from "./advancement";
import { ArianeService } from "./ariane";
import { DataService } from "./data";
import { SeasonService } from "./season";
@@ -14,6 +15,7 @@ export {
SeriesService,
TypeService,
VideoService,
+ AdvancementService
};
diff --git a/front/src/common b/front/src/common
index 9fc25b4..ea5a4f6 160000
--- a/front/src/common
+++ b/front/src/common
@@ -1 +1 @@
-Subproject commit 9fc25b4feaeba509ff39f70b24d97be47f4b30e1
+Subproject commit ea5a4f6b7537eb707916f4610bf79fbe86c6296f