private flushPlayer () {
// Remove player if it exists
if (this.player) {
- this.player.dispose()
- this.player = undefined
+ try {
+ this.player.dispose()
+ this.player = undefined
+ } catch (err) {
+ console.error('Cannot dispose player.', err)
+ }
}
}
+
+ private initHotkeys () {
+ 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)
+ }
}