2018-05-09 00:03:22 +02:00
|
|
|
class VideoData {
|
|
|
|
|
2018-08-05 23:48:56 +02:00
|
|
|
constructor(video, settings){
|
2018-05-16 23:26:47 +02:00
|
|
|
this.arSetupComplete = false;
|
2018-05-09 00:03:22 +02:00
|
|
|
this.video = video;
|
2018-05-21 22:43:56 +02:00
|
|
|
this.destroyed = false;
|
2018-08-05 23:48:56 +02:00
|
|
|
this.settings = settings;
|
2018-05-14 20:39:15 +02:00
|
|
|
// POZOR: VRSTNI RED JE POMEMBEN (arDetect mora bit zadnji)
|
|
|
|
// NOTE: ORDERING OF OBJ INITIALIZATIONS IS IMPORTANT (arDetect needs to go last)
|
2018-05-13 13:49:25 +02:00
|
|
|
this.player = new PlayerData(this);
|
2018-05-14 20:39:15 +02:00
|
|
|
this.resizer = new Resizer(this);
|
|
|
|
|
|
|
|
this.arDetector = new ArDetector(this); // this starts Ar detection. needs optional parameter that prevets ardetdctor from starting
|
2018-05-12 02:51:58 +02:00
|
|
|
// player dimensions need to be in:
|
|
|
|
// this.player.dimensions
|
|
|
|
}
|
|
|
|
|
2018-05-16 23:26:47 +02:00
|
|
|
firstTimeArdInit(){
|
|
|
|
if(! this.arSetupComplete){
|
|
|
|
this.arDetector = new ArDetector(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-14 20:39:15 +02:00
|
|
|
initArDetection() {
|
2018-05-20 23:17:09 +02:00
|
|
|
if(this.arDetector){
|
2018-05-16 23:26:47 +02:00
|
|
|
this.arDetector.init();
|
2018-05-20 23:17:09 +02:00
|
|
|
}
|
|
|
|
else{
|
2018-05-16 23:26:47 +02:00
|
|
|
this.arDetector = new ArDetector(this);
|
2018-05-20 23:17:09 +02:00
|
|
|
this.arDetector.init();
|
|
|
|
}
|
2018-05-12 02:51:58 +02:00
|
|
|
}
|
2018-05-24 20:50:37 +02:00
|
|
|
|
2018-05-14 20:39:15 +02:00
|
|
|
startArDetection() {
|
2018-08-31 00:35:52 +02:00
|
|
|
if(!this.arDetector) {
|
|
|
|
this.arDetector.init();
|
|
|
|
}
|
2018-05-12 02:51:58 +02:00
|
|
|
this.arDetector.start();
|
2018-05-09 00:03:22 +02:00
|
|
|
}
|
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
stopArDetection() {
|
2018-08-31 00:35:52 +02:00
|
|
|
if (this.arDetector) {
|
|
|
|
this.arDetector.stop();
|
|
|
|
}
|
2018-05-24 20:50:37 +02:00
|
|
|
}
|
|
|
|
|
2018-05-09 00:03:22 +02:00
|
|
|
destroy() {
|
2018-08-30 00:56:15 +02:00
|
|
|
if(Debug.debug){
|
|
|
|
console.log("[VideoData::destroy] received destroy command");
|
|
|
|
}
|
|
|
|
|
2018-05-21 22:43:56 +02:00
|
|
|
this.destroyed = true;
|
2018-05-16 23:26:47 +02:00
|
|
|
if(this.arDetector){
|
|
|
|
this.arDetector.stop();
|
|
|
|
this.arDetector.destroy();
|
|
|
|
}
|
|
|
|
this.arDetector = null;
|
|
|
|
if(this.resizer){
|
|
|
|
this.resizer.destroy();
|
|
|
|
}
|
2018-08-30 00:56:15 +02:00
|
|
|
this.resizer = null;
|
2018-05-22 00:19:50 +02:00
|
|
|
if(this.player){
|
2018-08-23 01:04:37 +02:00
|
|
|
this.player.destroy();
|
2018-05-22 00:19:50 +02:00
|
|
|
}
|
2018-08-30 00:56:15 +02:00
|
|
|
this.player = null;
|
2018-05-16 23:26:47 +02:00
|
|
|
this.video = null;
|
2018-05-09 00:03:22 +02:00
|
|
|
}
|
2018-05-09 00:34:22 +02:00
|
|
|
|
2018-05-23 23:58:34 +02:00
|
|
|
pause(){
|
|
|
|
this.paused = true;
|
|
|
|
if(this.arDetector){
|
|
|
|
this.arDetector.stop();
|
|
|
|
}
|
|
|
|
if(this.resizer){
|
|
|
|
this.resizer.stop();
|
|
|
|
}
|
|
|
|
if(this.player){
|
|
|
|
this.player.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resume(){
|
|
|
|
this.paused = false;
|
|
|
|
try {
|
|
|
|
this.resizer.start();
|
|
|
|
this.player.start();
|
|
|
|
} catch (e) {
|
|
|
|
if(Debug.debug){
|
|
|
|
console.log("[VideoData.js::resume] cannot resume for reasons. Will destroy videoData. Error here:", e);
|
|
|
|
}
|
|
|
|
this.destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resumeAutoAr(){
|
|
|
|
if(this.arDetector){
|
|
|
|
this.startArDetection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-09 00:34:22 +02:00
|
|
|
setLastAr(lastAr){
|
|
|
|
this.resizer.setLastAr(lastAr);
|
|
|
|
}
|
|
|
|
|
2018-05-13 21:05:11 +02:00
|
|
|
setAr(ar, lastAr){
|
|
|
|
this.resizer.setAr(ar, lastAr);
|
|
|
|
}
|
|
|
|
|
2018-09-14 00:10:57 +02:00
|
|
|
resetAr() {
|
|
|
|
this.resizer.reset();
|
|
|
|
}
|
|
|
|
|
2018-09-13 23:47:20 +02:00
|
|
|
panHandler(event) {
|
|
|
|
this.resizer.panHandler(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
setPanMode(mode) {
|
|
|
|
this.resizer.setPanMode(mode);
|
|
|
|
}
|
|
|
|
|
2018-07-15 16:22:32 +02:00
|
|
|
restoreAr(){
|
|
|
|
this.resizer.restore();
|
|
|
|
}
|
|
|
|
|
2018-05-13 21:05:11 +02:00
|
|
|
setStretchMode(stretchMode){
|
|
|
|
this.resizer.setStretchMode(stretchMode);
|
|
|
|
}
|
2018-05-13 13:49:25 +02:00
|
|
|
|
2018-05-24 20:50:37 +02:00
|
|
|
zoomStep(step){
|
2018-09-13 23:47:20 +02:00
|
|
|
this.resizer.zoomStep(step);
|
2018-05-24 20:50:37 +02:00
|
|
|
}
|
|
|
|
|
2018-05-09 00:03:22 +02:00
|
|
|
}
|