VideoMiniatureComponent,
VideoSortComponent,
VideoWatchComponent,
+ VideoShareComponent,
+ VideoMagnetComponent,
VideoService,
WebTorrentService
} from './videos';
VideosComponent,
VideoSortComponent,
VideoWatchComponent,
+ VideoShareComponent,
+ VideoMagnetComponent
],
imports: [ // import Angular's modules
BrowserModule,
+export * from './video-magnet.component';
+export * from './video-share.component';
export * from './video-watch.component';
export * from './webtorrent.service';
--- /dev/null
+<div bsModal #modal="bs-modal" class="modal" tabindex="-1">
+ <div class="modal-dialog">
+ <div class="modal-content modal-lg">
+
+ <div class="modal-header">
+ <button type="button" class="close" aria-label="Close" (click)="hideModal()">
+ <span aria-hidden="true">×</span>
+ </button>
+ <h4 class="modal-title">Magnet Uri</h4>
+ </div>
+
+ <div class="modal-body">
+ <input #magnetUriInput (click)="magnetUriInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="video.magnetUri" />
+ </div>
+ </div>
+ </div>
+</div>
--- /dev/null
+import { Component, Input, ViewChild } from '@angular/core';
+
+import { ModalDirective } from 'ng2-bootstrap/components/modal';
+
+import { Video } from '../shared';
+
+@Component({
+ selector: 'my-video-magnet',
+ templateUrl: './video-magnet.component.html'
+})
+export class VideoMagnetComponent {
+ @Input() video: Video = null;
+
+ @ViewChild('modal') modal: ModalDirective;
+
+ constructor() {
+ // empty
+ }
+
+ show() {
+ this.modal.show();
+ }
+
+ hide() {
+ this.modal.hide();
+ }
+}
--- /dev/null
+<div bsModal #modal="bs-modal" class="modal" tabindex="-1">
+ <div class="modal-dialog modal-lg">
+ <div class="modal-content">
+
+ <div class="modal-header">
+ <button type="button" class="close" aria-label="Close" (click)="hideModal()">
+ <span aria-hidden="true">×</span>
+ </button>
+ <h4 class="modal-title">Share</h4>
+ </div>
+
+ <div class="modal-body">
+ <div class="form-group">
+ <label>URL</label>
+ <input #urlInput (click)="urlInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="getVideoUrl()" />
+ </div>
+
+ <div class="form-group">
+ <label>Embed</label>
+ <input #shareInput (click)="shareInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="getVideoIframeCode()" />
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
--- /dev/null
+import { Component, Input, ViewChild } from '@angular/core';
+
+import { ModalDirective } from 'ng2-bootstrap/components/modal';
+
+import { Video } from '../shared';
+
+@Component({
+ selector: 'my-video-share',
+ templateUrl: './video-share.component.html'
+})
+export class VideoShareComponent {
+ @Input() video: Video = null;
+
+ @ViewChild('modal') modal: ModalDirective;
+
+ constructor() {
+ // empty
+ }
+
+ show() {
+ this.modal.show();
+ }
+
+ hide() {
+ this.modal.hide();
+ }
+
+ getVideoIframeCode() {
+ return '<iframe width="560" height="315" ' +
+ 'src="' + window.location.origin + '/videos/embed/' + this.video.id + '" ' +
+ 'frameborder="0" allowfullscreen>' +
+ '</iframe>';
+ }
+
+ getVideoUrl() {
+ return window.location.href;
+ }
+}
</div>
</div>
-<div *ngIf="video !== null" bsModal #magnetUriModal="bs-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="magnetUriModal" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content modal-lg">
-
- <div class="modal-header">
- <button type="button" class="close" aria-label="Close" (click)="hideMagnetUriModal()">
- <span aria-hidden="true">×</span>
- </button>
- <h4 class="modal-title">Magnet Uri</h4>
- </div>
-
- <div class="modal-body">
- <input #magnetUriInput (click)="magnetUriInput.select()" type="text" class="form-control input-sm" readonly [value]="video.magnetUri" />
- </div>
- </div>
- </div>
-</div>
-
-<div *ngIf="video !== null" bsModal #shareModal="bs-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="shareModal" aria-hidden="true">
- <div class="modal-dialog modal-lg">
- <div class="modal-content">
-
- <div class="modal-header">
- <button type="button" class="close" aria-label="Close" (click)="hideShareModal()">
- <span aria-hidden="true">×</span>
- </button>
- <h4 class="modal-title">Share</h4>
- </div>
-
- <div class="modal-body">
- <div class="form-group">
- <label>URL</label>
- <input #urlInput (click)="urlInput.select()" type="text" class="form-control input-sm" readonly [value]="getVideoUrl()" />
- </div>
-
- <div class="form-group">
- <label>Embed</label>
- <input #shareInput (click)="shareInput.select()" type="text" class="form-control input-sm" readonly [value]="getVideoIframeCode()" />
- </div>
- </div>
- </div>
- </div>
-</div>
+<my-video-share #videoShareModal *ngIf="video !== null" [video]="video"></my-video-share>
+<my-video-magnet #videoMagnetModal *ngIf="video !== null" [video]="video"></my-video-magnet>
}
}
}
-
-.modal-content {
- input {
- /* Force blank on readonly inputs */
- background-color: #fff;
- }
-}
import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { ModalDirective } from 'ng2-bootstrap/components/modal';
import { MetaService } from 'ng2-meta';
import * as videojs from 'video.js';
+import { VideoMagnetComponent } from './video-magnet.component';
+import { VideoShareComponent } from './video-share.component';
import { Video, VideoService } from '../shared';
import { WebTorrentService } from './webtorrent.service';
export class VideoWatchComponent implements OnInit, OnDestroy {
private static LOADTIME_TOO_LONG: number = 30000;
- @ViewChild('magnetUriModal') magnetUriModal: ModalDirective;
- @ViewChild('shareModal') shareModal: ModalDirective;
+ @ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent;
+ @ViewChild('videoShareModal') videoShareModal: VideoShareComponent;
downloadSpeed: number;
error: boolean = false;
});
}
- showMagnetUriModal() {
- this.magnetUriModal.show();
- }
-
- hideMagnetUriModal() {
- this.magnetUriModal.hide();
- }
-
showShareModal() {
- this.shareModal.show();
+ this.videoShareModal.show();
}
- hideShareModal() {
- this.shareModal.hide();
- }
-
- getVideoIframeCode() {
- return '<iframe width="560" height="315" ' +
- 'src="' + window.location.origin + '/videos/embed/' + this.video.id + '" ' +
- 'frameborder="0" allowfullscreen>' +
- '</iframe>';
- }
-
- getVideoUrl() {
- return window.location.href;
+ showMagnetUriModal() {
+ this.videoMagnetModal.show();
}
private loadTooLong() {
display: none !important;
}
+input.readonly {
+ /* Force blank on readonly inputs */
+ background-color: #fff !important;
+}
footer {
border-top: 1px solid rgba(0, 0, 0, 0.2);