aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2018-09-02 20:54:23 +0200
committerChocobozzz <me@florianbigard.com>2018-09-03 08:49:29 +0200
commit20d211990425af8d9bb5c8eba204d2b485bcd19a (patch)
tree020584a5712b153dc1d7e965287c7f384ae722b1 /client/src/app/videos
parent9a2f7ea799fdd52b24245e94d01f12fabd6efc02 (diff)
downloadPeerTube-20d211990425af8d9bb5c8eba204d2b485bcd19a.tar.gz
PeerTube-20d211990425af8d9bb5c8eba204d2b485bcd19a.tar.zst
PeerTube-20d211990425af8d9bb5c8eba204d2b485bcd19a.zip
add like, dislike and subscribe button hotkeys
Diffstat (limited to 'client/src/app/videos')
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.html2
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts28
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 @@
1import { catchError } from 'rxjs/operators' 1import { catchError, subscribeOn } from 'rxjs/operators'
2import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' 2import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'
3import { ActivatedRoute, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4import { RedirectService } from '@app/core/routing/redirect.service' 4import { RedirectService } from '@app/core/routing/redirect.service'
@@ -9,6 +9,7 @@ import { NotificationsService } from 'angular2-notifications'
9import { forkJoin, Subscription } from 'rxjs' 9import { forkJoin, Subscription } from 'rxjs'
10import * as videojs from 'video.js' 10import * as videojs from 'video.js'
11import 'videojs-hotkeys' 11import 'videojs-hotkeys'
12import { Hotkey, HotkeysService } from 'angular2-hotkeys'
12import * as WebTorrent from 'webtorrent' 13import * as WebTorrent from 'webtorrent'
13import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoRateType, VideoState } from '../../../../../shared' 14import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoRateType, VideoState } from '../../../../../shared'
14import '../../../assets/player/peertube-videojs-plugin' 15import '../../../assets/player/peertube-videojs-plugin'
@@ -21,6 +22,7 @@ import { VideoDownloadComponent } from './modal/video-download.component'
21import { VideoReportComponent } from './modal/video-report.component' 22import { VideoReportComponent } from './modal/video-report.component'
22import { VideoShareComponent } from './modal/video-share.component' 23import { VideoShareComponent } from './modal/video-share.component'
23import { VideoBlacklistComponent } from './modal/video-blacklist.component' 24import { VideoBlacklistComponent } from './modal/video-blacklist.component'
25import { SubscribeButtonComponent } from '@app/shared/user-subscription/subscribe-button.component'
24import { addContextMenu, getVideojsOptions, loadLocaleInVideoJS } from '../../../assets/player/peertube-player' 26import { addContextMenu, getVideojsOptions, loadLocaleInVideoJS } from '../../../assets/player/peertube-player'
25import { ServerService } from '@app/core' 27import { ServerService } from '@app/core'
26import { I18n } from '@ngx-translate/i18n-polyfill' 28import { 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 () {