import { forkJoin, Subscription } from 'rxjs'
import * as videojs from 'video.js'
import 'videojs-hotkeys'
+import { Hotkey, HotkeysService } from 'angular2-hotkeys'
import * as WebTorrent from 'webtorrent'
import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoRateType, VideoState } from '../../../../../shared'
import '../../../assets/player/peertube-videojs-plugin'
import { VideoReportComponent } from './modal/video-report.component'
import { VideoShareComponent } from './modal/video-share.component'
import { VideoBlacklistComponent } from './modal/video-blacklist.component'
+import { SubscribeButtonComponent } from '@app/shared/user-subscription/subscribe-button.component'
import { addContextMenu, getVideojsOptions, loadLocaleInVideoJS } from '../../../assets/player/peertube-player'
import { ServerService } from '@app/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
@ViewChild('videoReportModal') videoReportModal: VideoReportComponent
@ViewChild('videoSupportModal') videoSupportModal: VideoSupportComponent
@ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent
+ @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent
player: videojs.Player
playerElement: HTMLVideoElement
likesBarTooltipText = ''
hasAlreadyAcceptedPrivacyConcern = false
remoteServerDown = false
+ hotkeys: Hotkey[]
private videojsLocaleLoaded = false
private paramsSub: Subscription
private redirectService: RedirectService,
private videoCaptionService: VideoCaptionService,
private i18n: I18n,
+ private hotkeysService: HotkeysService,
@Inject(LOCALE_ID) private localeId: string
) {}
.catch(err => this.handleError(err))
})
})
+
+ this.hotkeys = [
+ new Hotkey('shift+l', (event: KeyboardEvent): boolean => {
+ this.setLike()
+ return false
+ }, undefined, this.i18n('Like the video')),
+ new Hotkey('shift+d', (event: KeyboardEvent): boolean => {
+ this.setDislike()
+ return false
+ }, undefined, this.i18n('Dislike the video')),
+ new Hotkey('shift+s', (event: KeyboardEvent): boolean => {
+ this.subscribeButton.subscribed ?
+ this.subscribeButton.unsubscribe() :
+ this.subscribeButton.subscribe()
+ return false
+ }, undefined, this.i18n('Subscribe to the account'))
+ ]
+ if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys)
}
ngOnDestroy () {
// Unsubscribe subscriptions
this.paramsSub.unsubscribe()
+
+ // Unbind hotkeys
+ if (this.isUserLoggedIn()) this.hotkeysService.remove(this.hotkeys)
}
setLike () {