<br />
<a href="https://travis-ci.org/Chocobozzz/PeerTube">
- <img src="https://travis-ci.org/Chocobozzz/PeerTube.svg?branch=master" alt="Build Status" />
+ <img src="https://travis-ci.org/Chocobozzz/PeerTube.svg?branch=develop" alt="Build Status" />
</a>
<a href="https://david-dm.org/Chocobozzz/PeerTube">
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin')
+const ProvidePlugin = require('webpack/lib/ProvidePlugin')
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
+import { Subscription } from 'rxjs/Subscription';
import * as videojs from 'video.js';
import { MetaService } from 'ng2-meta';
videoNotFound = false;
private errorTimer: number;
- private sub: any;
+ private paramsSub: Subscription;
+ private errorsSub: Subscription;
+ private warningsSub: Subscription;
private torrentInfosInterval: number;
constructor(
) {}
ngOnInit() {
- this.sub = this.route.params.subscribe(routeParams => {
+ this.paramsSub = this.route.params.subscribe(routeParams => {
let id = routeParams['id'];
this.videoService.getVideo(id).subscribe(
video => {
videojs(this.playerElement, videojsOptions, function () {
self.player = this;
});
+
+ this.errorsSub = this.webTorrentService.errors.subscribe(err => this.notificationsService.error('Error', err.message));
+ this.warningsSub = this.webTorrentService.errors.subscribe(err => this.notificationsService.alert('Warning', err.message));
}
ngOnDestroy() {
// Remove player
videojs(this.playerElement).dispose();
- // Unsubscribe route subscription
- this.sub.unsubscribe();
+ // Unsubscribe subscriptions
+ this.paramsSub.unsubscribe();
+ this.errorsSub.unsubscribe();
+ this.warningsSub.unsubscribe();
}
loadVideo() {
-// Don't use webtorrent typings for now
-// It misses some little things I'll fix later
-// <reference path="../../../../typings/globals/webtorrent/index.d.ts" />
-
import { Injectable } from '@angular/core';
+import { Subject } from 'rxjs/Subject';
-// import WebTorrent = require('webtorrent');
-declare var WebTorrent: any;
+declare const WebTorrent;
@Injectable()
export class WebTorrentService {
+ errors = new Subject<Error>();
+ warnings = new Subject<Error>();
+
+ // TODO: use WebTorrent @type
// private client: WebTorrent.Client;
private client: any;
constructor() {
this.client = new WebTorrent({ dht: false });
+
+ this.client.on('error', (err) => this.errors.next(err))
+ this.client.on('warning', (err) => this.warnings.next(err))
}
add(magnetUri: string, callback: Function) {