aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--client/config/webpack.common.js1
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts16
-rw-r--r--client/src/app/videos/video-watch/webtorrent.service.ts15
4 files changed, 23 insertions, 11 deletions
diff --git a/README.md b/README.md
index a1198019c..1047ea6e9 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@ Prototype of a decentralized video streaming platform using P2P (BitTorrent) dir
26 <br /> 26 <br />
27 27
28 <a href="https://travis-ci.org/Chocobozzz/PeerTube"> 28 <a href="https://travis-ci.org/Chocobozzz/PeerTube">
29 <img src="https://travis-ci.org/Chocobozzz/PeerTube.svg?branch=master" alt="Build Status" /> 29 <img src="https://travis-ci.org/Chocobozzz/PeerTube.svg?branch=develop" alt="Build Status" />
30 </a> 30 </a>
31 31
32 <a href="https://david-dm.org/Chocobozzz/PeerTube"> 32 <a href="https://david-dm.org/Chocobozzz/PeerTube">
diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js
index 08b8a4b09..2d227f6f8 100644
--- a/client/config/webpack.common.js
+++ b/client/config/webpack.common.js
@@ -8,6 +8,7 @@ const AssetsPlugin = require('assets-webpack-plugin')
8const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 8const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
9const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin') 9const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
10const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin') 10const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin')
11const ProvidePlugin = require('webpack/lib/ProvidePlugin')
11const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin') 12const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')
12const CopyWebpackPlugin = require('copy-webpack-plugin') 13const CopyWebpackPlugin = require('copy-webpack-plugin')
13const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin 14const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
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 c27133f74..9ac9342b7 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -1,5 +1,6 @@
1import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'; 1import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
2import { ActivatedRoute } from '@angular/router'; 2import { ActivatedRoute } from '@angular/router';
3import { Subscription } from 'rxjs/Subscription';
3 4
4import * as videojs from 'video.js'; 5import * as videojs from 'video.js';
5import { MetaService } from 'ng2-meta'; 6import { MetaService } from 'ng2-meta';
@@ -36,7 +37,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
36 videoNotFound = false; 37 videoNotFound = false;
37 38
38 private errorTimer: number; 39 private errorTimer: number;
39 private sub: any; 40 private paramsSub: Subscription;
41 private errorsSub: Subscription;
42 private warningsSub: Subscription;
40 private torrentInfosInterval: number; 43 private torrentInfosInterval: number;
41 44
42 constructor( 45 constructor(
@@ -51,7 +54,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
51 ) {} 54 ) {}
52 55
53 ngOnInit() { 56 ngOnInit() {
54 this.sub = this.route.params.subscribe(routeParams => { 57 this.paramsSub = this.route.params.subscribe(routeParams => {
55 let id = routeParams['id']; 58 let id = routeParams['id'];
56 this.videoService.getVideo(id).subscribe( 59 this.videoService.getVideo(id).subscribe(
57 video => { 60 video => {
@@ -76,6 +79,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
76 videojs(this.playerElement, videojsOptions, function () { 79 videojs(this.playerElement, videojsOptions, function () {
77 self.player = this; 80 self.player = this;
78 }); 81 });
82
83 this.errorsSub = this.webTorrentService.errors.subscribe(err => this.notificationsService.error('Error', err.message));
84 this.warningsSub = this.webTorrentService.errors.subscribe(err => this.notificationsService.alert('Warning', err.message));
79 } 85 }
80 86
81 ngOnDestroy() { 87 ngOnDestroy() {
@@ -91,8 +97,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
91 // Remove player 97 // Remove player
92 videojs(this.playerElement).dispose(); 98 videojs(this.playerElement).dispose();
93 99
94 // Unsubscribe route subscription 100 // Unsubscribe subscriptions
95 this.sub.unsubscribe(); 101 this.paramsSub.unsubscribe();
102 this.errorsSub.unsubscribe();
103 this.warningsSub.unsubscribe();
96 } 104 }
97 105
98 loadVideo() { 106 loadVideo() {
diff --git a/client/src/app/videos/video-watch/webtorrent.service.ts b/client/src/app/videos/video-watch/webtorrent.service.ts
index bf38b5aaa..1839c7c27 100644
--- a/client/src/app/videos/video-watch/webtorrent.service.ts
+++ b/client/src/app/videos/video-watch/webtorrent.service.ts
@@ -1,19 +1,22 @@
1// Don't use webtorrent typings for now
2// It misses some little things I'll fix later
3// <reference path="../../../../typings/globals/webtorrent/index.d.ts" />
4
5import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Subject } from 'rxjs/Subject';
6 3
7// import WebTorrent = require('webtorrent'); 4declare const WebTorrent;
8declare var WebTorrent: any;
9 5
10@Injectable() 6@Injectable()
11export class WebTorrentService { 7export class WebTorrentService {
8 errors = new Subject<Error>();
9 warnings = new Subject<Error>();
10
11 // TODO: use WebTorrent @type
12 // private client: WebTorrent.Client; 12 // private client: WebTorrent.Client;
13 private client: any; 13 private client: any;
14 14
15 constructor() { 15 constructor() {
16 this.client = new WebTorrent({ dht: false }); 16 this.client = new WebTorrent({ dht: false });
17
18 this.client.on('error', (err) => this.errors.next(err))
19 this.client.on('warning', (err) => this.warnings.next(err))
17 } 20 }
18 21
19 add(magnetUri: string, callback: Function) { 22 add(magnetUri: string, callback: Function) {