diff options
Diffstat (limited to 'client/src/app/videos')
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.html | 2 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.ts | 28 |
2 files changed, 28 insertions, 2 deletions
diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index 7dbc96bf4..0f2f3cf11 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html | |||
@@ -125,7 +125,7 @@ | |||
125 | <img [src]="video.videoChannelAvatarUrl" alt="Video channel avatar" /> | 125 | <img [src]="video.videoChannelAvatarUrl" alt="Video channel avatar" /> |
126 | </a> | 126 | </a> |
127 | 127 | ||
128 | <my-subscribe-button *ngIf="isUserLoggedIn()" [videoChannel]="video.channel" size="small"></my-subscribe-button> | 128 | <my-subscribe-button #subscribeButton *ngIf="isUserLoggedIn()" [videoChannel]="video.channel" size="small"></my-subscribe-button> |
129 | </div> | 129 | </div> |
130 | 130 | ||
131 | <div class="video-info-by"> | 131 | <div class="video-info-by"> |
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 25643cfde..768a08d42 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { catchError } from 'rxjs/operators' | 1 | import { catchError, subscribeOn } from 'rxjs/operators' |
2 | import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' | 2 | import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { RedirectService } from '@app/core/routing/redirect.service' | 4 | import { RedirectService } from '@app/core/routing/redirect.service' |
@@ -9,6 +9,7 @@ import { NotificationsService } from 'angular2-notifications' | |||
9 | import { forkJoin, Subscription } from 'rxjs' | 9 | import { forkJoin, Subscription } from 'rxjs' |
10 | import * as videojs from 'video.js' | 10 | import * as videojs from 'video.js' |
11 | import 'videojs-hotkeys' | 11 | import 'videojs-hotkeys' |
12 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' | ||
12 | import * as WebTorrent from 'webtorrent' | 13 | import * as WebTorrent from 'webtorrent' |
13 | import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoRateType, VideoState } from '../../../../../shared' | 14 | import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoRateType, VideoState } from '../../../../../shared' |
14 | import '../../../assets/player/peertube-videojs-plugin' | 15 | import '../../../assets/player/peertube-videojs-plugin' |
@@ -21,6 +22,7 @@ import { VideoDownloadComponent } from './modal/video-download.component' | |||
21 | import { VideoReportComponent } from './modal/video-report.component' | 22 | import { VideoReportComponent } from './modal/video-report.component' |
22 | import { VideoShareComponent } from './modal/video-share.component' | 23 | import { VideoShareComponent } from './modal/video-share.component' |
23 | import { VideoBlacklistComponent } from './modal/video-blacklist.component' | 24 | import { VideoBlacklistComponent } from './modal/video-blacklist.component' |
25 | import { SubscribeButtonComponent } from '@app/shared/user-subscription/subscribe-button.component' | ||
24 | import { addContextMenu, getVideojsOptions, loadLocaleInVideoJS } from '../../../assets/player/peertube-player' | 26 | import { addContextMenu, getVideojsOptions, loadLocaleInVideoJS } from '../../../assets/player/peertube-player' |
25 | import { ServerService } from '@app/core' | 27 | import { ServerService } from '@app/core' |
26 | import { I18n } from '@ngx-translate/i18n-polyfill' | 28 | import { I18n } from '@ngx-translate/i18n-polyfill' |
@@ -41,6 +43,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
41 | @ViewChild('videoReportModal') videoReportModal: VideoReportComponent | 43 | @ViewChild('videoReportModal') videoReportModal: VideoReportComponent |
42 | @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent | 44 | @ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent |
43 | @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent | 45 | @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent |
46 | @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent | ||
44 | 47 | ||
45 | player: videojs.Player | 48 | player: videojs.Player |
46 | playerElement: HTMLVideoElement | 49 | playerElement: HTMLVideoElement |
@@ -55,6 +58,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
55 | likesBarTooltipText = '' | 58 | likesBarTooltipText = '' |
56 | hasAlreadyAcceptedPrivacyConcern = false | 59 | hasAlreadyAcceptedPrivacyConcern = false |
57 | remoteServerDown = false | 60 | remoteServerDown = false |
61 | hotkeys: Hotkey[] | ||
58 | 62 | ||
59 | private videojsLocaleLoaded = false | 63 | private videojsLocaleLoaded = false |
60 | private paramsSub: Subscription | 64 | private paramsSub: Subscription |
@@ -77,6 +81,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
77 | private redirectService: RedirectService, | 81 | private redirectService: RedirectService, |
78 | private videoCaptionService: VideoCaptionService, | 82 | private videoCaptionService: VideoCaptionService, |
79 | private i18n: I18n, | 83 | private i18n: I18n, |
84 | private hotkeysService: HotkeysService, | ||
80 | @Inject(LOCALE_ID) private localeId: string | 85 | @Inject(LOCALE_ID) private localeId: string |
81 | ) {} | 86 | ) {} |
82 | 87 | ||
@@ -115,6 +120,24 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
115 | .catch(err => this.handleError(err)) | 120 | .catch(err => this.handleError(err)) |
116 | }) | 121 | }) |
117 | }) | 122 | }) |
123 | |||
124 | this.hotkeys = [ | ||
125 | new Hotkey('L', (event: KeyboardEvent): boolean => { | ||
126 | this.setLike() | ||
127 | return false | ||
128 | }, undefined, 'Like the video'), | ||
129 | new Hotkey('D', (event: KeyboardEvent): boolean => { | ||
130 | this.setDislike() | ||
131 | return false | ||
132 | }, undefined, 'Dislike the video'), | ||
133 | new Hotkey('S', (event: KeyboardEvent): boolean => { | ||
134 | this.subscribeButton.subscribed ? | ||
135 | this.subscribeButton.unsubscribe() : | ||
136 | this.subscribeButton.subscribe() | ||
137 | return false | ||
138 | }, undefined, 'Subscribe to the account') | ||
139 | ] | ||
140 | if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys) | ||
118 | } | 141 | } |
119 | 142 | ||
120 | ngOnDestroy () { | 143 | ngOnDestroy () { |
@@ -122,6 +145,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
122 | 145 | ||
123 | // Unsubscribe subscriptions | 146 | // Unsubscribe subscriptions |
124 | this.paramsSub.unsubscribe() | 147 | this.paramsSub.unsubscribe() |
148 | |||
149 | // Unbind hotkeys | ||
150 | if (this.isUserLoggedIn()) this.hotkeysService.remove(this.hotkeys) | ||
125 | } | 151 | } |
126 | 152 | ||
127 | setLike () { | 153 | setLike () { |