@ -38,6 +38,8 @@ embed_url.searchParams.delete('v');
short _url = location . origin + '/' + video _data . id + embed _url . search ;
short _url = location . origin + '/' + video _data . id + embed _url . search ;
embed _url = location . origin + '/embed/' + video _data . id + embed _url . search ;
embed _url = location . origin + '/embed/' + video _data . id + embed _url . search ;
var remember _position _key = "remember_position" ;
var shareOptions = {
var shareOptions = {
socials : [ 'fbFeed' , 'tw' , 'reddit' , 'email' ] ,
socials : [ 'fbFeed' , 'tw' , 'reddit' , 'email' ] ,
@ -199,6 +201,27 @@ if (video_data.premiere_timestamp && Math.round(new Date() / 1000) < video_data.
player . getChild ( 'bigPlayButton' ) . hide ( ) ;
player . getChild ( 'bigPlayButton' ) . hide ( ) ;
}
}
if ( video _data . params . remember _position ) {
const remeberedTime = get _video _time ( ) ;
let lastUpdated = 0 ;
set _seconds _after _start ( remeberedTime ) ;
player . on ( "timeupdate" , e => {
const raw = player . currentTime ( ) ;
const time = Math . floor ( raw ) ;
if ( lastUpdated !== time ) {
save _video _time ( time ) ;
lastUpdated = time ;
}
} ) ;
}
else {
console . log ( "Removing data for remebered positions" ) ;
remove _all _video _times ( ) ;
}
if ( video _data . params . autoplay ) {
if ( video _data . params . autoplay ) {
var bpb = player . getChild ( 'bigPlayButton' ) ;
var bpb = player . getChild ( 'bigPlayButton' ) ;
bpb . hide ( ) ;
bpb . hide ( ) ;
@ -330,6 +353,55 @@ function skip_seconds(delta) {
player . currentTime ( newTime ) ;
player . currentTime ( newTime ) ;
}
}
function set _seconds _after _start ( delta ) {
const start = video _data . params . video _start ;
player . currentTime ( start + delta ) ;
}
function save _video _time ( seconds ) {
const videoId = video _data . id ;
const all _video _times = get _all _video _times ( ) ;
all _video _times [ videoId ] = seconds ;
set _all _video _times ( all _video _times ) ;
}
function get _video _time ( ) {
try {
const videoId = video _data . id ;
const all _video _times = get _all _video _times ( ) ;
const timestamp = all _video _times [ videoId ] ;
return timestamp ;
}
catch {
return 0 ;
}
}
function set _all _video _times ( times ) {
const json = JSON . stringify ( times ) ;
localStorage . setItem ( remember _position _key , json ) ;
}
function get _all _video _times ( ) {
try {
const raw = localStorage . getItem ( remember _position _key ) ;
const times = JSON . parse ( raw ) ;
return times || { } ;
}
catch {
return { } ;
}
}
function remove _all _video _times ( ) {
localStorage . removeItem ( remember _position _key ) ;
}
function set _time _percent ( percent ) {
function set _time _percent ( percent ) {
const duration = player . duration ( ) ;
const duration = player . duration ( ) ;
const newTime = duration * ( percent / 100 ) ;
const newTime = duration * ( percent / 100 ) ;