import { Component,  ChangeDetectorRef, ElementRef, OnInit, ViewChild } from '@angular/core';
import { LocalStorage } from "../../core/services/local_storage.service"
import { HyperService } from '../../core/services/http.service';
import { Location } from '@angular/common';
declare var $;

@Component({
  selector: 'app-product-videos',
  templateUrl: './product-videos.component.html',
  styleUrls: ['./product-videos.component.scss']
})
export class ProductVideosComponent implements OnInit {
video:any;
model_name:any;
data_check:boolean=false;
@ViewChild('videoplayer') videoplayer: ElementRef;
  constructor(private server: HyperService, private loc: Location, private elementRef: ElementRef) { 
    this.model_name =  LocalStorage.getValue('model_name')
    this.getContent()
  }
  
  ngOnInit() {

  }
  getContent(){
    this.server.get("explore/contentlist/" +LocalStorage.getValue('set_model_id')+ "?page=0&limit=10").then((data)=>{
     
      if (data.status == 200 && data.result.response != 'failed' && data.result.data != null){
        console.log(data.result.data);
        if(data.result.data.length==0){
          this.data_check=true;
          console.log(this.data_check)
      }else{
        this.video=data.result.data
        console.log(data.result.data);
        this.data_check=false;
      }
      
      }
        
    })
  }

  closeVideo(id) {
    console.log(id)
    $('#videoModal_'+id).on('hidden.bs.modal', function (event) {
      $('#videoplayers_'+id)[0].pause();
    });
    // this.videoplayer.nativeElement.pause();
  }

}
