Commit 21ebaeec authored by Anton's avatar Anton

Respect start and duration in video cell

parent 8eae78cc
......@@ -6,6 +6,7 @@
:annotation="video || fauxVideo",
@ready="handlePlayerReady",
@play="handlePlayerPlaying",
@canplay:once="onCanPlay",
@time="handlePlayerTimeChange")
template(v-else)
......@@ -72,6 +73,15 @@
}
},
methods: {
onCanPlay () {
console.log('player can play')
if (this.cell.start) {
console.log('video cell', this.cell.start, this.cell.duration)
if (this.player) {
this.player.currentTime(this.cell.start)
}
}
},
getSignature () {
if (this.video) {
return { origin: this.video, type: 'Video' }
......@@ -82,11 +92,16 @@
},
setPlayerTimeFromDateTime (datetime) {
if (this.player && this.videoTime) {
const movieTime = Interval.fromDateTimes(this.videoTime, datetime)
.toDuration()
.as('seconds')
console.debug('CellVideo: setting player to second', movieTime)
this.player.currentTime(movieTime)
try {
const movieTime = Interval.fromDateTimes(this.videoTime, datetime)
.toDuration()
.as('seconds')
console.debug('CellVideo: setting player to second', movieTime)
this.player.currentTime(movieTime)
}
catch (e) {
console.debug('Failed to set time', e.message)
}
}
},
handlePlayerReady (player) {
......@@ -97,6 +112,11 @@
this.$root.$emit('video-started-playing', this.getSignature())
},
handlePlayerTimeChange (localTime) {
if (this.cell.start && localTime < this.cell.start) return this.player.currentTime(this.cell.start)
if (this.cell.duration && localTime > this.cell.start + this.cell.duration) {
this.player.pause()
return this.player.currentTime(this.cell.start + this.cell.duration)
}
let globalTime = DateTime.local()
if (this.videoTime) {
globalTime = this.videoTime.plus(localTime * 1000.0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment