Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, OnInit, ViewChild} from '@angular/core';
  2. import {ActivatedRoute, ParamMap, Router} from "@angular/router";
  3. import {VideoService} from "../video.service";
  4. import {DomSanitizer} from "@angular/platform-browser";
  5. import {TagService} from "../tag.service";
  6. import {NgxY2PlayerComponent, NgxY2PlayerOptions} from "ngx-y2-player";
  7.  
  8. @Component({
  9.   selector: 'app-video-show',
  10.   templateUrl: './video-show.component.html',
  11.   styleUrls: ['./video-show.component.css']
  12. })
  13. export class VideoShowComponent implements OnInit {
  14.  
  15.     public youtubeId;
  16.  
  17.     public videoInfo;
  18.  
  19.     public errorMsg;
  20.  
  21.     public tags;
  22.  
  23.     @ViewChild('video') video: NgxY2PlayerComponent;
  24.  
  25.     constructor(private route: ActivatedRoute, private router: Router, private _videoService: VideoService,
  26.                 private _tagService: TagService) {
  27.  
  28.     }
  29.  
  30.     playerOptions: NgxY2PlayerOptions = {
  31.         videoId: this.youtubeId,
  32.         height: 'auto',
  33.         width: 'auto',
  34.         playerVars: {
  35.             autoplay: 1,
  36.         },
  37.     };
  38.    
  39.  
  40.     ngOnInit() {
  41.         this.route.paramMap.subscribe((params : ParamMap) => {
  42.             this.youtubeId = params.get('youtubeId');
  43.         });
  44.  
  45.         this._videoService.getVideo(this.youtubeId)
  46.             .subscribe(data => this.videoInfo = data,
  47.                 error => this.errorMsg = error);
  48.  
  49.         this._tagService.getTagsForVideo(this.youtubeId)
  50.             .subscribe(data => this.tags = data,
  51.                 error => this.errorMsg = error);
  52.     }
  53.  
  54.  
  55.  
  56.     tagStyle(tag): string {
  57.  
  58.         if(tag.times == null) {
  59.             return 'btn-default';
  60.         }
  61.  
  62.         if(tag.complete) {
  63.             return 'btn-success';
  64.         }
  65.  
  66.         let arr = tag.times[0];
  67.  
  68.         if(arr.start == 0 && arr.stop == this.videoInfo.duration){
  69.             return 'btn-danger'
  70.         }
  71.  
  72.         return 'btn-warning'
  73.     }
  74.  
  75.     pause() {
  76.         this.video.videoPlayer.pauseVideo();
  77.     }
  78.     play() {
  79.         this.video.videoPlayer.playVideo();
  80.     }
  81.     stop() {
  82.         this.video.videoPlayer.stopVideo();
  83.     }
  84.     go(second) {
  85.         this.video.videoPlayer.seekTo(second, true);
  86.     }
  87.  
  88.     onReady(event) {
  89.         console.log('ready');
  90.         console.log(event);
  91.     }
  92.  
  93.     onStateChange(event) {
  94.         console.log('change');
  95.         console.log(event);
  96.     }
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement