diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
commit | a6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch) | |
tree | 03204a408d56311692c3528bedcf95d2455e94f2 /client/src/app/videos/video-watch | |
parent | 052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff) | |
parent | c4403b29ad4db097af528a7f04eea07e0ed320d0 (diff) | |
download | PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.gz PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.zst PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.zip |
Merge branch 'master' into webseed-merged
Diffstat (limited to 'client/src/app/videos/video-watch')
-rw-r--r-- | client/src/app/videos/video-watch/video-watch.component.ts | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts index 3aaed0487..239e24c99 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts | |||
@@ -1,18 +1,13 @@ | |||
1 | import { Component, ElementRef, OnDestroy, OnInit } from '@angular/core'; | 1 | import { Component, ElementRef, NgZone, OnDestroy, OnInit } from '@angular/core'; |
2 | import { ActivatedRoute } from '@angular/router'; | 2 | import { ActivatedRoute } from '@angular/router'; |
3 | 3 | ||
4 | import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; | 4 | import { Video, VideoService } from '../shared'; |
5 | |||
6 | import { LoaderComponent, Video, VideoService } from '../shared'; | ||
7 | import { WebTorrentService } from './webtorrent.service'; | 5 | import { WebTorrentService } from './webtorrent.service'; |
8 | 6 | ||
9 | @Component({ | 7 | @Component({ |
10 | selector: 'my-video-watch', | 8 | selector: 'my-video-watch', |
11 | template: require('./video-watch.component.html'), | 9 | templateUrl: './video-watch.component.html', |
12 | styles: [ require('./video-watch.component.scss') ], | 10 | styleUrls: [ './video-watch.component.scss' ] |
13 | providers: [ WebTorrentService ], | ||
14 | directives: [ LoaderComponent ], | ||
15 | pipes: [ BytesPipe ] | ||
16 | }) | 11 | }) |
17 | 12 | ||
18 | export class VideoWatchComponent implements OnInit, OnDestroy { | 13 | export class VideoWatchComponent implements OnInit, OnDestroy { |
@@ -31,6 +26,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
31 | 26 | ||
32 | constructor( | 27 | constructor( |
33 | private elementRef: ElementRef, | 28 | private elementRef: ElementRef, |
29 | private ngZone: NgZone, | ||
34 | private route: ActivatedRoute, | 30 | private route: ActivatedRoute, |
35 | private videoService: VideoService, | 31 | private videoService: VideoService, |
36 | private webTorrentService: WebTorrentService | 32 | private webTorrentService: WebTorrentService |
@@ -65,12 +61,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
65 | } | 61 | } |
66 | }); | 62 | }); |
67 | 63 | ||
68 | // Refresh each second | 64 | this.runInProgress(torrent); |
69 | this.torrentInfosInterval = setInterval(() => { | ||
70 | this.downloadSpeed = torrent.downloadSpeed; | ||
71 | this.numPeers = torrent.numPeers; | ||
72 | this.uploadSpeed = torrent.uploadSpeed; | ||
73 | }, 1000); | ||
74 | }); | 65 | }); |
75 | } | 66 | } |
76 | 67 | ||
@@ -91,7 +82,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
91 | this.video = video; | 82 | this.video = video; |
92 | this.loadVideo(); | 83 | this.loadVideo(); |
93 | }, | 84 | }, |
94 | error => alert(error) | 85 | error => alert(error.text) |
95 | ); | 86 | ); |
96 | }); | 87 | }); |
97 | } | 88 | } |
@@ -100,4 +91,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
100 | this.error = true; | 91 | this.error = true; |
101 | console.error('The video load seems to be abnormally long.'); | 92 | console.error('The video load seems to be abnormally long.'); |
102 | } | 93 | } |
94 | |||
95 | private runInProgress(torrent: any) { | ||
96 | // Refresh each second | ||
97 | this.torrentInfosInterval = setInterval(() => { | ||
98 | this.ngZone.run(() => { | ||
99 | this.downloadSpeed = torrent.downloadSpeed; | ||
100 | this.numPeers = torrent.numPeers; | ||
101 | this.uploadSpeed = torrent.uploadSpeed; | ||
102 | }); | ||
103 | }, 1000); | ||
104 | } | ||
103 | } | 105 | } |