import { AuthService, AuthUser, ConfirmService, MarkdownService, Notifier, RestExtractor, ServerService, UserService } from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service'
import { RedirectService } from '@app/core/routing/redirect.service'
-import { isXPercentInViewport, peertubeLocalStorage, scrollToTop } from '@app/helpers'
+import { isXPercentInViewport, scrollToTop } from '@app/helpers'
import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
+import { VideoShareComponent } from '@app/shared/shared-share-modal'
import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
+import { VideoDownloadComponent } from '@app/shared/shared-video-miniature'
import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
import { MetaService } from '@ngx-meta/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
+import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
import { ServerConfig, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models'
import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage'
import {
} from '../../../assets/player/peertube-player-manager'
import { isWebRTCDisabled, timeToInt } from '../../../assets/player/utils'
import { environment } from '../../../environments/environment'
-import { VideoShareComponent } from './modal/video-share.component'
import { VideoSupportComponent } from './modal/video-support.component'
import { VideoWatchPlaylistComponent } from './video-watch-playlist.component'
-import { VideoDownloadComponent } from '@app/shared/shared-video-miniature'
@Component({
selector: 'my-video-watch',
// Unsubscribe subscriptions
if (this.paramsSub) this.paramsSub.unsubscribe()
if (this.queryParamsSub) this.queryParamsSub.unsubscribe()
+ if (this.configSub) this.configSub.unsubscribe()
// Unbind hotkeys
this.hotkeysService.remove(this.hotkeys)
}
showSupportModal () {
+ // Check video was playing before opening support modal
+ const isVideoPlaying = this.isPlaying()
+
this.pausePlayer()
- this.videoSupportModal.show()
+ const modalRef = this.videoSupportModal.show()
+
+ modalRef.result.then(() => {
+ if (isVideoPlaying) {
+ this.resumePlayer()
+ }
+ })
}
showShareModal () {
this.pausePlayer()
- this.videoShareModal.show(this.currentTime)
+ this.videoShareModal.show(this.currentTime, this.videoWatchPlaylist.currentPlaylistPosition)
}
isUserLoggedIn () {
this.player.pause()
}
+ private resumePlayer () {
+ if (!this.player) return
+
+ this.player.play()
+ }
+
+ private isPlaying () {
+ if (!this.player) return
+
+ return !this.player.paused()
+ }
+
private initHotkeys () {
this.hotkeys = [
// These hotkeys are managed by the player