import videojs from 'video.js'
import { VideoPlaylistElement } from '@shared/models'
import { PlaylistItemOptions } from '../peertube-videojs-typings'
+import { secondsToTime } from '../utils'
const Component = videojs.getComponent('Component')
}
private buildAvailableVideo (li: HTMLElement, positionBlock: HTMLElement, options: PlaylistItemOptions) {
+ const videoElement = options.element
+
const player = super.createEl('div', {
className: 'item-player'
})
positionBlock.appendChild(player)
const thumbnail = super.createEl('img', {
- src: window.location.origin + options.element.video.thumbnailPath
+ src: window.location.origin + videoElement.video.thumbnailPath
})
const infoBlock = super.createEl('div', {
})
const title = super.createEl('div', {
- innerHTML: options.element.video.name,
+ innerHTML: videoElement.video.name,
className: 'title'
})
const channel = super.createEl('div', {
- innerHTML: options.element.video.channel.displayName,
+ innerHTML: videoElement.video.channel.displayName,
className: 'channel'
})
infoBlock.appendChild(title)
infoBlock.appendChild(channel)
+ if (videoElement.startTimestamp || videoElement.stopTimestamp) {
+ let html = ''
+
+ if (videoElement.startTimestamp) html += secondsToTime(videoElement.startTimestamp)
+ if (videoElement.stopTimestamp) html += ' - ' + secondsToTime(videoElement.stopTimestamp)
+
+ const timestamps = super.createEl('div', {
+ innerHTML: html,
+ className: 'timestamps'
+ })
+
+ infoBlock.append(timestamps)
+ }
+
li.append(thumbnail)
li.append(infoBlock)
}
controls: this.controls,
muted: this.muted,
loop: this.loop,
+
captions: videoCaptions.length !== 0,
- startTime: this.startTime,
- stopTime: this.stopTime,
subtitle: this.subtitle,
+ startTime: this.playlist ? this.currentPlaylistElement.startTimestamp : this.startTime,
+ stopTime: this.playlist ? this.currentPlaylistElement.stopTimestamp : this.stopTime,
+
nextVideo: this.playlist ? () => this.playNextVideo() : undefined,
hasNextVideo: this.playlist ? () => !!this.getNextPlaylistElement() : undefined,
if (this.isPlaylistEmbed()) {
await this.buildPlaylistManager()
+
this.player.playlist().updateSelected()
+
+ this.player.on('stopped', () => {
+ this.playNextVideo()
+ })
}
}